Browse Source

test,tools: test yaml parsing of doctool

Add checks that make sure the doctool parses metadata correctly.

PR-URL: https://github.com/nodejs/node/pull/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>
process-exit-stdio-flushing
Anna Henningsen 9 years ago
parent
commit
1b365f60f0
No known key found for this signature in database GPG Key ID: D8B9F5AEAE84E4CF
  1. 20
      test/doctool/test-doctool-html.js
  2. 47
      test/doctool/test-doctool-json.js
  3. 21
      test/fixtures/doc_with_yaml.md

20
test/doctool/test-doctool-html.js

@ -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) {

47
test/doctool/test-doctool-json.js

@ -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'
}
]
}
}
];

21
test/fixtures/doc_with_yaml.md

@ -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.
Loading…
Cancel
Save