merge from develop

This commit is contained in:
Ashish Jain 2024-07-19 10:31:52 +02:00
commit 5b47950f9f
16 changed files with 1745 additions and 510 deletions

41
.github/workflows/autofix.yml vendored Normal file
View File

@ -0,0 +1,41 @@
name: autofix.ci # needed to securely identify the workflow
on:
pull_request:
permissions:
contents: read
jobs:
autofix:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
# uses version from "packageManager" field in package.json
- name: Setup Node.js
uses: actions/setup-node@v4
with:
cache: pnpm
node-version-file: '.node-version'
- name: Install Packages
run: |
pnpm install --frozen-lockfile
env:
CYPRESS_CACHE_FOLDER: .cache/Cypress
- name: Fix Linting
shell: bash
run: pnpm -w run lint:fix
- name: Sync `./src/config.type.ts` with `./src/schemas/config.schema.yaml`
shell: bash
run: pnpm run --filter mermaid types:build-config
- name: Build Docs
working-directory: ./packages/mermaid
run: pnpm run docs:build
- uses: autofix-ci/action@dd55f44df8f7cdb7a6bf74c78677eb8acd40cd0a

View File

@ -82,15 +82,3 @@ jobs:
working-directory: ./packages/mermaid working-directory: ./packages/mermaid
continue-on-error: ${{ github.event_name == 'push' }} continue-on-error: ${{ github.event_name == 'push' }}
run: pnpm run docs:verify run: pnpm run docs:verify
- name: Rebuild Docs
if: ${{ steps.verifyDocs.outcome == 'failure' && github.event_name == 'push' }}
working-directory: ./packages/mermaid
run: pnpm run docs:build
- name: Commit changes
uses: EndBug/add-and-commit@v9
if: ${{ steps.verifyDocs.outcome == 'failure' && github.event_name == 'push' }}
with:
message: 'Update docs'
add: 'docs/*'

View File

@ -1532,5 +1532,41 @@ gitGraph TB:
{} {}
); );
}); });
it('75: should render a gitGraph with multiple tags on a merge commit on bottom-to-top orientation', () => {
imgSnapshotTest(
`gitGraph BT:
commit id: "ZERO"
branch develop
commit id:"A"
checkout main
commit id:"ONE"
checkout develop
commit id:"B"
checkout main
merge develop id:"Release 1.0" type:HIGHLIGHT tag: "SAML v2.0" tag: "OpenID v1.1"
commit id:"TWO"
checkout develop
commit id:"C"`,
{}
);
});
});
it('76: should render a gitGraph with multiple tags on a merge commit on left-to-right orientation', () => {
imgSnapshotTest(
`gitGraph
commit id: "ZERO"
branch develop
commit id:"A"
checkout main
commit id:"ONE"
checkout develop
commit id:"B"
checkout main
merge develop id:"Release 1.0" type:HIGHLIGHT tag: "SAML v2.0" tag: "OpenID v1.1"
commit id:"TWO"
checkout develop
commit id:"C"`,
{}
);
}); });
}); });

View File

@ -208,6 +208,7 @@ Communication tools and platforms
- [gatsby-remark-mermaid](https://github.com/remcohaszing/gatsby-remark-mermaid) - [gatsby-remark-mermaid](https://github.com/remcohaszing/gatsby-remark-mermaid)
- [JSDoc](https://jsdoc.app/) - [JSDoc](https://jsdoc.app/)
- [jsdoc-mermaid](https://github.com/Jellyvision/jsdoc-mermaid) - [jsdoc-mermaid](https://github.com/Jellyvision/jsdoc-mermaid)
- [Madness](https://madness.dannyb.co/)
- [mdBook](https://rust-lang.github.io/mdBook/index.html) - [mdBook](https://rust-lang.github.io/mdBook/index.html)
- [mdbook-mermaid](https://github.com/badboy/mdbook-mermaid) - [mdbook-mermaid](https://github.com/badboy/mdbook-mermaid)
- [MkDocs](https://www.mkdocs.org) - [MkDocs](https://www.mkdocs.org)

View File

@ -136,7 +136,7 @@ Cardinality is a property that describes how many elements of another entity can
| 1+ | 1+ | One or more | | 1+ | 1+ | One or more |
| zero or more | zero or more | Zero or more | | zero or more | zero or more | Zero or more |
| zero or many | zero or many | Zero or more | | zero or many | zero or many | Zero or more |
| many(0) | many(1) | Zero or more | | many(0) | many(0) | Zero or more |
| 0+ | 0+ | Zero or more | | 0+ | 0+ | Zero or more |
| only one | only one | Exactly one | | only one | only one | Exactly one |
| 1 | 1 | Exactly one | | 1 | 1 | Exactly one |

View File

@ -12,7 +12,7 @@ A packet diagram is a visual representation used to illustrate the structure and
## Usage ## Usage
This diagram type is particularly useful for network engineers, educators, and students who require a clear and concise way to represent the structure of network packets. This diagram type is particularly useful for developers, network engineers, educators, and students who require a clear and concise way to represent the structure of network packets.
## Syntax ## Syntax

View File

@ -12,8 +12,7 @@ import {
getDiagramTitle, getDiagramTitle,
} from '../common/commonDb.js'; } from '../common/commonDb.js';
let mainBranchName = getConfig().gitGraph.mainBranchName; let { mainBranchName, mainBranchOrder } = getConfig().gitGraph;
let mainBranchOrder = getConfig().gitGraph.mainBranchOrder;
let commits = new Map(); let commits = new Map();
let head = null; let head = null;
let branchesConfig = new Map(); let branchesConfig = new Map();
@ -103,17 +102,18 @@ export const getOptions = function () {
return options; return options;
}; };
export const commit = function (msg, id, type, tag) { export const commit = function (msg, id, type, tags) {
log.debug('Entering commit:', msg, id, type, tag); log.debug('Entering commit:', msg, id, type, tags);
id = common.sanitizeText(id, getConfig()); const config = getConfig();
msg = common.sanitizeText(msg, getConfig()); id = common.sanitizeText(id, config);
tag = common.sanitizeText(tag, getConfig()); msg = common.sanitizeText(msg, config);
tags = tags?.map((tag) => common.sanitizeText(tag, config));
const commit = { const commit = {
id: id ? id : seq + '-' + getId(), id: id ? id : seq + '-' + getId(),
message: msg, message: msg,
seq: seq++, seq: seq++,
type: type ? type : commitType.NORMAL, type: type ? type : commitType.NORMAL,
tag: tag ? tag : '', tags: tags ?? [],
parents: head == null ? [] : [head.id], parents: head == null ? [] : [head.id],
branch: curBranch, branch: curBranch,
}; };
@ -147,9 +147,10 @@ export const branch = function (name, order) {
} }
}; };
export const merge = function (otherBranch, custom_id, override_type, custom_tag) { export const merge = function (otherBranch, custom_id, override_type, custom_tags) {
otherBranch = common.sanitizeText(otherBranch, getConfig()); const config = getConfig();
custom_id = common.sanitizeText(custom_id, getConfig()); otherBranch = common.sanitizeText(otherBranch, config);
custom_id = common.sanitizeText(custom_id, config);
const currentCommit = commits.get(branches.get(curBranch)); const currentCommit = commits.get(branches.get(curBranch));
const otherCommit = commits.get(branches.get(otherBranch)); const otherCommit = commits.get(branches.get(otherBranch));
@ -216,12 +217,12 @@ export const merge = function (otherBranch, custom_id, override_type, custom_tag
' already exists, use different custom Id' ' already exists, use different custom Id'
); );
error.hash = { error.hash = {
text: 'merge ' + otherBranch + custom_id + override_type + custom_tag, text: 'merge ' + otherBranch + custom_id + override_type + custom_tags?.join(','),
token: 'merge ' + otherBranch + custom_id + override_type + custom_tag, token: 'merge ' + otherBranch + custom_id + override_type + custom_tags?.join(','),
line: '1', line: '1',
loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 }, loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 },
expected: [ expected: [
'merge ' + otherBranch + ' ' + custom_id + '_UNIQUE ' + override_type + ' ' + custom_tag, `merge ${otherBranch} ${custom_id}_UNIQUE ${override_type} ${custom_tags?.join(',')}`,
], ],
}; };
@ -245,7 +246,7 @@ export const merge = function (otherBranch, custom_id, override_type, custom_tag
type: commitType.MERGE, type: commitType.MERGE,
customType: override_type, customType: override_type,
customId: custom_id ? true : false, customId: custom_id ? true : false,
tag: custom_tag ? custom_tag : '', tags: custom_tags ? custom_tags : [],
}; };
head = commit; head = commit;
commits.set(commit.id, commit); commits.set(commit.id, commit);
@ -255,12 +256,13 @@ export const merge = function (otherBranch, custom_id, override_type, custom_tag
log.debug('in mergeBranch'); log.debug('in mergeBranch');
}; };
export const cherryPick = function (sourceId, targetId, tag, parentCommitId) { export const cherryPick = function (sourceId, targetId, tags, parentCommitId) {
log.debug('Entering cherryPick:', sourceId, targetId, tag); log.debug('Entering cherryPick:', sourceId, targetId, tags);
sourceId = common.sanitizeText(sourceId, getConfig()); const config = getConfig();
targetId = common.sanitizeText(targetId, getConfig()); sourceId = common.sanitizeText(sourceId, config);
tag = common.sanitizeText(tag, getConfig()); targetId = common.sanitizeText(targetId, config);
parentCommitId = common.sanitizeText(parentCommitId, getConfig()); tags = tags?.map((tag) => common.sanitizeText(tag, config));
parentCommitId = common.sanitizeText(parentCommitId, config);
if (!sourceId || !commits.has(sourceId)) { if (!sourceId || !commits.has(sourceId)) {
let error = new Error( let error = new Error(
@ -329,11 +331,13 @@ export const cherryPick = function (sourceId, targetId, tag, parentCommitId) {
parents: [head == null ? null : head.id, sourceCommit.id], parents: [head == null ? null : head.id, sourceCommit.id],
branch: curBranch, branch: curBranch,
type: commitType.CHERRY_PICK, type: commitType.CHERRY_PICK,
tag: tags: tags
tag ?? ? tags.filter(Boolean)
`cherry-pick:${sourceCommit.id}${ : [
sourceCommit.type === commitType.MERGE ? `|parent:${parentCommitId}` : '' `cherry-pick:${sourceCommit.id}${
}`, sourceCommit.type === commitType.MERGE ? `|parent:${parentCommitId}` : ''
}`,
],
}; };
head = commit; head = commit;
commits.set(commit.id, commit); commits.set(commit.id, commit);
@ -356,8 +360,6 @@ export const checkout = function (branch) {
expected: ['"branch ' + branch + '"'], expected: ['"branch ' + branch + '"'],
}; };
throw error; throw error;
//branches[branch] = head != null ? head.id : null;
//log.debug('in createBranch');
} else { } else {
curBranch = branch; curBranch = branch;
const id = branches.get(curBranch); const id = branches.get(curBranch);
@ -444,13 +446,12 @@ export const prettyPrint = function () {
export const clear = function () { export const clear = function () {
commits = new Map(); commits = new Map();
head = null; head = null;
let mainBranch = getConfig().gitGraph.mainBranchName; const { mainBranchName, mainBranchOrder } = getConfig().gitGraph;
let mainBranchOrder = getConfig().gitGraph.mainBranchOrder;
branches = new Map(); branches = new Map();
branches.set(mainBranch, null); branches.set(mainBranchName, null);
branchesConfig = new Map(); branchesConfig = new Map();
branchesConfig.set(mainBranch, { name: mainBranch, order: mainBranchOrder }); branchesConfig.set(mainBranchName, { name: mainBranchName, order: mainBranchOrder });
curBranch = mainBranch; curBranch = mainBranchName;
seq = 0; seq = 0;
commonClear(); commonClear();
}; };

View File

@ -20,7 +20,7 @@ describe('when parsing a gitGraph', function () {
const key = commits.keys().next().value; const key = commits.keys().next().value;
expect(commits.get(key).message).toBe(''); expect(commits.get(key).message).toBe('');
expect(commits.get(key).id).not.toBeNull(); expect(commits.get(key).id).not.toBeNull();
expect(commits.get(key).tag).toBe(''); expect(commits.get(key).tags).toStrictEqual([]);
expect(commits.get(key).type).toBe(0); expect(commits.get(key).type).toBe(0);
}); });
@ -37,7 +37,7 @@ describe('when parsing a gitGraph', function () {
const key = commits.keys().next().value; const key = commits.keys().next().value;
expect(commits.get(key).message).toBe(''); expect(commits.get(key).message).toBe('');
expect(commits.get(key).id).toBe('1111'); expect(commits.get(key).id).toBe('1111');
expect(commits.get(key).tag).toBe(''); expect(commits.get(key).tags).toStrictEqual([]);
expect(commits.get(key).type).toBe(0); expect(commits.get(key).type).toBe(0);
}); });
@ -55,7 +55,7 @@ describe('when parsing a gitGraph', function () {
const key = commits.keys().next().value; const key = commits.keys().next().value;
expect(commits.get(key).message).toBe(''); expect(commits.get(key).message).toBe('');
expect(commits.get(key).id).not.toBeNull(); expect(commits.get(key).id).not.toBeNull();
expect(commits.get(key).tag).toBe('test'); expect(commits.get(key).tags).toStrictEqual(['test']);
expect(commits.get(key).type).toBe(0); expect(commits.get(key).type).toBe(0);
}); });
@ -73,7 +73,7 @@ describe('when parsing a gitGraph', function () {
const key = commits.keys().next().value; const key = commits.keys().next().value;
expect(commits.get(key).message).toBe(''); expect(commits.get(key).message).toBe('');
expect(commits.get(key).id).not.toBeNull(); expect(commits.get(key).id).not.toBeNull();
expect(commits.get(key).tag).toBe(''); expect(commits.get(key).tags).toStrictEqual([]);
expect(commits.get(key).type).toBe(2); expect(commits.get(key).type).toBe(2);
}); });
@ -91,7 +91,7 @@ describe('when parsing a gitGraph', function () {
const key = commits.keys().next().value; const key = commits.keys().next().value;
expect(commits.get(key).message).toBe(''); expect(commits.get(key).message).toBe('');
expect(commits.get(key).id).not.toBeNull(); expect(commits.get(key).id).not.toBeNull();
expect(commits.get(key).tag).toBe(''); expect(commits.get(key).tags).toStrictEqual([]);
expect(commits.get(key).type).toBe(1); expect(commits.get(key).type).toBe(1);
}); });
@ -109,7 +109,7 @@ describe('when parsing a gitGraph', function () {
const key = commits.keys().next().value; const key = commits.keys().next().value;
expect(commits.get(key).message).toBe(''); expect(commits.get(key).message).toBe('');
expect(commits.get(key).id).not.toBeNull(); expect(commits.get(key).id).not.toBeNull();
expect(commits.get(key).tag).toBe(''); expect(commits.get(key).tags).toStrictEqual([]);
expect(commits.get(key).type).toBe(0); expect(commits.get(key).type).toBe(0);
}); });
@ -127,7 +127,7 @@ describe('when parsing a gitGraph', function () {
const key = commits.keys().next().value; const key = commits.keys().next().value;
expect(commits.get(key).message).toBe('test commit'); expect(commits.get(key).message).toBe('test commit');
expect(commits.get(key).id).not.toBeNull(); expect(commits.get(key).id).not.toBeNull();
expect(commits.get(key).tag).toBe(''); expect(commits.get(key).tags).toStrictEqual([]);
expect(commits.get(key).type).toBe(0); expect(commits.get(key).type).toBe(0);
}); });
@ -145,7 +145,7 @@ describe('when parsing a gitGraph', function () {
const key = commits.keys().next().value; const key = commits.keys().next().value;
expect(commits.get(key).message).toBe('test commit'); expect(commits.get(key).message).toBe('test commit');
expect(commits.get(key).id).not.toBeNull(); expect(commits.get(key).id).not.toBeNull();
expect(commits.get(key).tag).toBe(''); expect(commits.get(key).tags).toStrictEqual([]);
expect(commits.get(key).type).toBe(0); expect(commits.get(key).type).toBe(0);
}); });
@ -163,7 +163,7 @@ describe('when parsing a gitGraph', function () {
const key = commits.keys().next().value; const key = commits.keys().next().value;
expect(commits.get(key).message).toBe(''); expect(commits.get(key).message).toBe('');
expect(commits.get(key).id).toBe('1111'); expect(commits.get(key).id).toBe('1111');
expect(commits.get(key).tag).toBe('test tag'); expect(commits.get(key).tags).toStrictEqual(['test tag']);
expect(commits.get(key).type).toBe(0); expect(commits.get(key).type).toBe(0);
}); });
@ -181,7 +181,7 @@ describe('when parsing a gitGraph', function () {
const key = commits.keys().next().value; const key = commits.keys().next().value;
expect(commits.get(key).message).toBe(''); expect(commits.get(key).message).toBe('');
expect(commits.get(key).id).not.toBeNull(); expect(commits.get(key).id).not.toBeNull();
expect(commits.get(key).tag).toBe('test tag'); expect(commits.get(key).tags).toStrictEqual(['test tag']);
expect(commits.get(key).type).toBe(2); expect(commits.get(key).type).toBe(2);
}); });
@ -199,7 +199,7 @@ describe('when parsing a gitGraph', function () {
const key = commits.keys().next().value; const key = commits.keys().next().value;
expect(commits.get(key).message).toBe(''); expect(commits.get(key).message).toBe('');
expect(commits.get(key).id).not.toBeNull(); expect(commits.get(key).id).not.toBeNull();
expect(commits.get(key).tag).toBe('test tag'); expect(commits.get(key).tags).toStrictEqual(['test tag']);
expect(commits.get(key).type).toBe(2); expect(commits.get(key).type).toBe(2);
}); });
@ -217,7 +217,7 @@ describe('when parsing a gitGraph', function () {
const key = commits.keys().next().value; const key = commits.keys().next().value;
expect(commits.get(key).message).toBe(''); expect(commits.get(key).message).toBe('');
expect(commits.get(key).id).toBe('1111'); expect(commits.get(key).id).toBe('1111');
expect(commits.get(key).tag).toBe('test tag'); expect(commits.get(key).tags).toStrictEqual(['test tag']);
expect(commits.get(key).type).toBe(1); expect(commits.get(key).type).toBe(1);
}); });
@ -235,7 +235,7 @@ describe('when parsing a gitGraph', function () {
const key = commits.keys().next().value; const key = commits.keys().next().value;
expect(commits.get(key).message).toBe('test msg'); expect(commits.get(key).message).toBe('test msg');
expect(commits.get(key).id).toBe('1111'); expect(commits.get(key).id).toBe('1111');
expect(commits.get(key).tag).toBe('test tag'); expect(commits.get(key).tags).toStrictEqual(['test tag']);
expect(commits.get(key).type).toBe(1); expect(commits.get(key).type).toBe(1);
}); });
@ -254,7 +254,7 @@ describe('when parsing a gitGraph', function () {
const key = commits.keys().next().value; const key = commits.keys().next().value;
expect(commits.get(key).message).toBe('test msg'); expect(commits.get(key).message).toBe('test msg');
expect(commits.get(key).id).toBe('1111'); expect(commits.get(key).id).toBe('1111');
expect(commits.get(key).tag).toBe('test tag'); expect(commits.get(key).tags).toStrictEqual(['test tag']);
expect(commits.get(key).type).toBe(1); expect(commits.get(key).type).toBe(1);
}); });
@ -272,7 +272,7 @@ describe('when parsing a gitGraph', function () {
const key = commits.keys().next().value; const key = commits.keys().next().value;
expect(commits.get(key).message).toBe('test msg'); expect(commits.get(key).message).toBe('test msg');
expect(commits.get(key).id).toBe('1111'); expect(commits.get(key).id).toBe('1111');
expect(commits.get(key).tag).toBe('test tag'); expect(commits.get(key).tags).toStrictEqual(['test tag']);
expect(commits.get(key).type).toBe(1); expect(commits.get(key).type).toBe(1);
}); });
@ -290,7 +290,7 @@ describe('when parsing a gitGraph', function () {
const key = commits.keys().next().value; const key = commits.keys().next().value;
expect(commits.get(key).message).toBe('test msg'); expect(commits.get(key).message).toBe('test msg');
expect(commits.get(key).id).toBe('1111'); expect(commits.get(key).id).toBe('1111');
expect(commits.get(key).tag).toBe('test tag'); expect(commits.get(key).tags).toStrictEqual(['test tag']);
expect(commits.get(key).type).toBe(1); expect(commits.get(key).type).toBe(1);
}); });
@ -616,7 +616,7 @@ describe('when parsing a gitGraph', function () {
commits.get(commit1).id, commits.get(commit1).id,
commits.get(commit2).id, commits.get(commit2).id,
]); ]);
expect(commits.get(commit3).tag).toBe('merge-tag'); expect(commits.get(commit3).tags).toStrictEqual(['merge-tag']);
expect(parser.yy.getBranchesAsObjArray()).toStrictEqual([ expect(parser.yy.getBranchesAsObjArray()).toStrictEqual([
{ name: 'main' }, { name: 'main' },
{ name: 'testBranch' }, { name: 'testBranch' },
@ -671,12 +671,12 @@ describe('when parsing a gitGraph', function () {
expect(testBranchMerge.branch).toBe('main'); expect(testBranchMerge.branch).toBe('main');
expect(testBranchMerge.parents).toStrictEqual([mainCommit.id, testBranchCommit.id]); expect(testBranchMerge.parents).toStrictEqual([mainCommit.id, testBranchCommit.id]);
expect(testBranchMerge.tag).toBe('merge-tag'); expect(testBranchMerge.tags).toStrictEqual(['merge-tag']);
expect(testBranchMerge.id).toBe('2-222'); expect(testBranchMerge.id).toBe('2-222');
expect(testBranch2Merge.branch).toBe('main'); expect(testBranch2Merge.branch).toBe('main');
expect(testBranch2Merge.parents).toStrictEqual([testBranchMerge.id, testBranch2Commit.id]); expect(testBranch2Merge.parents).toStrictEqual([testBranchMerge.id, testBranch2Commit.id]);
expect(testBranch2Merge.tag).toBe('merge-tag2'); expect(testBranch2Merge.tags).toStrictEqual(['merge-tag2']);
expect(testBranch2Merge.id).toBe('4-444'); expect(testBranch2Merge.id).toBe('4-444');
expect(testBranch2Merge.customType).toBe(2); expect(testBranch2Merge.customType).toBe(2);
expect(testBranch2Merge.customId).toBe(true); expect(testBranch2Merge.customId).toBe(true);
@ -705,7 +705,7 @@ describe('when parsing a gitGraph', function () {
parser.parse(str); parser.parse(str);
const commits = parser.yy.getCommits(); const commits = parser.yy.getCommits();
const cherryPickCommitID = [...commits.keys()][2]; const cherryPickCommitID = [...commits.keys()][2];
expect(commits.get(cherryPickCommitID).tag).toBe('cherry-pick:A'); expect(commits.get(cherryPickCommitID).tags).toStrictEqual(['cherry-pick:A']);
expect(commits.get(cherryPickCommitID).branch).toBe('main'); expect(commits.get(cherryPickCommitID).branch).toBe('main');
}); });
@ -721,7 +721,7 @@ describe('when parsing a gitGraph', function () {
parser.parse(str); parser.parse(str);
const commits = parser.yy.getCommits(); const commits = parser.yy.getCommits();
const cherryPickCommitID = [...commits.keys()][2]; const cherryPickCommitID = [...commits.keys()][2];
expect(commits.get(cherryPickCommitID).tag).toBe('MyTag'); expect(commits.get(cherryPickCommitID).tags).toStrictEqual(['MyTag']);
expect(commits.get(cherryPickCommitID).branch).toBe('main'); expect(commits.get(cherryPickCommitID).branch).toBe('main');
}); });
@ -737,7 +737,7 @@ describe('when parsing a gitGraph', function () {
parser.parse(str); parser.parse(str);
const commits = parser.yy.getCommits(); const commits = parser.yy.getCommits();
const cherryPickCommitID = [...commits.keys()][2]; const cherryPickCommitID = [...commits.keys()][2];
expect(commits.get(cherryPickCommitID).tag).toBe(''); expect(commits.get(cherryPickCommitID).tags).toStrictEqual([]);
expect(commits.get(cherryPickCommitID).branch).toBe('main'); expect(commits.get(cherryPickCommitID).branch).toBe('main');
}); });
@ -758,7 +758,7 @@ describe('when parsing a gitGraph', function () {
parser.parse(str); parser.parse(str);
const commits = parser.yy.getCommits(); const commits = parser.yy.getCommits();
const cherryPickCommitID = [...commits.keys()][4]; const cherryPickCommitID = [...commits.keys()][4];
expect(commits.get(cherryPickCommitID).tag).toBe('cherry-pick:M|parent:B'); expect(commits.get(cherryPickCommitID).tags).toStrictEqual(['cherry-pick:M|parent:B']);
expect(commits.get(cherryPickCommitID).branch).toBe('release'); expect(commits.get(cherryPickCommitID).branch).toBe('release');
}); });
@ -779,7 +779,7 @@ describe('when parsing a gitGraph', function () {
parser.parse(str); parser.parse(str);
const commits = parser.yy.getCommits(); const commits = parser.yy.getCommits();
const cherryPickCommitID = [...commits.keys()][4]; const cherryPickCommitID = [...commits.keys()][4];
expect(commits.get(cherryPickCommitID).tag).toBe('v1.0'); expect(commits.get(cherryPickCommitID).tags).toStrictEqual(['v1.0']);
expect(commits.get(cherryPickCommitID).branch).toBe('release'); expect(commits.get(cherryPickCommitID).branch).toBe('release');
}); });
@ -802,7 +802,7 @@ describe('when parsing a gitGraph', function () {
parser.parse(str); parser.parse(str);
const commits = parser.yy.getCommits(); const commits = parser.yy.getCommits();
const cherryPickCommitID = [...commits.keys()][5]; const cherryPickCommitID = [...commits.keys()][5];
expect(commits.get(cherryPickCommitID).tag).toBe('v2.1:ZERO'); expect(commits.get(cherryPickCommitID).tags).toStrictEqual(['v2.1:ZERO']);
expect(commits.get(cherryPickCommitID).branch).toBe('release'); expect(commits.get(cherryPickCommitID).branch).toBe('release');
}); });
@ -827,8 +827,8 @@ describe('when parsing a gitGraph', function () {
const commits = parser.yy.getCommits(); const commits = parser.yy.getCommits();
const cherryPickCommitID = [...commits.keys()][5]; const cherryPickCommitID = [...commits.keys()][5];
const cherryPickCommitID2 = [...commits.keys()][7]; const cherryPickCommitID2 = [...commits.keys()][7];
expect(commits.get(cherryPickCommitID).tag).toBe(''); expect(commits.get(cherryPickCommitID).tags).toStrictEqual([]);
expect(commits.get(cherryPickCommitID2).tag).toBe(''); expect(commits.get(cherryPickCommitID2).tags).toStrictEqual([]);
expect(commits.get(cherryPickCommitID).branch).toBe('release'); expect(commits.get(cherryPickCommitID).branch).toBe('release');
}); });

View File

@ -414,59 +414,83 @@ const drawCommits = (svg, commits, modifyGraph) => {
} }
} }
} }
if (commit.tag) { if (commit.tags.length > 0) {
const rect = gLabels.insert('polygon'); let yOffset = 0;
const hole = gLabels.append('circle'); let maxTagBboxWidth = 0;
const tag = gLabels let maxTagBboxHeight = 0;
.append('text') const tagElements = [];
// Note that we are delaying setting the x position until we know the width of the text
.attr('y', y - 16)
.attr('class', 'tag-label')
.text(commit.tag);
let tagBbox = tag.node().getBBox();
tag.attr('x', posWithOffset - tagBbox.width / 2);
const h2 = tagBbox.height / 2; for (const tagValue of commit.tags.reverse()) {
const ly = y - 19.2; const rect = gLabels.insert('polygon');
rect.attr('class', 'tag-label-bkg').attr( const hole = gLabels.append('circle');
'points', const tag = gLabels
` .append('text')
${pos - tagBbox.width / 2 - px / 2},${ly + py} // Note that we are delaying setting the x position until we know the width of the text
${pos - tagBbox.width / 2 - px / 2},${ly - py} .attr('y', y - 16 - yOffset)
${posWithOffset - tagBbox.width / 2 - px},${ly - h2 - py} .attr('class', 'tag-label')
${posWithOffset + tagBbox.width / 2 + px},${ly - h2 - py} .text(tagValue);
${posWithOffset + tagBbox.width / 2 + px},${ly + h2 + py} let tagBbox = tag.node().getBBox();
${posWithOffset - tagBbox.width / 2 - px},${ly + h2 + py}` maxTagBboxWidth = Math.max(maxTagBboxWidth, tagBbox.width);
); maxTagBboxHeight = Math.max(maxTagBboxHeight, tagBbox.height);
hole // We don't use the max over here to center the text within the tags
.attr('cx', pos - tagBbox.width / 2 + px / 2) tag.attr('x', posWithOffset - tagBbox.width / 2);
.attr('cy', ly)
.attr('r', 1.5) tagElements.push({
.attr('class', 'tag-hole'); tag,
hole,
rect,
yOffset,
});
yOffset += 20;
}
for (const { tag, hole, rect, yOffset } of tagElements) {
const h2 = maxTagBboxHeight / 2;
const ly = y - 19.2 - yOffset;
rect.attr('class', 'tag-label-bkg').attr(
'points',
`
${pos - maxTagBboxWidth / 2 - px / 2},${ly + py}
${pos - maxTagBboxWidth / 2 - px / 2},${ly - py}
${posWithOffset - maxTagBboxWidth / 2 - px},${ly - h2 - py}
${posWithOffset + maxTagBboxWidth / 2 + px},${ly - h2 - py}
${posWithOffset + maxTagBboxWidth / 2 + px},${ly + h2 + py}
${posWithOffset - maxTagBboxWidth / 2 - px},${ly + h2 + py}`
);
if (dir === 'TB' || dir === 'BT') {
rect
.attr('class', 'tag-label-bkg')
.attr(
'points',
`
${x},${pos + py}
${x},${pos - py}
${x + layoutOffset},${pos - h2 - py}
${x + layoutOffset + tagBbox.width + px},${pos - h2 - py}
${x + layoutOffset + tagBbox.width + px},${pos + h2 + py}
${x + layoutOffset},${pos + h2 + py}`
)
.attr('transform', 'translate(12,12) rotate(45, ' + x + ',' + pos + ')');
hole hole
.attr('cx', x + px / 2) .attr('cy', ly)
.attr('cy', pos) .attr('cx', pos - maxTagBboxWidth / 2 + px / 2)
.attr('transform', 'translate(12,12) rotate(45, ' + x + ',' + pos + ')'); .attr('r', 1.5)
tag .attr('class', 'tag-hole');
.attr('x', x + 5)
.attr('y', pos + 3) if (dir === 'TB' || dir === 'BT') {
.attr('transform', 'translate(14,14) rotate(45, ' + x + ',' + pos + ')'); const yOrigin = pos + yOffset;
rect
.attr('class', 'tag-label-bkg')
.attr(
'points',
`
${x},${yOrigin + py}
${x},${yOrigin - py}
${x + layoutOffset},${yOrigin - h2 - py}
${x + layoutOffset + maxTagBboxWidth + px},${yOrigin - h2 - py}
${x + layoutOffset + maxTagBboxWidth + px},${yOrigin + h2 + py}
${x + layoutOffset},${yOrigin + h2 + py}`
)
.attr('transform', 'translate(12,12) rotate(45, ' + x + ',' + pos + ')');
hole
.attr('cx', x + px / 2)
.attr('cy', yOrigin)
.attr('transform', 'translate(12,12) rotate(45, ' + x + ',' + pos + ')');
tag
.attr('x', x + 5)
.attr('y', yOrigin + 3)
.attr('transform', 'translate(14,14) rotate(45, ' + x + ',' + pos + ')');
}
} }
} }
} }

View File

@ -112,122 +112,105 @@ branchStatement
cherryPickStatement cherryPickStatement
: CHERRY_PICK COMMIT_ID STR {yy.cherryPick($3, '', undefined)} : CHERRY_PICK COMMIT_ID STR {yy.cherryPick($3, '', undefined)}
| CHERRY_PICK COMMIT_ID STR PARENT_COMMIT STR {yy.cherryPick($3, '', undefined,$5)} | CHERRY_PICK COMMIT_ID STR PARENT_COMMIT STR {yy.cherryPick($3, '', undefined,$5)}
| CHERRY_PICK COMMIT_ID STR COMMIT_TAG STR {yy.cherryPick($3, '', $5)} | CHERRY_PICK COMMIT_ID STR commitTags {yy.cherryPick($3, '', $4)}
| CHERRY_PICK COMMIT_ID STR PARENT_COMMIT STR COMMIT_TAG STR {yy.cherryPick($3, '', $7,$5)} | CHERRY_PICK COMMIT_ID STR PARENT_COMMIT STR commitTags {yy.cherryPick($3, '', $6,$5)}
| CHERRY_PICK COMMIT_ID STR COMMIT_TAG STR PARENT_COMMIT STR {yy.cherryPick($3, '', $5,$7)} | CHERRY_PICK COMMIT_ID STR commitTags PARENT_COMMIT STR {yy.cherryPick($3, '', $4,$6)}
| CHERRY_PICK COMMIT_TAG STR COMMIT_ID STR {yy.cherryPick($5, '', $3)} | CHERRY_PICK commitTags COMMIT_ID STR {yy.cherryPick($4, '', $2)}
| CHERRY_PICK COMMIT_TAG EMPTYSTR COMMIT_ID STR {yy.cherryPick($5, '', '')} | CHERRY_PICK commitTags COMMIT_ID STR PARENT_COMMIT STR {yy.cherryPick($4, '', $2,$6)}
| CHERRY_PICK COMMIT_ID STR COMMIT_TAG EMPTYSTR {yy.cherryPick($3, '', '')}
| CHERRY_PICK COMMIT_ID STR PARENT_COMMIT STR COMMIT_TAG EMPTYSTR {yy.cherryPick($3, '', '',$5)}
| CHERRY_PICK COMMIT_ID STR COMMIT_TAG EMPTYSTR PARENT_COMMIT STR {yy.cherryPick($3, '', '',$7)}
| CHERRY_PICK COMMIT_TAG STR COMMIT_ID STR PARENT_COMMIT STR {yy.cherryPick($5, '', $3,$7)}
| CHERRY_PICK COMMIT_TAG EMPTYSTR COMMIT_ID STR PARENT_COMMIT STR{yy.cherryPick($5, '', '',$7)}
; ;
mergeStatement mergeStatement
: MERGE ref {yy.merge($2,'','','')} : MERGE ref {yy.merge($2,'','', undefined)}
| MERGE ref COMMIT_ID STR {yy.merge($2, $4,'','')} | MERGE ref COMMIT_ID STR {yy.merge($2, $4,'', undefined)}
| MERGE ref COMMIT_TYPE commitType {yy.merge($2,'', $4,'')} | MERGE ref COMMIT_TYPE commitType {yy.merge($2,'', $4, undefined)}
| MERGE ref COMMIT_TAG STR {yy.merge($2, '','',$4)} | MERGE ref commitTags {yy.merge($2, '','',$3)}
| MERGE ref COMMIT_TAG STR COMMIT_ID STR {yy.merge($2, $6,'', $4)} | MERGE ref commitTags COMMIT_ID STR {yy.merge($2, $5,'', $3)}
| MERGE ref COMMIT_TAG STR COMMIT_TYPE commitType {yy.merge($2, '',$6, $4)} | MERGE ref commitTags COMMIT_TYPE commitType {yy.merge($2, '',$5, $3)}
| MERGE ref COMMIT_TYPE commitType COMMIT_TAG STR {yy.merge($2, '',$4, $6)} | MERGE ref COMMIT_TYPE commitType commitTags {yy.merge($2, '',$4, $5)}
| MERGE ref COMMIT_ID STR COMMIT_TYPE commitType {yy.merge($2, $4, $6, '')} | MERGE ref COMMIT_ID STR COMMIT_TYPE commitType {yy.merge($2, $4, $6, undefined)}
| MERGE ref COMMIT_ID STR COMMIT_TAG STR {yy.merge($2, $4, '', $6)} | MERGE ref COMMIT_ID STR commitTags {yy.merge($2, $4, '', $5)}
| MERGE ref COMMIT_TYPE commitType COMMIT_ID STR {yy.merge($2, $6,$4, '')} | MERGE ref COMMIT_TYPE commitType COMMIT_ID STR {yy.merge($2, $6,$4, undefined)}
| MERGE ref COMMIT_ID STR COMMIT_TYPE commitType COMMIT_TAG STR {yy.merge($2, $4, $6, $8)} | MERGE ref COMMIT_ID STR COMMIT_TYPE commitType commitTags {yy.merge($2, $4, $6, $7)}
| MERGE ref COMMIT_TYPE commitType COMMIT_TAG STR COMMIT_ID STR {yy.merge($2, $8, $4, $6)} | MERGE ref COMMIT_TYPE commitType commitTags COMMIT_ID STR {yy.merge($2, $7, $4, $5)}
| MERGE ref COMMIT_ID STR COMMIT_TAG STR COMMIT_TYPE commitType {yy.merge($2, $4, $8, $6)} | MERGE ref COMMIT_ID STR commitTags COMMIT_TYPE commitType {yy.merge($2, $4, $7, $5)}
| MERGE ref COMMIT_TYPE commitType COMMIT_ID STR COMMIT_TAG STR {yy.merge($2, $6, $4, $8)} | MERGE ref COMMIT_TYPE commitType COMMIT_ID STR commitTags {yy.merge($2, $6, $4, $7)}
| MERGE ref COMMIT_TAG STR COMMIT_TYPE commitType COMMIT_ID STR {yy.merge($2, $8, $6, $4)} | MERGE ref commitTags COMMIT_TYPE commitType COMMIT_ID STR {yy.merge($2, $7, $5, $3)}
| MERGE ref COMMIT_TAG STR COMMIT_ID STR COMMIT_TYPE commitType {yy.merge($2, $6, $8, $4)} | MERGE ref commitTags COMMIT_ID STR COMMIT_TYPE commitType {yy.merge($2, $5, $7, $3)}
; ;
commitStatement commitStatement
: COMMIT commit_arg {yy.commit($2)} : COMMIT commit_arg {yy.commit($2)}
| COMMIT COMMIT_TAG STR {yy.commit('','',yy.commitType.NORMAL,$3)} | COMMIT commitTags {yy.commit('','',yy.commitType.NORMAL,$2)}
| COMMIT COMMIT_TYPE commitType {yy.commit('','',$3,'')} | COMMIT COMMIT_TYPE commitType {yy.commit('','',$3, undefined)}
| COMMIT COMMIT_TAG STR COMMIT_TYPE commitType {yy.commit('','',$5,$3)} | COMMIT commitTags COMMIT_TYPE commitType {yy.commit('','',$4,$2)}
| COMMIT COMMIT_TYPE commitType COMMIT_TAG STR {yy.commit('','',$3,$5)} | COMMIT COMMIT_TYPE commitType commitTags {yy.commit('','',$3,$4)}
| COMMIT COMMIT_ID STR {yy.commit('',$3,yy.commitType.NORMAL,'')} | COMMIT COMMIT_ID STR {yy.commit('',$3,yy.commitType.NORMAL, undefined)}
| COMMIT COMMIT_ID STR COMMIT_TAG STR {yy.commit('',$3,yy.commitType.NORMAL,$5)} | COMMIT COMMIT_ID STR commitTags {yy.commit('',$3,yy.commitType.NORMAL,$4)}
| COMMIT COMMIT_TAG STR COMMIT_ID STR {yy.commit('',$5,yy.commitType.NORMAL,$3)} | COMMIT commitTags COMMIT_ID STR {yy.commit('',$4,yy.commitType.NORMAL,$2)}
| COMMIT COMMIT_ID STR COMMIT_TYPE commitType {yy.commit('',$3,$5,'')} | COMMIT COMMIT_ID STR COMMIT_TYPE commitType {yy.commit('',$3,$5, undefined)}
| COMMIT COMMIT_TYPE commitType COMMIT_ID STR {yy.commit('',$5,$3,'')} | COMMIT COMMIT_TYPE commitType COMMIT_ID STR {yy.commit('',$5,$3, undefined)}
| COMMIT COMMIT_ID STR COMMIT_TYPE commitType COMMIT_TAG STR {yy.commit('',$3,$5,$7)} | COMMIT COMMIT_ID STR COMMIT_TYPE commitType commitTags {yy.commit('',$3,$5,$6)}
| COMMIT COMMIT_ID STR COMMIT_TAG STR COMMIT_TYPE commitType {yy.commit('',$3,$7,$5)} | COMMIT COMMIT_ID STR commitTags COMMIT_TYPE commitType {yy.commit('',$3,$6,$4)}
| COMMIT COMMIT_TYPE commitType COMMIT_ID STR COMMIT_TAG STR {yy.commit('',$5,$3,$7)} | COMMIT COMMIT_TYPE commitType COMMIT_ID STR commitTags {yy.commit('',$5,$3,$6)}
| COMMIT COMMIT_TYPE commitType COMMIT_TAG STR COMMIT_ID STR {yy.commit('',$7,$3,$5)} | COMMIT COMMIT_TYPE commitType commitTags COMMIT_ID STR {yy.commit('',$6,$3,$4)}
| COMMIT COMMIT_TAG STR COMMIT_TYPE commitType COMMIT_ID STR {yy.commit('',$7,$5,$3)} | COMMIT commitTags COMMIT_TYPE commitType COMMIT_ID STR {yy.commit('',$6,$4,$2)}
| COMMIT COMMIT_TAG STR COMMIT_ID STR COMMIT_TYPE commitType {yy.commit('',$5,$7,$3)} | COMMIT commitTags COMMIT_ID STR COMMIT_TYPE commitType {yy.commit('',$4,$6,$2)}
| COMMIT COMMIT_MSG STR {yy.commit($3,'',yy.commitType.NORMAL,'')} | COMMIT COMMIT_MSG STR {yy.commit($3,'',yy.commitType.NORMAL, undefined)}
| COMMIT COMMIT_TAG STR COMMIT_MSG STR {yy.commit($5,'',yy.commitType.NORMAL,$3)} | COMMIT commitTags COMMIT_MSG STR {yy.commit($4,'',yy.commitType.NORMAL,$2)}
| COMMIT COMMIT_MSG STR COMMIT_TAG STR {yy.commit($3,'',yy.commitType.NORMAL,$5)} | COMMIT COMMIT_MSG STR commitTags {yy.commit($3,'',yy.commitType.NORMAL,$4)}
| COMMIT COMMIT_MSG STR COMMIT_TYPE commitType {yy.commit($3,'',$5,'')} | COMMIT COMMIT_MSG STR COMMIT_TYPE commitType {yy.commit($3,'',$5, undefined)}
| COMMIT COMMIT_TYPE commitType COMMIT_MSG STR {yy.commit($5,'',$3,'')} | COMMIT COMMIT_TYPE commitType COMMIT_MSG STR {yy.commit($5,'',$3, undefined)}
| COMMIT COMMIT_ID STR COMMIT_MSG STR {yy.commit($5,$3,yy.commitType.NORMAL,'')} | COMMIT COMMIT_ID STR COMMIT_MSG STR {yy.commit($5,$3,yy.commitType.NORMAL, undefined)}
| COMMIT COMMIT_MSG STR COMMIT_ID STR {yy.commit($3,$5,yy.commitType.NORMAL,'')} | COMMIT COMMIT_MSG STR COMMIT_ID STR {yy.commit($3,$5,yy.commitType.NORMAL, undefined)}
| COMMIT COMMIT_MSG STR COMMIT_TYPE commitType COMMIT_TAG STR {yy.commit($3,'',$5,$7)} | COMMIT COMMIT_MSG STR COMMIT_TYPE commitType commitTags {yy.commit($3,'',$5,$6)}
| COMMIT COMMIT_MSG STR COMMIT_TAG STR COMMIT_TYPE commitType {yy.commit($3,'',$7,$5)} | COMMIT COMMIT_MSG STR commitTags COMMIT_TYPE commitType {yy.commit($3,'',$6,$4)}
| COMMIT COMMIT_TYPE commitType COMMIT_MSG STR COMMIT_TAG STR {yy.commit($5,'',$3,$7)} | COMMIT COMMIT_TYPE commitType COMMIT_MSG STR commitTags {yy.commit($5,'',$3,$6)}
| COMMIT COMMIT_TYPE commitType COMMIT_TAG STR COMMIT_MSG STR {yy.commit($7,'',$3,$5)} | COMMIT COMMIT_TYPE commitType commitTags COMMIT_MSG STR {yy.commit($6,'',$3,$4)}
| COMMIT COMMIT_TAG STR COMMIT_TYPE commitType COMMIT_MSG STR {yy.commit($7,'',$5,$3)} | COMMIT commitTags COMMIT_TYPE commitType COMMIT_MSG STR {yy.commit($6,'',$4,$2)}
| COMMIT COMMIT_TAG STR COMMIT_MSG STR COMMIT_TYPE commitType {yy.commit($5,'',$7,$3)} | COMMIT commitTags COMMIT_MSG STR COMMIT_TYPE commitType {yy.commit($4,'',$6,$2)}
| COMMIT COMMIT_MSG STR COMMIT_TYPE commitType COMMIT_ID STR {yy.commit($3,$7,$5,'')} | COMMIT COMMIT_MSG STR COMMIT_TYPE commitType COMMIT_ID STR {yy.commit($3,$7,$5, undefined)}
| COMMIT COMMIT_MSG STR COMMIT_ID STR COMMIT_TYPE commitType {yy.commit($3,$5,$7,'')} | COMMIT COMMIT_MSG STR COMMIT_ID STR COMMIT_TYPE commitType {yy.commit($3,$5,$7, undefined)}
| COMMIT COMMIT_TYPE commitType COMMIT_MSG STR COMMIT_ID STR {yy.commit($5,$7,$3,'')} | COMMIT COMMIT_TYPE commitType COMMIT_MSG STR COMMIT_ID STR {yy.commit($5,$7,$3, undefined)}
| COMMIT COMMIT_TYPE commitType COMMIT_ID STR COMMIT_MSG STR {yy.commit($7,$5,$3,'')} | COMMIT COMMIT_TYPE commitType COMMIT_ID STR COMMIT_MSG STR {yy.commit($7,$5,$3, undefined)}
| COMMIT COMMIT_ID STR COMMIT_TYPE commitType COMMIT_MSG STR {yy.commit($7,$3,$5,'')} | COMMIT COMMIT_ID STR COMMIT_TYPE commitType COMMIT_MSG STR {yy.commit($7,$3,$5, undefined)}
| COMMIT COMMIT_ID STR COMMIT_MSG STR COMMIT_TYPE commitType {yy.commit($5,$3,$7,'')} | COMMIT COMMIT_ID STR COMMIT_MSG STR COMMIT_TYPE commitType {yy.commit($5,$3,$7, undefined)}
| COMMIT COMMIT_MSG STR COMMIT_TAG STR COMMIT_ID STR {yy.commit($3,$7,yy.commitType.NORMAL,$5)} | COMMIT COMMIT_MSG STR commitTags COMMIT_ID STR {yy.commit($3,$6,yy.commitType.NORMAL,$4)}
| COMMIT COMMIT_MSG STR COMMIT_ID STR COMMIT_TAG STR {yy.commit($3,$5,yy.commitType.NORMAL,$7)} | COMMIT COMMIT_MSG STR COMMIT_ID STR commitTags {yy.commit($3,$5,yy.commitType.NORMAL,$6)}
| COMMIT COMMIT_TAG STR COMMIT_MSG STR COMMIT_ID STR {yy.commit($5,$7,yy.commitType.NORMAL,$3)} | COMMIT commitTags COMMIT_MSG STR COMMIT_ID STR {yy.commit($4,$6,yy.commitType.NORMAL,$2)}
| COMMIT COMMIT_TAG STR COMMIT_ID STR COMMIT_MSG STR {yy.commit($7,$5,yy.commitType.NORMAL,$3)} | COMMIT commitTags COMMIT_ID STR COMMIT_MSG STR {yy.commit($6,$4,yy.commitType.NORMAL,$2)}
| COMMIT COMMIT_ID STR COMMIT_TAG STR COMMIT_MSG STR {yy.commit($7,$3,yy.commitType.NORMAL,$5)} | COMMIT COMMIT_ID STR commitTags COMMIT_MSG STR {yy.commit($6,$3,yy.commitType.NORMAL,$4)}
| COMMIT COMMIT_ID STR COMMIT_MSG STR COMMIT_TAG STR {yy.commit($5,$3,yy.commitType.NORMAL,$7)} | COMMIT COMMIT_ID STR COMMIT_MSG STR commitTags {yy.commit($5,$3,yy.commitType.NORMAL,$6)}
| COMMIT COMMIT_MSG STR COMMIT_ID STR COMMIT_TYPE commitType COMMIT_TAG STR {yy.commit($3,$5,$7,$9)} | COMMIT COMMIT_MSG STR COMMIT_ID STR COMMIT_TYPE commitType commitTags {yy.commit($3,$5,$7,$8)}
| COMMIT COMMIT_MSG STR COMMIT_ID STR COMMIT_TAG STR COMMIT_TYPE commitType {yy.commit($3,$5,$9,$7)} | COMMIT COMMIT_MSG STR COMMIT_ID STR commitTags COMMIT_TYPE commitType {yy.commit($3,$5,$8,$6)}
| COMMIT COMMIT_MSG STR COMMIT_TYPE commitType COMMIT_ID STR COMMIT_TAG STR {yy.commit($3,$7,$5,$9)} | COMMIT COMMIT_MSG STR COMMIT_TYPE commitType COMMIT_ID STR commitTags {yy.commit($3,$7,$5,$8)}
| COMMIT COMMIT_MSG STR COMMIT_TYPE commitType COMMIT_TAG STR COMMIT_ID STR {yy.commit($3,$9,$5,$7)} | COMMIT COMMIT_MSG STR COMMIT_TYPE commitType commitTags COMMIT_ID STR {yy.commit($3,$8,$5,$6)}
| COMMIT COMMIT_MSG STR COMMIT_TAG STR COMMIT_ID STR COMMIT_TYPE commitType {yy.commit($3,$7,$9,$5)} | COMMIT COMMIT_MSG STR commitTags COMMIT_ID STR COMMIT_TYPE commitType {yy.commit($3,$6,$8,$4)}
| COMMIT COMMIT_MSG STR COMMIT_TAG STR COMMIT_TYPE commitType COMMIT_ID STR {yy.commit($3,$9,$7,$5)} | COMMIT COMMIT_MSG STR commitTags COMMIT_TYPE commitType COMMIT_ID STR {yy.commit($3,$8,$6,$4)}
| COMMIT COMMIT_ID STR COMMIT_MSG STR COMMIT_TYPE commitType COMMIT_TAG STR {yy.commit($5,$3,$7,$9)} | COMMIT COMMIT_ID STR COMMIT_MSG STR COMMIT_TYPE commitType commitTags {yy.commit($5,$3,$7,$8)}
| COMMIT COMMIT_ID STR COMMIT_MSG STR COMMIT_TAG STR COMMIT_TYPE commitType {yy.commit($5,$3,$9,$7)} | COMMIT COMMIT_ID STR COMMIT_MSG STR commitTags COMMIT_TYPE commitType {yy.commit($5,$3,$8,$6)}
| COMMIT COMMIT_ID STR COMMIT_TYPE commitType COMMIT_MSG STR COMMIT_TAG STR {yy.commit($7,$3,$5,$9)} | COMMIT COMMIT_ID STR COMMIT_TYPE commitType COMMIT_MSG STR commitTags {yy.commit($7,$3,$5,$8)}
| COMMIT COMMIT_ID STR COMMIT_TYPE commitType COMMIT_TAG STR COMMIT_MSG STR {yy.commit($9,$3,$5,$7)} | COMMIT COMMIT_ID STR COMMIT_TYPE commitType commitTags COMMIT_MSG STR {yy.commit($8,$3,$5,$6)}
| COMMIT COMMIT_ID STR COMMIT_TAG STR COMMIT_MSG STR COMMIT_TYPE commitType {yy.commit($7,$3,$9,$5)} | COMMIT COMMIT_ID STR commitTags COMMIT_MSG STR COMMIT_TYPE commitType {yy.commit($6,$3,$8,$4)}
| COMMIT COMMIT_ID STR COMMIT_TAG STR COMMIT_TYPE commitType COMMIT_MSG STR {yy.commit($9,$3,$7,$5)} | COMMIT COMMIT_ID STR commitTags COMMIT_TYPE commitType COMMIT_MSG STR {yy.commit($8,$3,$6,$4)}
| COMMIT COMMIT_TAG STR COMMIT_ID STR COMMIT_TYPE commitType COMMIT_MSG STR {yy.commit($9,$5,$7,$3)} | COMMIT commitTags COMMIT_ID STR COMMIT_TYPE commitType COMMIT_MSG STR {yy.commit($8,$4,$6,$2)}
| COMMIT COMMIT_TAG STR COMMIT_ID STR COMMIT_MSG STR COMMIT_TYPE commitType {yy.commit($7,$5,$9,$3)} | COMMIT commitTags COMMIT_ID STR COMMIT_MSG STR COMMIT_TYPE commitType {yy.commit($6,$4,$8,$2)}
| COMMIT COMMIT_TAG STR COMMIT_TYPE commitType COMMIT_ID STR COMMIT_MSG STR {yy.commit($9,$7,$5,$3)} | COMMIT commitTags COMMIT_TYPE commitType COMMIT_ID STR COMMIT_MSG STR {yy.commit($8,$6,$4,$2)}
| COMMIT COMMIT_TAG STR COMMIT_TYPE commitType COMMIT_MSG STR COMMIT_ID STR {yy.commit($7,$9,$5,$3)} | COMMIT commitTags COMMIT_TYPE commitType COMMIT_MSG STR COMMIT_ID STR {yy.commit($6,$8,$4,$2)}
| COMMIT COMMIT_TAG STR COMMIT_MSG STR COMMIT_ID STR COMMIT_TYPE commitType {yy.commit($5,$7,$9,$3)} | COMMIT commitTags COMMIT_MSG STR COMMIT_ID STR COMMIT_TYPE commitType {yy.commit($4,$6,$8,$2)}
| COMMIT COMMIT_TAG STR COMMIT_MSG STR COMMIT_TYPE commitType COMMIT_ID STR {yy.commit($5,$9,$7,$3)} | COMMIT commitTags COMMIT_MSG STR COMMIT_TYPE commitType COMMIT_ID STR {yy.commit($4,$8,$6,$2)}
| COMMIT COMMIT_TYPE commitType COMMIT_ID STR COMMIT_MSG STR COMMIT_TAG STR {yy.commit($7,$5,$3,$9)} | COMMIT COMMIT_TYPE commitType COMMIT_ID STR COMMIT_MSG STR commitTags {yy.commit($7,$5,$3,$8)}
| COMMIT COMMIT_TYPE commitType COMMIT_ID STR COMMIT_TAG STR COMMIT_MSG STR {yy.commit($9,$5,$3,$7)} | COMMIT COMMIT_TYPE commitType COMMIT_ID STR commitTags COMMIT_MSG STR {yy.commit($8,$5,$3,$6)}
| COMMIT COMMIT_TYPE commitType COMMIT_TAG STR COMMIT_MSG STR COMMIT_ID STR {yy.commit($7,$9,$3,$5)} | COMMIT COMMIT_TYPE commitType commitTags COMMIT_MSG STR COMMIT_ID STR {yy.commit($6,$8,$3,$4)}
| COMMIT COMMIT_TYPE commitType COMMIT_TAG STR COMMIT_ID STR COMMIT_MSG STR {yy.commit($9,$7,$3,$5)} | COMMIT COMMIT_TYPE commitType commitTags COMMIT_ID STR COMMIT_MSG STR {yy.commit($8,$6,$3,$4)}
| COMMIT COMMIT_TYPE commitType COMMIT_MSG STR COMMIT_ID STR COMMIT_TAG STR {yy.commit($5,$7,$3,$9)} | COMMIT COMMIT_TYPE commitType COMMIT_MSG STR COMMIT_ID STR commitTags {yy.commit($5,$7,$3,$8)}
| COMMIT COMMIT_TYPE commitType COMMIT_MSG STR COMMIT_TAG STR COMMIT_ID STR {yy.commit($5,$9,$3,$7)} | COMMIT COMMIT_TYPE commitType COMMIT_MSG STR commitTags COMMIT_ID STR {yy.commit($5,$8,$3,$6)}
// | COMMIT COMMIT_ID STR {yy.commit('',$3,yy.commitType.NORMAL,'')}
// | COMMIT COMMIT_TYPE commitType {yy.commit('','',$3,'')}
// | COMMIT COMMIT_TAG STR {yy.commit('','',yy.commitType.NORMAL,$3)}
// | COMMIT COMMIT_MSG STR {yy.commit($3,'',yy.commitType.NORMAL,'')}
// | COMMIT COMMIT_TAG STR COMMIT_TYPE commitType {yy.commit('','',$5,$3)}
// | COMMIT COMMIT_TYPE commitType COMMIT_TAG STR {yy.commit('','',$3,$5)}
// | COMMIT COMMIT_ID STR COMMIT_TYPE commitType {yy.commit('',$3,$5,'')}
// | COMMIT COMMIT_ID STR COMMIT_TAG STR {yy.commit('',$3,yy.commitType.NORMAL,$5)}
// | COMMIT COMMIT_ID STR COMMIT_TYPE commitType COMMIT_TAG STR {yy.commit('',$3,$5,$7)}
// | COMMIT COMMIT_ID STR COMMIT_TAG STR COMMIT_TYPE commitType {yy.commit('',$3,$7,$5)}
; ;
commit_arg commit_arg
: /* empty */ {$$ = ""} : /* empty */ {$$ = ""}
@ -238,6 +221,12 @@ commitType
| REVERSE { $$=yy.commitType.REVERSE;} | REVERSE { $$=yy.commitType.REVERSE;}
| HIGHLIGHT { $$=yy.commitType.HIGHLIGHT;} | HIGHLIGHT { $$=yy.commitType.HIGHLIGHT;}
; ;
commitTags
: COMMIT_TAG STR {$$=[$2]}
| COMMIT_TAG EMPTYSTR {$$=['']}
| commitTags COMMIT_TAG STR {$commitTags.push($3); $$=$commitTags;}
| commitTags COMMIT_TAG EMPTYSTR {$commitTags.push(''); $$=$commitTags;}
;
ref ref
: ID : ID

View File

@ -203,6 +203,7 @@ Communication tools and platforms
- [gatsby-remark-mermaid](https://github.com/remcohaszing/gatsby-remark-mermaid) - [gatsby-remark-mermaid](https://github.com/remcohaszing/gatsby-remark-mermaid)
- [JSDoc](https://jsdoc.app/) - [JSDoc](https://jsdoc.app/)
- [jsdoc-mermaid](https://github.com/Jellyvision/jsdoc-mermaid) - [jsdoc-mermaid](https://github.com/Jellyvision/jsdoc-mermaid)
- [Madness](https://madness.dannyb.co/)
- [mdBook](https://rust-lang.github.io/mdBook/index.html) - [mdBook](https://rust-lang.github.io/mdBook/index.html)
- [mdbook-mermaid](https://github.com/badboy/mdbook-mermaid) - [mdbook-mermaid](https://github.com/badboy/mdbook-mermaid)
- [MkDocs](https://www.mkdocs.org) - [MkDocs](https://www.mkdocs.org)

View File

@ -100,7 +100,7 @@ Cardinality is a property that describes how many elements of another entity can
| 1+ | 1+ | One or more | | 1+ | 1+ | One or more |
| zero or more | zero or more | Zero or more | | zero or more | zero or more | Zero or more |
| zero or many | zero or many | Zero or more | | zero or many | zero or many | Zero or more |
| many(0) | many(1) | Zero or more | | many(0) | many(0) | Zero or more |
| 0+ | 0+ | Zero or more | | 0+ | 0+ | Zero or more |
| only one | only one | Exactly one | | only one | only one | Exactly one |
| 1 | 1 | Exactly one | | 1 | 1 | Exactly one |

View File

@ -6,7 +6,7 @@ A packet diagram is a visual representation used to illustrate the structure and
## Usage ## Usage
This diagram type is particularly useful for network engineers, educators, and students who require a clear and concise way to represent the structure of network packets. This diagram type is particularly useful for developers, network engineers, educators, and students who require a clear and concise way to represent the structure of network packets.
## Syntax ## Syntax

View File

@ -567,7 +567,7 @@ export const wrapLabel: (label: string, maxWidth: number, config: WrapLabelConfi
if (common.lineBreakRegex.test(label)) { if (common.lineBreakRegex.test(label)) {
return label; return label;
} }
const words = label.split(' '); const words = label.split(' ').filter(Boolean);
const completedLines: string[] = []; const completedLines: string[] = [];
let nextLine = ''; let nextLine = '';
words.forEach((word, index) => { words.forEach((word, index) => {

1710
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@ -19,10 +19,12 @@ pnpm build:esbuild
pnpm build:types pnpm build:types
# Clone the Mermaid Live Editor repository # Clone the Mermaid Live Editor repository
rm -rf mermaid-live-editor if [ ! -d "mermaid-live-editor" ]; then
git clone --single-branch https://github.com/mermaid-js/mermaid-live-editor.git git clone --single-branch https://github.com/mermaid-js/mermaid-live-editor.git
fi
cd mermaid-live-editor cd mermaid-live-editor
git clean -xdf
rm -rf docs/
# We have to use npm instead of yarn because it causes trouble in netlify # We have to use npm instead of yarn because it causes trouble in netlify
# Install dependencies # Install dependencies