Skip to content

Commit

Permalink
fix: Remove duplicates, add documentation, rename legacyAlias
Browse files Browse the repository at this point in the history
Co-authored-by: Alois Klink <[email protected]>
  • Loading branch information
sidharthv96 and aloisklink committed Oct 8, 2024
1 parent d9a26ff commit 51be99c
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions packages/mermaid/src/rendering-util/rendering-elements/shapes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,14 @@ export interface ShapeDefinition {
name: string;
shortName: string;
description: string;
/**
* Aliases can include descriptive names, other short names, etc.
*/
aliases?: string[];
legacyAliases?: string[];
/**
* These are names used by mermaid before the introduction of new shapes. These will not be in standard formats, and shouldn't be used by the users
*/
internalAliases?: string[];
handler: ShapeHandler;
}

Expand Down Expand Up @@ -140,7 +146,7 @@ export const shapesDefs: ShapeDefinition[] = [
shortName: 'lean-r',
description: 'Represents input or output',
aliases: ['lean-right', 'in-out'],
legacyAliases: ['lean_right'],
internalAliases: ['lean_right'],
handler: lean_right,
},
{
Expand All @@ -149,7 +155,7 @@ export const shapesDefs: ShapeDefinition[] = [
shortName: 'lean-l',
description: 'Represents output or input',
aliases: ['lean-left', 'out-in'],
legacyAliases: ['lean_left'],
internalAliases: ['lean_left'],
handler: lean_left,
},
{
Expand All @@ -166,7 +172,7 @@ export const shapesDefs: ShapeDefinition[] = [
shortName: 'trap-t',
description: 'Represents a manual task',
aliases: ['manual', 'trapezoid-top', 'inv-trapezoid'],
legacyAliases: ['inv_trapezoid'],
internalAliases: ['inv_trapezoid'],
handler: inv_trapezoid,
},
{
Expand All @@ -175,7 +181,7 @@ export const shapesDefs: ShapeDefinition[] = [
shortName: 'dbl-circ',
description: 'Represents a stop point',
aliases: ['double-circle'],
legacyAliases: ['doublecircle'],
internalAliases: ['doublecircle'],
handler: doublecircle,
},
{
Expand Down Expand Up @@ -420,7 +426,7 @@ export const shapesDefs: ShapeDefinition[] = [
name: 'Odd',
shortName: 'odd',
description: 'Odd shape',
legacyAliases: ['rect_left_inv_arrow'],
internalAliases: ['rect_left_inv_arrow'],
handler: rect_left_inv_arrow,
},
{
Expand All @@ -438,16 +444,11 @@ const generateShapeMap = () => {
const shapeMap: Record<string, ShapeHandler> = {
// States
state,
stateStart,
stateEnd,
forkJoin,
choice,
note,

// Rectangles
rectWithTitle,
roundedRect,
squareRect,
labelRect,

// Icons
Expand All @@ -464,7 +465,7 @@ const generateShapeMap = () => {
for (const alias of [
shape.shortName,
...(shape.aliases ?? []),
...(shape.legacyAliases ?? []),
...(shape.internalAliases ?? []),
]) {
shapeMap[alias] = shape.handler;
}
Expand Down

0 comments on commit 51be99c

Please sign in to comment.