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

feat: add pie langium parser #4751

Merged
merged 53 commits into from
Feb 11, 2024

Conversation

Yokozuna59
Copy link
Member

@Yokozuna59 Yokozuna59 commented Aug 20, 2023

📑 Summary

  • Create pie langium parser and integrate it in packages/mermaid.
  • ignore yaml, comments, and directives in pie grammar

BREAKING CHANGES

  • Remove cleanValue from pieDb.
  • Rename D3Sections into D3Section
  • Change addSection header into D3Section type

Issues

📏 Design Decisions

📋 Tasks

Make sure you

@Yokozuna59 Yokozuna59 changed the title feat: add pie langium parser feat: add pie langium parser Aug 20, 2023
@codecov
Copy link

codecov bot commented Aug 20, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (a344d88) 44.54% compared to head (25cd86f) 44.54%.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             next    #4751   +/-   ##
=======================================
  Coverage   44.54%   44.54%           
=======================================
  Files          25       25           
  Lines        5246     5246           
  Branches       27       27           
=======================================
  Hits         2337     2337           
  Misses       2908     2908           
  Partials        1        1           
Flag Coverage Δ
unit 44.54% <ø> (ø)

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

@Yokozuna59
Copy link
Member Author

I think we should change sections type into list of D3Section:

export interface D3Sections {
label: string;
value: number;
}

Since it's what d3 uses:

const pieData: D3Sections[] = Object.entries(sections).map(
(element: [string, number]): D3Sections => {
return {
label: element[0],
value: element[1],
};
}
);

And the returned value from mermaid-parser:

export interface PieSection extends AstNode {
    readonly $container: Pie;
    readonly $type: 'PieSection';
    label: string;
    value: number;
}

@Yokozuna59 Yokozuna59 force-pushed the add-pie-langium-parser branch 2 times, most recently from fc7c798 to 1ffa9ca Compare August 20, 2023 19:43
* next: (70 commits)
  chore: Add comment for `yy`.
  chore: Increase heap size when building
  chore: increase `test-util.ts` converage by returning `undefined`
  chore: add `vitest` imports to `test-util.ts`
  chore: run `pnpm lint:fix`
  create `noErrorsOrAlternatives` parser helper function
  chore: export `InfoModule` from `infoModule.ts`
  docs: Fix link
  Update docs
  fix(pie): align slices and legend orders
  Mermaid version v10.4.0
  unique batches every time, if not repeated tests end up in the same batch
  Added missed .md
  Increase JS heap
  More tests for redirects + prettier
  Fixed redirects inside vitepress, extended tests
  chore: Explain redirect.ts clearly
  docs: Fix npmjs link
  chore: Update editor.bash to build latest version
  chore: Build after clone
  ...
@netlify
Copy link

netlify bot commented Aug 28, 2023

Deploy Preview for mermaid-js ready!

Name Link
🔨 Latest commit 25cd86f
🔍 Latest deploy log https://app.netlify.com/sites/mermaid-js/deploys/65c8e038cf77b7000894d7b8
😎 Deploy Preview https://deploy-preview-4751--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.

Yokozuna59 and others added 3 commits August 28, 2023 12:11
Co-authored-by: Sidharth Vinod <sidharthv96@gmail.com>
Co-authored-by: Sidharth Vinod <sidharthv96@gmail.com>
@Yokozuna59
Copy link
Member Author

@sidharthv96 seeing that you renamed some files in 11b60ce, should we rename all other files?

@sidharthv96
Copy link
Member

@sidharthv96 seeing that you renamed some files in 11b60ce, should we rename all other files?

Renaming the files might not be a bad idea.

#4499 (comment)

@Yokozuna59
Copy link
Member Author

@sidharthv96 suggested comments are applied.

Should we add the AstNode omit type and use it or not? And what about this comment #4751 (comment).

* pref: optimize `common` rules and matchers
* chore: rename diagrams services to short form
* chore: sort imports
@sidharthv96
Copy link
Member

@Yokozuna59 Hope the exams were a breeze :)
Merging this to next, we can add the new approach as you mentioned there.

* next: (35 commits)
  docs: fix lint
  docs: move community to Discord
  Swap condition blocks to avoid using negation
  Reposition const declaration to ideal place
  Change repetitive values into consts
  docs: fix swimm link
  Fix Update Browserslist
  Use pnpm/action-setup@v2
  Fix lint
  Delete docs/syntax/gantt.html
  Add more detailed docs for Gantt tasks
  Update docs
  Update packages/mermaid/src/docs/syntax/flowchart.md
  Update flowchart.md mermaid-js#5195
  Add tests for gitgraphs with unconnected branches
  Include logic for gitgraph with unconnected branches
  Include undefined on findClosestParent return types and update the function
  Remove unnecessary argument on findClosestParent call
  Use already defined const instead of method call
  Fix pnpm-lock by resetting it, sorry!
  ...
@Yokozuna59
Copy link
Member Author

@sidharthv96 I merged packet diagram changes to this PR, some modification has been to that approach so it would inline with the current one, e.g., remove Lexer and use EOL.

@Yokozuna59
Copy link
Member Author

@sidharthv96 Do you know why the ZenUML Cypress test keeps failing? I haven't modified it files.

@Yokozuna59
Copy link
Member Author

@sidharthv96 Any updates on this PR? It's currently blocking #4799 and other parsers future PRs. I plan to work on the mindmap diagram since its files have been converted to TS in #5247, but I need the changes that have been implemented in this PR.

@sidharthv96
Copy link
Member

Is the E2E failure valid?

@Yokozuna59
Copy link
Member Author

They’re, although I’m not sure why because I haven’t touched ZenUml files.

…d into pr/Yokozuna59/4751

* 'add-pie-langium-parser' of github.com:Yokozuna59/mermaid: (48 commits)
  make pie parser async
  Changes to gantt.html 1. Added a Gantt diagram that demonstrates to users that hashtages and semicolons can be added to titles, sections, and task data. Changes to gantt.spec.js 1. Added unit tests to ensure that semicolons and hashtags didn't break the functionality of the gantt diagram when used in titles, sections or task data. Changes to /parser/gantt.spec.js 1. Added rendering tests to ensure that semicolons and hashtags in titles, sections, and task data didn't break the rendering of Gantt diagrams.
  perf: prevent adding multiple DOMPurify hooks
  Update docs
  chore: Update tests
  Fix types
  refactor: Make parser.parse async
  refactor: Support async parsers Add `Diagram.fromText`
  Lint
  Remove echo
  RefTest
  Echo event
  Update cypress
  Fix applitools
  Fix applitools
  add sequenceDiagram link e2e test
  fix sequence diagram popup
  Changes to gantt.jison 1. Consistent spacing on line 30
  Changes to gantt.jison 1. Removed typo
  Changes to gnatt.jison 1. Removed the hash and semicolon symbols from the title regex to allow for their use. 2. Removed the hash and semicolon symbols from the section regex to allow for their use. 3. Removed the hash and semicolon symbols for the taskTxt regex to allow for their use. I did not remove the colon because the parser fails to recognize when the actual taskData begins if that distinctions isn't kept. 4. Removed the regex \#[^\n]* which skipped comments to fix some bugs with hash symbols in the taskTxt. I tested this changed by putting it back and using the comment  to see if it was recognized as a comment, but I would receive a syntax error and the diagram would not be rendered. So, I think we can safely remove that line, BUT it would be best practice if someone else tested this change to ensure that this will not break anyone's Gantt diagrams.
  ...
* next: (118 commits)
  Update Deps
  chore(deps): update all patch dependencies
  fix typo cutomers => customers
  chore(deps): update all minor dependencies
  Fix macOS onboarding issues
  Bump @zenuml/core and update render options in mermaid-zenuml (mermaid-js#5257)
  Fixed Typo in ErrorRenderer.ts (mermaid-js#5256)
  mermaid-js#3358 Removing redundant file
  mermaid-js#3358 Fix after review
  Fix selector
  mermaid-js#3358 Renaming of IOperation to ActionFun
  chore: Add interface naming
  build(deps-dev): bump vite from 4.4.12 to 4.5.2
  Update container
  Update container
  Remove pnpm cache
  3358 Adding types for blockArrowHelper
  #3358n Updated lockfile
  Update docs
  mermaid-js#3358 Another set of review changes
  ...
* next:
  Fix BlockDiagramConfig
  Fix docs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pie chart is not rendered when we provide any other value except positive number
3 participants