Skip to content

Commit ef8bd6b

Browse files
authored
Merge pull request #75 from InnerSourceCommons/fix-gqm-links
fix: add mermaid clicks instead of inline links
2 parents 1b0c018 + 488abae commit ef8bd6b

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

scripts/gqm_gen/index.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const mdFilePath = process.env.npm_config_markDownFilePath || "../../measuring";
99
const graph = getGQMFileLinks(mdFilePath);
1010

1111
export function getLinkUrl(linkType: LinkType, file: string) {
12-
const measuringUrl = "https://github.com/InnerSourceCommons/managing-inner-source-projects/blob/main/measuring/";
12+
const measuringUrl = "https://github.com/InnerSourceCommons/managing-inner-source-projects/blob/main/measuring";
1313
const url = `${measuringUrl}/${linkType.toLowerCase()}s/${file}`
1414
return url;
1515
}
@@ -127,7 +127,7 @@ export function getLinks(parsed: Commonmark.Node) {
127127

128128
export function getNodeShapeSyntax(node: Node) {
129129
const nodeUrl = getLinkUrl(node.type, node.id)
130-
const nodeLabel = `<a href='${nodeUrl}'>${node.label}</a>`;
130+
const nodeLabel = `${node.label}`;
131131
switch (node.shape) {
132132
case 'rect':
133133
return `[${nodeLabel}]`;
@@ -150,16 +150,31 @@ export function generateMermaidDiagram(graph: Graph) {
150150
subgraph GQM[Goals, Questions, Metrics]\n
151151
`;
152152

153+
mermaidSyntax += " %% begin nodes\n";
153154
nodes.forEach((node) => {
154155
const nodeSyntax = getNodeShapeSyntax(node)
155156
mermaidSyntax += ` ${node.id}${nodeSyntax}\n`
156157
});
158+
mermaidSyntax += " %% end nodes\n\n";
159+
160+
mermaidSyntax += " %% begin edges\n";
157161

158162
edges.forEach((edge) => {
159163
const arrowSyntax: string = ArrowType.ARROW;
160164
mermaidSyntax += ` ${edge.from}${arrowSyntax}${edge.to}\n`;
161165
});
162166

167+
mermaidSyntax += " %% end edges\n\n";
168+
169+
mermaidSyntax += " %% begin clicks\n"
170+
171+
nodes.forEach((node) => {
172+
const nodeUrl = getLinkUrl(node.type, node.id);
173+
mermaidSyntax += ` click ${node.id} "${nodeUrl}" "${node.label}"\n`;
174+
});
175+
176+
mermaidSyntax += " %% end clicks\n\n"
177+
163178
const goalsList = nodes.filter(n => n.type == LinkType.GOAL).map(n => `${n.id}`).join(',');
164179
const questionsList = nodes.filter(n => n.type == LinkType.QUESTION).map(n => `${n.id}`).join(',');
165180
const metricsList = nodes.filter(n => n.type == LinkType.METRIC).map(n => `${n.id}`).join(',');

0 commit comments

Comments
 (0)