Skip to content

Commit

Permalink
test,tools: test yaml parsing of doctool
Browse files Browse the repository at this point in the history
Add checks that make sure the doctool parses metadata correctly.

PR-URL: #6495
Reviewed-By: Robert Jefe Lindstaedt <robert.lindstaedt@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
  • Loading branch information
addaleax authored and Myles Borins committed Jul 14, 2016
1 parent f0f990a commit 6a65939
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test/doctool/test-doctool-html.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,26 @@ const testData = [
'Reference/Global_Objects/Array" class="type">&lt;Array&gt;</a></li>' +
'</ul></div>'
},
{
'file': common.fixturesDir + '/doc_with_yaml.md',
'html': '<h1>Sample Markdown with YAML info' +
'<span><a class="mark" href="#foo_sample_markdown_with_yaml_info" ' +
' id="foo_sample_markdown_with_yaml_info">#</a></span></h1>' +
'<h2>Foobar<span><a class="mark" href="#foo_foobar" ' +
'id="foo_foobar">#</a></span></h2>' +
'<div class="api_metadata"><span>Added: v1.0.0</span></div> ' +
'<p>Describe <code>Foobar</code> in more detail here.</p>' +
'<h2>Deprecated thingy<span><a class="mark" ' +
'href="#foo_deprecated_thingy" id="foo_deprecated_thingy">#</a>' +
'</span></h2>' +
'<div class="api_metadata"><span>Added: v1.0.0</span></div><p>Describe ' +
'<code>Deprecated thingy</code> in more detail here.</p>' +
'<h2>Something<span><a class="mark" href="#foo_something" ' +
'id="foo_something">#</a></span></h2> ' +
'<!-- This is not a metadata comment --> ' +
'<p>Describe <code>Something</code> in more detail here. ' +
'</p>'
},
];

testData.forEach(function(item) {
Expand Down
47 changes: 47 additions & 0 deletions test/doctool/test-doctool-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,53 @@ var testData = [
'displayName': 'Title'
} ]
}
},
{
'file': common.fixturesDir + '/doc_with_yaml.md',
'json': {
'source': 'foo',
'modules': [
{
'textRaw': 'Sample Markdown with YAML info',
'name': 'sample_markdown_with_yaml_info',
'modules': [
{
'textRaw': 'Foobar',
'name': 'foobar',
'meta': {
'added': 'v1.0.0'
},
'desc': '<p>Describe <code>Foobar</code> in more detail ' +
'here.\n\n</p>\n',
'type': 'module',
'displayName': 'Foobar'
},
{
'textRaw': 'Deprecated thingy',
'name': 'deprecated_thingy',
'meta': {
'added': 'v1.0.0',
'deprecated': 'v2.0.0'
},
'desc': '<p>Describe <code>Deprecated thingy</code> in more ' +
'detail here.\n\n</p>\n',
'type': 'module',
'displayName': 'Deprecated thingy'
},
{
'textRaw': 'Something',
'name': 'something',
'desc': '<!-- This is not a metadata comment -->\n\n<p>' +
'Describe <code>Something</code> in more detail here.\n</p>\n',
'type': 'module',
'displayName': 'Something'
}
],
'type': 'module',
'displayName': 'Sample Markdown with YAML info'
}
]
}
}
];

Expand Down
21 changes: 21 additions & 0 deletions test/fixtures/doc_with_yaml.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Sample Markdown with YAML info

## Foobar
<!-- YAML
added: v1.0.0
-->

Describe `Foobar` in more detail here.

## Deprecated thingy
<!-- YAML
added: v1.0.0
deprecated: v2.0.0
-->

Describe `Deprecated thingy` in more detail here.

## Something
<!-- This is not a metadata comment -->

Describe `Something` in more detail here.

0 comments on commit 6a65939

Please sign in to comment.