-
Notifications
You must be signed in to change notification settings - Fork 29.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test doctool #6031
Closed
Closed
Test doctool #6031
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const fs = require('fs'); | ||
|
||
const html = require('../../tools/doc/html.js'); | ||
|
||
// Test data is a list of objects with two properties. | ||
// The file property is the file path. | ||
// The html property is some html which will be generated by the doctool. | ||
// This html will be stripped of all whitespace because we don't currently | ||
// have an html parser. | ||
const testData = [ | ||
{ | ||
'file': common.fixturesDir + '/sample_document.md', | ||
'html': '<ol><li>fish</li><li><p>fish</p></li><li><p>Redfish</p></li>' + | ||
'<li>Bluefish</li></ol>' | ||
}, | ||
{ | ||
'file': common.fixturesDir + '/order_of_end_tags_5873.md', | ||
'html': '<h3>ClassMethod: Buffer.from(array) <span> ' + | ||
'<a class="mark" href="#foo_class_method_buffer_from_array" ' + | ||
'id="foo_class_method_buffer_from_array">#</a> </span> </h3><div' + | ||
'class="signature"><ul><li><code>array</code><a ' + | ||
'href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/' + | ||
'Reference/Global_Objects/Array" class="type"><Array></a></li>' + | ||
'</ul></div>' | ||
}, | ||
]; | ||
|
||
testData.forEach(function(item) { | ||
// Normalize expected data by stripping whitespace | ||
const expected = item.html.replace(/\s/g, ''); | ||
|
||
fs.readFile(item.file, 'utf8', common.mustCall(function(err, input) { | ||
assert.ifError(err); | ||
html(input, 'foo', 'doc/template.html', | ||
common.mustCall(function(err, output) { | ||
assert.ifError(err); | ||
|
||
const actual = output.replace(/\s/g, ''); | ||
// Assert that the input stripped of all whitespace contains the | ||
// expected list | ||
assert.notEqual(actual.indexOf(expected), -1); | ||
})); | ||
})); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const fs = require('fs'); | ||
|
||
const json = require('../../tools/doc/json.js'); | ||
|
||
// Outputs valid json with the expected fields when given simple markdown | ||
// Test data is a list of objects with two properties. | ||
// The file property is the file path. | ||
// The json property is some json which will be generated by the doctool. | ||
var testData = [ | ||
{ | ||
'file': common.fixturesDir + '/sample_document.md', | ||
'json': { | ||
'source': 'foo', | ||
'modules': [ { 'textRaw': 'Sample Markdown', | ||
'name': 'sample_markdown', | ||
'modules': [ { 'textRaw':'Seussian Rhymes', | ||
'name': 'seussian_rhymes', | ||
'desc': '<ol>\n<li>fish</li>\n<li><p>fish</p>\n</li>\n<li>' + | ||
'<p>Red fish</p>\n</li>\n<li>Blue fish</li>\n</ol>\n', | ||
'type': 'module', | ||
'displayName': 'Seussian Rhymes' | ||
} ], | ||
'type': 'module', | ||
'displayName': 'Sample Markdown' | ||
} ] | ||
} | ||
}, | ||
{ | ||
'file': common.fixturesDir + '/order_of_end_tags_5873.md', | ||
'json': { | ||
'source':'foo', | ||
'modules': [ { | ||
'textRaw': 'Title', | ||
'name': 'title', | ||
'modules': [ { | ||
'textRaw': 'Subsection', | ||
'name': 'subsection', | ||
'classMethods': [ { | ||
'textRaw': 'Class Method: Buffer.from(array)', | ||
'type':'classMethod', | ||
'name':'from', | ||
'signatures': [ { | ||
'params': [ { | ||
'textRaw': '`array` {Array} ', | ||
'name': 'array', | ||
'type': 'Array' | ||
} ] | ||
}, | ||
{ | ||
'params' : [ { | ||
'name': 'array' | ||
} ] | ||
} | ||
] | ||
} ], | ||
'type': 'module', | ||
'displayName': 'Subsection' | ||
} ], | ||
'type': 'module', | ||
'displayName': 'Title' | ||
} ] | ||
} | ||
} | ||
]; | ||
|
||
testData.forEach(function(item) { | ||
fs.readFile(item.file, 'utf8', common.mustCall(function(err, input) { | ||
assert.ifError(err); | ||
json(input, 'foo', common.mustCall(function(err, output) { | ||
assert.ifError(err); | ||
assert.deepStrictEqual(output, item.json); | ||
})); | ||
})); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import os | ||
import sys | ||
sys.path.append(os.path.join(os.path.dirname(__file__), '..')) | ||
import testpy | ||
|
||
def GetConfiguration(context, root): | ||
return testpy.SimpleTestConfiguration(context, root, 'doctool') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Title | ||
|
||
## Subsection | ||
|
||
### Class Method: Buffer.from(array) | ||
* `array` {Array} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Sample Markdown | ||
|
||
## Seussian Rhymes | ||
1. fish | ||
2. fish | ||
|
||
* Red fish | ||
* Blue fish |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1427,6 +1427,7 @@ def ExpandCommand(args): | |
'addons', | ||
'gc', | ||
'debugger', | ||
'doctool', | ||
] | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very minor, but for consistency I'd suggest adding the new directory on the last position here, like you did with
test-ci
below. Same goes forvcbuild.bat
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I'd keep both lists in alphabetical order if it's all the same to everyone else.
I promise to not say another words about this, as I bike-shedded more than my share on the last topic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I alphabetized them because that makes more sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call 👍