Small bug fix with requirement diagram naming.
This commit is contained in:
parent
55251e1024
commit
45518580a4
|
@ -679,24 +679,26 @@
|
||||||
end note
|
end note
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<hr />
|
||||||
|
|
||||||
<div class="mermaid">
|
<div class="mermaid">
|
||||||
requirementDiagram
|
requirementDiagram
|
||||||
|
|
||||||
requirement test_req {
|
requirement An Example {
|
||||||
id: 1
|
id: 1
|
||||||
text: the test text.
|
text: the test text.
|
||||||
risk: high
|
risk: high
|
||||||
verifymethod: test
|
verifymethod: test
|
||||||
}
|
}
|
||||||
|
|
||||||
functionalRequirement test_req2 {
|
functionalRequirement Random Name {
|
||||||
id: 1.1
|
id: 1.1
|
||||||
text: the second test text.
|
text: the second test text.
|
||||||
risk: low
|
risk: low
|
||||||
verifymethod: inspection
|
verifymethod: inspection
|
||||||
}
|
}
|
||||||
|
|
||||||
performanceRequirement test_req3 {
|
performanceRequirement Something Else {
|
||||||
id: 1.2
|
id: 1.2
|
||||||
text: the third test text.
|
text: the third test text.
|
||||||
risk: medium
|
risk: medium
|
||||||
|
@ -739,14 +741,14 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
test_entity - satisfies -> test_req2
|
test_entity - satisfies -> Random Name
|
||||||
test_req - traces -> test_req2
|
An Example - traces -> Random Name
|
||||||
test_req - contains -> test_req3
|
An Example - contains -> Something Else
|
||||||
test_req3 - contains -> test_req4
|
Something Else - contains -> test_req4
|
||||||
test_req4 - derives -> test_req5
|
test_req4 - derives -> test_req5
|
||||||
test_req5 - refines -> test_req6
|
test_req5 - refines -> test_req6
|
||||||
test_entity3 - verifies -> test_req5
|
test_entity3 - verifies -> test_req5
|
||||||
test_req <- copies - test_entity2 </div>
|
An Example <- copies - test_entity2 </div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h1 id="link-clicked">Anchor for "link-clicked" test</h1>
|
<h1 id="link-clicked">Anchor for "link-clicked" test</h1>
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -823,6 +823,22 @@ scaled based on available space. If set to false, the diagram reserves its
|
||||||
absolute width.
|
absolute width.
|
||||||
**Default value: true**.
|
**Default value: true**.
|
||||||
|
|
||||||
|
## requirement
|
||||||
|
|
||||||
|
The object containing configurations specific for req diagrams
|
||||||
|
|
||||||
|
### useMaxWidth
|
||||||
|
|
||||||
|
| Parameter | Description | Type | Required | Values |
|
||||||
|
| ----------- | ----------- | ------- | -------- | ----------- |
|
||||||
|
| useMaxWidth | See Notes | Boolean | Required | true, false |
|
||||||
|
|
||||||
|
**Notes:**
|
||||||
|
When this flag is set to true, the diagram width is locked to 100% and
|
||||||
|
scaled based on available space. If set to false, the diagram reserves its
|
||||||
|
absolute width.
|
||||||
|
**Default value: true**.
|
||||||
|
|
||||||
## setSiteConfig
|
## setSiteConfig
|
||||||
|
|
||||||
## setSiteConfig
|
## setSiteConfig
|
||||||
|
|
|
@ -9,8 +9,17 @@
|
||||||
%x string
|
%x string
|
||||||
%x token
|
%x token
|
||||||
%x unqString
|
%x unqString
|
||||||
|
%x open_directive
|
||||||
|
%x type_directive
|
||||||
|
%x arg_directive
|
||||||
|
%x close_directive
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
\%\%\{ { this.begin('open_directive'); return 'open_directive'; }
|
||||||
|
<open_directive>((?:(?!\}\%\%)[^:.])*) { this.begin('type_directive'); return 'type_directive'; }
|
||||||
|
<type_directive>":" { this.popState(); this.begin('arg_directive'); return ':'; }
|
||||||
|
<type_directive,arg_directive>\}\%\% { this.popState(); this.popState(); return 'close_directive'; }
|
||||||
|
<arg_directive>((?:(?!\}\%\%).|\n)*) return 'arg_directive';
|
||||||
|
|
||||||
(\r?\n)+ return 'NEWLINE';
|
(\r?\n)+ return 'NEWLINE';
|
||||||
\s+ /* skip all whitespace */
|
\s+ /* skip all whitespace */
|
||||||
|
@ -78,6 +87,22 @@ start
|
||||||
: directive start
|
: directive start
|
||||||
| RD NEWLINE diagram EOF;
|
| RD NEWLINE diagram EOF;
|
||||||
|
|
||||||
|
directive
|
||||||
|
: openDirective typeDirective closeDirective
|
||||||
|
| openDirective typeDirective ':' argDirective closeDirective;
|
||||||
|
|
||||||
|
openDirective
|
||||||
|
: open_directive { yy.parseDirective('%%{', 'open_directive'); };
|
||||||
|
|
||||||
|
typeDirective
|
||||||
|
: type_directive { yy.parseDirective($1, 'type_directive'); };
|
||||||
|
|
||||||
|
argDirective
|
||||||
|
: arg_directive { $1 = $1.trim().replace(/'/g, '"'); yy.parseDirective($1, 'arg_directive'); };
|
||||||
|
|
||||||
|
closeDirective
|
||||||
|
: close_directive { yy.parseDirective('}%%', 'close_directive', 'pie'); };
|
||||||
|
|
||||||
diagram
|
diagram
|
||||||
: /* empty */ { $$ = [] }
|
: /* empty */ { $$ = [] }
|
||||||
| requirementDef diagram
|
| requirementDef diagram
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import configApi from '../../config';
|
import * as configApi from '../../config';
|
||||||
import { log } from '../../logger';
|
import { log } from '../../logger';
|
||||||
import mermaidAPI from '../../mermaidAPI';
|
import mermaidAPI from '../../mermaidAPI';
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ import { configureSvgSize } from '../../utils';
|
||||||
import common from '../common/common';
|
import common from '../common/common';
|
||||||
import { parser } from './parser/requirementDiagram';
|
import { parser } from './parser/requirementDiagram';
|
||||||
import requirementDb from './requirementDb';
|
import requirementDb from './requirementDb';
|
||||||
import { insertLineEndings, ReqMarkers } from './requirementMarkers';
|
import markers from './requirementMarkers';
|
||||||
|
|
||||||
const conf = {};
|
const conf = {};
|
||||||
let relCnt = 0;
|
let relCnt = 0;
|
||||||
|
@ -44,7 +44,7 @@ const newTitleNode = (parentNode, id, txts) => {
|
||||||
.attr('class', 'req reqLabel reqTitle')
|
.attr('class', 'req reqLabel reqTitle')
|
||||||
.attr('id', id)
|
.attr('id', id)
|
||||||
.attr('x', x)
|
.attr('x', x)
|
||||||
.attr('y', 0)
|
.attr('y', conf.rect_padding)
|
||||||
.attr('dominant-baseline', 'hanging')
|
.attr('dominant-baseline', 'hanging')
|
||||||
.attr(
|
.attr(
|
||||||
'style',
|
'style',
|
||||||
|
@ -58,7 +58,7 @@ const newTitleNode = (parentNode, id, txts) => {
|
||||||
.append('tspan')
|
.append('tspan')
|
||||||
.attr('text-anchor', 'middle')
|
.attr('text-anchor', 'middle')
|
||||||
.attr('x', conf.rect_min_width / 2)
|
.attr('x', conf.rect_min_width / 2)
|
||||||
.attr('dy', conf.rect_padding)
|
.attr('dy', 0)
|
||||||
.text(textStr);
|
.text(textStr);
|
||||||
} else {
|
} else {
|
||||||
title
|
title
|
||||||
|
@ -171,7 +171,7 @@ const addEdgeLabel = (parentNode, svgPath, conf, txt) => {
|
||||||
|
|
||||||
const drawRelationshipFromLayout = function(svg, rel, g, insert) {
|
const drawRelationshipFromLayout = function(svg, rel, g, insert) {
|
||||||
// Find the edge relating to this relationship
|
// Find the edge relating to this relationship
|
||||||
const edge = g.edge(rel.src, rel.dst);
|
const edge = g.edge(elementString(rel.src), elementString(rel.dst));
|
||||||
|
|
||||||
// Get a function that will generate the line path
|
// Get a function that will generate the line path
|
||||||
const lineFunction = line()
|
const lineFunction = line()
|
||||||
|
@ -202,7 +202,7 @@ const drawRelationshipFromLayout = function(svg, rel, g, insert) {
|
||||||
'url(' +
|
'url(' +
|
||||||
common.getUrl(conf.arrowMarkerAbsolute) +
|
common.getUrl(conf.arrowMarkerAbsolute) +
|
||||||
'#' +
|
'#' +
|
||||||
ReqMarkers.ARROW +
|
markers.ReqMarkers.ARROW +
|
||||||
'_line_ending' +
|
'_line_ending' +
|
||||||
')'
|
')'
|
||||||
);
|
);
|
||||||
|
@ -216,6 +216,9 @@ const drawRelationshipFromLayout = function(svg, rel, g, insert) {
|
||||||
export const drawReqs = (reqs, graph, svgNode) => {
|
export const drawReqs = (reqs, graph, svgNode) => {
|
||||||
Object.keys(reqs).forEach(reqName => {
|
Object.keys(reqs).forEach(reqName => {
|
||||||
let req = reqs[reqName];
|
let req = reqs[reqName];
|
||||||
|
reqName = elementString(reqName);
|
||||||
|
console.log('reqName: ', reqName);
|
||||||
|
log.info('Added new requirement: ', reqName);
|
||||||
|
|
||||||
const groupNode = svgNode.append('g').attr('id', reqName);
|
const groupNode = svgNode.append('g').attr('id', reqName);
|
||||||
const textId = 'req-' + reqName;
|
const textId = 'req-' + reqName;
|
||||||
|
@ -259,7 +262,7 @@ export const drawReqs = (reqs, graph, svgNode) => {
|
||||||
export const drawElements = (els, graph, svgNode) => {
|
export const drawElements = (els, graph, svgNode) => {
|
||||||
Object.keys(els).forEach(elName => {
|
Object.keys(els).forEach(elName => {
|
||||||
let el = els[elName];
|
let el = els[elName];
|
||||||
const id = elName.replace(/\./g, '_');
|
const id = elementString(elName);
|
||||||
|
|
||||||
const groupNode = svgNode.append('g').attr('id', id);
|
const groupNode = svgNode.append('g').attr('id', id);
|
||||||
const textId = 'element-' + id;
|
const textId = 'element-' + id;
|
||||||
|
@ -294,7 +297,9 @@ export const drawElements = (els, graph, svgNode) => {
|
||||||
|
|
||||||
const addRelationships = (relationships, g) => {
|
const addRelationships = (relationships, g) => {
|
||||||
relationships.forEach(function(r) {
|
relationships.forEach(function(r) {
|
||||||
g.setEdge(r.src, r.dst, { relationship: r });
|
let src = elementString(r.src);
|
||||||
|
let dst = elementString(r.dst);
|
||||||
|
g.setEdge(src, dst, { relationship: r });
|
||||||
});
|
});
|
||||||
return relationships;
|
return relationships;
|
||||||
};
|
};
|
||||||
|
@ -318,13 +323,16 @@ const adjustEntities = function(svgNode, graph) {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const elementString = str => {
|
||||||
|
return str.replace(/\s/g, '').replace(/\./g, '_');
|
||||||
|
};
|
||||||
|
|
||||||
export const draw = (text, id) => {
|
export const draw = (text, id) => {
|
||||||
log.info('Drawing requirements!');
|
|
||||||
parser.yy = requirementDb;
|
parser.yy = requirementDb;
|
||||||
parser.parse(text);
|
parser.parse(text);
|
||||||
|
|
||||||
const svg = select(`[id='${id}']`);
|
const svg = select(`[id='${id}']`);
|
||||||
insertLineEndings(svg, conf);
|
markers.insertLineEndings(svg, conf);
|
||||||
|
|
||||||
const g = new graphlib.Graph({
|
const g = new graphlib.Graph({
|
||||||
multigraph: false,
|
multigraph: false,
|
||||||
|
|
Loading…
Reference in New Issue