Skip to content

Commit 8f76d7d

Browse files
addaleaxMyles Borins
authored and
Myles Borins
committed
test,tools: test yaml parsing of doctool
Add checks that make sure the doctool parses metadata correctly. PR-URL: #6495 Reviewed-By: Robert Jefe Lindstaedt <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Jeremiah Senkpiel <[email protected]>
1 parent 2832a60 commit 8f76d7d

File tree

3 files changed

+88
-0
lines changed

3 files changed

+88
-0
lines changed

test/doctool/test-doctool-html.js

+20
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,26 @@ const testData = [
2727
'Reference/Global_Objects/Array" class="type">&lt;Array&gt;</a></li>' +
2828
'</ul></div>'
2929
},
30+
{
31+
'file': common.fixturesDir + '/doc_with_yaml.md',
32+
'html': '<h1>Sample Markdown with YAML info' +
33+
'<span><a class="mark" href="#foo_sample_markdown_with_yaml_info" ' +
34+
' id="foo_sample_markdown_with_yaml_info">#</a></span></h1>' +
35+
'<h2>Foobar<span><a class="mark" href="#foo_foobar" ' +
36+
'id="foo_foobar">#</a></span></h2>' +
37+
'<div class="api_metadata"><span>Added: v1.0.0</span></div> ' +
38+
'<p>Describe <code>Foobar</code> in more detail here.</p>' +
39+
'<h2>Deprecated thingy<span><a class="mark" ' +
40+
'href="#foo_deprecated_thingy" id="foo_deprecated_thingy">#</a>' +
41+
'</span></h2>' +
42+
'<div class="api_metadata"><span>Added: v1.0.0</span></div><p>Describe ' +
43+
'<code>Deprecated thingy</code> in more detail here.</p>' +
44+
'<h2>Something<span><a class="mark" href="#foo_something" ' +
45+
'id="foo_something">#</a></span></h2> ' +
46+
'<!-- This is not a metadata comment --> ' +
47+
'<p>Describe <code>Something</code> in more detail here. ' +
48+
'</p>'
49+
},
3050
];
3151

3252
testData.forEach(function(item) {

test/doctool/test-doctool-json.js

+47
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,53 @@ var testData = [
6464
'displayName': 'Title'
6565
} ]
6666
}
67+
},
68+
{
69+
'file': common.fixturesDir + '/doc_with_yaml.md',
70+
'json': {
71+
'source': 'foo',
72+
'modules': [
73+
{
74+
'textRaw': 'Sample Markdown with YAML info',
75+
'name': 'sample_markdown_with_yaml_info',
76+
'modules': [
77+
{
78+
'textRaw': 'Foobar',
79+
'name': 'foobar',
80+
'meta': {
81+
'added': 'v1.0.0'
82+
},
83+
'desc': '<p>Describe <code>Foobar</code> in more detail ' +
84+
'here.\n\n</p>\n',
85+
'type': 'module',
86+
'displayName': 'Foobar'
87+
},
88+
{
89+
'textRaw': 'Deprecated thingy',
90+
'name': 'deprecated_thingy',
91+
'meta': {
92+
'added': 'v1.0.0',
93+
'deprecated': 'v2.0.0'
94+
},
95+
'desc': '<p>Describe <code>Deprecated thingy</code> in more ' +
96+
'detail here.\n\n</p>\n',
97+
'type': 'module',
98+
'displayName': 'Deprecated thingy'
99+
},
100+
{
101+
'textRaw': 'Something',
102+
'name': 'something',
103+
'desc': '<!-- This is not a metadata comment -->\n\n<p>' +
104+
'Describe <code>Something</code> in more detail here.\n</p>\n',
105+
'type': 'module',
106+
'displayName': 'Something'
107+
}
108+
],
109+
'type': 'module',
110+
'displayName': 'Sample Markdown with YAML info'
111+
}
112+
]
113+
}
67114
}
68115
];
69116

test/fixtures/doc_with_yaml.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Sample Markdown with YAML info
2+
3+
## Foobar
4+
<!-- YAML
5+
added: v1.0.0
6+
-->
7+
8+
Describe `Foobar` in more detail here.
9+
10+
## Deprecated thingy
11+
<!-- YAML
12+
added: v1.0.0
13+
deprecated: v2.0.0
14+
-->
15+
16+
Describe `Deprecated thingy` in more detail here.
17+
18+
## Something
19+
<!-- This is not a metadata comment -->
20+
21+
Describe `Something` in more detail here.

0 commit comments

Comments
 (0)