Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TreeView Diagram #5665

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from

Conversation

Vikrantpalle
Copy link

@Vikrantpalle Vikrantpalle commented Jul 25, 2024

📑 Summary

This PR introduces a new diagram named TreeView which displays hierarchical directory-like structures.

Resolves #2645

📷 Example

treeview_example

💻 Code

treeView-beta
  packages
    mermaid
      dist
      diagrams
        block
        fold
          parser
            parser.jison
  dist

📏 Design Decisions

The features of the diagram focus on user flexibility and ease of use.

  • Simple Syntax: The structure of the tree depends only on the indentation of rows.
  • User Flexibility: Users have the flexibility to change most aspects of the diagram including font size, padding, line thickness, etc.
  • Dynamic Layout: The rows and lines are laid out dynamically based on the changing size of labels.

📋 Tasks

Make sure you

@github-actions github-actions bot added the Type: Enhancement New feature or request label Jul 25, 2024
Copy link

netlify bot commented Jul 25, 2024

Deploy Preview for mermaid-js ready!

Name Link
🔨 Latest commit 353a208
🔍 Latest deploy log https://app.netlify.com/sites/mermaid-js/deploys/66a41565d04b2d00080a0f56
😎 Deploy Preview https://deploy-preview-5665--mermaid-js.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

codecov bot commented Jul 25, 2024

Codecov Report

Attention: Patch coverage is 1.03359% with 383 lines in your changes missing coverage. Please review.

Project coverage is 5.81%. Comparing base (c91dc7d) to head (353a208).
Report is 1359 commits behind head on develop.

Files with missing lines Patch % Lines
packages/mermaid/src/diagrams/treeView/renderer.ts 0.00% 126 Missing ⚠️
packages/mermaid/src/diagrams/treeView/db.ts 0.00% 79 Missing ⚠️
packages/parser/src/language/treeView/module.ts 0.00% 77 Missing ⚠️
packages/mermaid/src/diagrams/treeView/styles.ts 0.00% 26 Missing ⚠️
packages/mermaid/src/diagrams/treeView/detector.ts 0.00% 21 Missing ⚠️
packages/mermaid/src/diagrams/treeView/parser.ts 0.00% 18 Missing ⚠️
packages/mermaid/src/diagrams/treeView/diagram.ts 0.00% 12 Missing ⚠️
packages/parser/src/parse.ts 0.00% 8 Missing ⚠️
...kages/parser/src/language/treeView/tokenBuilder.ts 0.00% 7 Missing ⚠️
...s/mermaid/src/diagram-api/diagram-orchestration.ts 0.00% 3 Missing ⚠️
... and 4 more
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           develop   #5665      +/-   ##
==========================================
- Coverage     5.85%   5.81%   -0.05%     
==========================================
  Files          274     282       +8     
  Lines        41112   41485     +373     
  Branches       488     521      +33     
==========================================
+ Hits          2408    2412       +4     
- Misses       38704   39073     +369     
Flag Coverage Δ
unit 5.81% <1.03%> (-0.05%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
packages/mermaid/src/defaultConfig.ts 47.14% <100.00%> (+0.76%) ⬆️
.build/jsonSchema.ts 0.00% <0.00%> (ø)
packages/mermaid/src/docs/.vitepress/config.ts 0.00% <0.00%> (ø)
packages/parser/src/language/treeView/index.ts 0.00% <0.00%> (ø)
...s/mermaid/src/diagram-api/diagram-orchestration.ts 0.00% <0.00%> (ø)
packages/parser/src/language/index.ts 0.00% <0.00%> (ø)
...kages/parser/src/language/treeView/tokenBuilder.ts 0.00% <0.00%> (ø)
packages/parser/src/parse.ts 0.00% <0.00%> (ø)
packages/mermaid/src/diagrams/treeView/diagram.ts 0.00% <0.00%> (ø)
packages/mermaid/src/diagrams/treeView/parser.ts 0.00% <0.00%> (ø)
... and 5 more

... and 1 file with indirect coverage changes

Copy link

argos-ci bot commented Jul 25, 2024

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) ⚠️ Changes detected (Review) 3 added Jul 26, 2024, 9:40 PM

Copy link
Member

@sidharthv96 sidharthv96 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work @Vikrantpalle !!
Just some convention issues, and the langium change.

packages/mermaid/src/diagrams/treeView/parser/parser.jison Outdated Show resolved Hide resolved
packages/mermaid/src/diagrams/treeView/styles.ts Outdated Show resolved Hide resolved
packages/mermaid/src/diagrams/treeView/types.ts Outdated Show resolved Hide resolved
packages/mermaid/src/diagrams/treeView/db.ts Outdated Show resolved Hide resolved
packages/mermaid/src/diagrams/treeView/detector.ts Outdated Show resolved Hide resolved
Copy link
Member

@sidharthv96 sidharthv96 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wonderful!!
All we need is some documentation and tests.

Existing tests can be found in cypress/integration/rendering
Documentation needs to be added in packages/mermaid/src/docs/syntax

@Vikrantpalle Vikrantpalle requested a review from sidharthv96 July 26, 2024 21:43
@sidharthv96
Copy link
Member

@Vikrantpalle looks great to me! I'd say this PR is feature complete. 🚀

But treeView is a bit generic name to use for this diagram, as there are other issues/requests which could also be named a treeView.

What are your thoughts on renaming this to something more specific?
Few suggestions, fileTree, fileStructure, fileSystem. Open to more suggestions.

@george-gca
Copy link

Maybe hierarchicalTree, since this can be used to more than just files and directories. For example, one could use to display a list of dependencies to a library and its subdependencies.

@Vikrantpalle
Copy link
Author

I feel like hierarchichalTree might be a bit too verbose. What about listTree or treeList? As the tree is being represented by a hierarchical list.

@george-gca
Copy link

george-gca commented Jul 27, 2024

I think listTree is not clear enough as a name. By reading hierarchicalTree you can have a better sense of what to expect. Also it is not that verbose. What about hierarchyTree? It's 5 chars longer than listTree.

@sgaechter
Copy link

sgaechter commented Jul 28, 2024

I would suggest TreeList. Because this is the purpose of it.

@sidharthv96
Copy link
Member

I'm also leaning towards treeList, as it's a tree that's represented as a list.

"Hierarchical Tree" is a tautology because "tree" already implies a hierarchical structure. So either hierarchy or tree can be used, in which we can pick tree, as it's simpler. As it's represented as a list, treeList is a suitable option.

The only issue I'm thinking is, if someone tries to write a file system diagram, they might not know what a treeList is. But I guess we can handle that in the documentation and the sample buttons in live editor?

@Vikrantpalle
Copy link
Author

I think documentation and examples is the way to go too.

I think the only other way to solve the problem is explicitly mention file or directory in the name. But suppose we name it as fileTree then the name isn't indicating that the diagram is a list and can be interpreted as a flowchart diagram with file names as nodes. Alternatively, fileList can be interpreted as a list of files without the hierarchical structure.

Since both list and tree are key to give context to the diagram I feel like treeList might be the way to go while sacrificing some brevity.

@aromeronavia
Copy link

aromeronavia commented Jul 30, 2024

Throwing out an idea name, what about FileStructure, FileHierarchy? fileTree sounds very intuitive if we think about code editors, that's basically how industry calls the sidebar.

@Austin-Fulbright
Copy link
Contributor

Hey quick comment on the langium file I saw that you were pasting the code from the common.langium into your file as opposed to importing it. If this is because it does not parse the TitleAndAccessabilities tokens correctly, I ran into the same problem and am currently working on figuring out why this happens.

@Vikrantpalle
Copy link
Author

I actually didn’t import the common file as whitespace is a hidden terminal in the common file, but is necessary to track indentation for the syntax.

@Austin-Fulbright
Copy link
Contributor

Austin-Fulbright commented Aug 5, 2024

That makes sense. I feel like maybe the common should be separated out a bit. So if you import common/common it will give you the ability to use the TitleAndAccessabilities but leave out the terminals not related to it. And then you can have a seperate file called like common/terminals if you want to use all the terminals. Just so we can reuse the code that is written for the TitleAndAccesabilities.

@becky-intelletive
Copy link

So exciting to see this nearing completion! Is there anything remaining? I'd love to use it 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Folder structure Diagram
7 participants