Skip to content

Commit f0af5b8

Browse files
authored
Add generator comment to Markdown output (#496)
1 parent 51fa35c commit f0af5b8

File tree

85 files changed

+262
-13
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+262
-13
lines changed

lib/output/markdown_ast.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ function commentsToAST(comments, options, callback) {
2929

3030
var formatType = _formatType.bind(undefined, linkerStack.link);
3131

32+
var generatorComment = [
33+
u('html', '<!-- Generated by documentation.js. Update this documentation by updating the source code. -->')
34+
];
35+
3236
/**
3337
* Generate an AST chunk for a comment at a given depth: this is
3438
* split from the main function to handle hierarchially nested comments
@@ -190,9 +194,9 @@ function commentsToAST(comments, options, callback) {
190194
}
191195

192196
return callback(null, rerouteLinks(linkerStack.link,
193-
u('root', comments.reduce(function (memo, comment) {
197+
u('root', generatorComment.concat(comments.reduce(function (memo, comment) {
194198
return memo.concat(generate(1, comment));
195-
}, []))));
199+
}, [])))));
196200
}
197201

198202
module.exports = commentsToAST;

test/bin-readme.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,11 @@ test('readme command', function (group) {
7070
fs.copySync(path.join(fixtures, 'README.input.md'), path.join(d, 'other.md'));
7171
documentation(['readme index.js -s API --readme-file other.md'], {cwd: d}, function (err, stdout) {
7272
t.error(err);
73-
var actual = fs.readFileSync(path.join(d, 'other.md'), 'utf-8');
73+
var actualPath = path.join(d, 'other.md');
74+
if (UPDATE) {
75+
fs.writeFileSync(actualPath, expected);
76+
}
77+
var actual = fs.readFileSync(actualPath, 'utf-8');
7478
t.same(actual, expected, 'generated readme output');
7579
t.end();
7680
});

test/fixture/auto_lang_hljs/multilanguage.output.md

Lines changed: 2 additions & 0 deletions

test/fixture/class.output.md

Lines changed: 2 additions & 0 deletions

test/fixture/class.output.md.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
{
22
"type": "root",
33
"children": [
4+
{
5+
"type": "html",
6+
"value": "<!-- Generated by documentation.js. Update this documentation by updating the source code. -->"
7+
},
48
{
59
"depth": 1,
610
"type": "heading",

test/fixture/es6-import.output.md

Lines changed: 2 additions & 0 deletions

test/fixture/es6-import.output.md.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
{
22
"type": "root",
33
"children": [
4+
{
5+
"type": "html",
6+
"value": "<!-- Generated by documentation.js. Update this documentation by updating the source code. -->"
7+
},
48
{
59
"depth": 1,
610
"type": "heading",

test/fixture/es6.output.md

Lines changed: 2 additions & 0 deletions

test/fixture/es6.output.md.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
{
22
"type": "root",
33
"children": [
4+
{
5+
"type": "html",
6+
"value": "<!-- Generated by documentation.js. Update this documentation by updating the source code. -->"
7+
},
48
{
59
"depth": 1,
610
"type": "heading",

test/fixture/event.output.md

Lines changed: 2 additions & 0 deletions

test/fixture/event.output.md.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
{
22
"type": "root",
33
"children": [
4+
{
5+
"type": "html",
6+
"value": "<!-- Generated by documentation.js. Update this documentation by updating the source code. -->"
7+
},
48
{
59
"depth": 1,
610
"type": "heading",

test/fixture/example-caption.output.md

Lines changed: 2 additions & 0 deletions

test/fixture/example-caption.output.md.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
{
22
"type": "root",
33
"children": [
4+
{
5+
"type": "html",
6+
"value": "<!-- Generated by documentation.js. Update this documentation by updating the source code. -->"
7+
},
48
{
59
"depth": 1,
610
"type": "heading",

test/fixture/external.output.md

Lines changed: 2 additions & 0 deletions

test/fixture/external.output.md.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
{
22
"type": "root",
33
"children": [
4+
{
5+
"type": "html",
6+
"value": "<!-- Generated by documentation.js. Update this documentation by updating the source code. -->"
7+
},
48
{
59
"depth": 1,
610
"type": "heading",

test/fixture/factory.output.md

Lines changed: 2 additions & 0 deletions

test/fixture/factory.output.md.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
{
22
"type": "root",
33
"children": [
4+
{
5+
"type": "html",
6+
"value": "<!-- Generated by documentation.js. Update this documentation by updating the source code. -->"
7+
},
48
{
59
"depth": 1,
610
"type": "heading",

test/fixture/infer-private.output.md

Lines changed: 2 additions & 0 deletions

test/fixture/infer-private.output.md.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
{
22
"type": "root",
33
"children": [
4+
{
5+
"type": "html",
6+
"value": "<!-- Generated by documentation.js. Update this documentation by updating the source code. -->"
7+
},
48
{
59
"depth": 1,
610
"type": "heading",

test/fixture/inheritance.output.md

Lines changed: 2 additions & 0 deletions

test/fixture/inheritance.output.md.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
{
22
"type": "root",
33
"children": [
4+
{
5+
"type": "html",
6+
"value": "<!-- Generated by documentation.js. Update this documentation by updating the source code. -->"
7+
},
48
{
59
"depth": 1,
610
"type": "heading",

test/fixture/inline-link.output.md

Lines changed: 2 additions & 0 deletions

test/fixture/inline-link.output.md.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
{
22
"type": "root",
33
"children": [
4+
{
5+
"type": "html",
6+
"value": "<!-- Generated by documentation.js. Update this documentation by updating the source code. -->"
7+
},
48
{
59
"depth": 1,
610
"type": "heading",

test/fixture/internal.output.md

Lines changed: 2 additions & 0 deletions

test/fixture/internal.output.md.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
{
22
"type": "root",
33
"children": [
4+
{
5+
"type": "html",
6+
"value": "<!-- Generated by documentation.js. Update this documentation by updating the source code. -->"
7+
},
48
{
59
"depth": 1,
610
"type": "heading",

test/fixture/memberedclass.output.md

Lines changed: 2 additions & 0 deletions

test/fixture/memberedclass.output.md.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
{
22
"type": "root",
33
"children": [
4+
{
5+
"type": "html",
6+
"value": "<!-- Generated by documentation.js. Update this documentation by updating the source code. -->"
7+
},
48
{
59
"depth": 1,
610
"type": "heading",

test/fixture/merge-infered-type.output.md

Lines changed: 2 additions & 0 deletions

test/fixture/merge-infered-type.output.md.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
{
22
"type": "root",
33
"children": [
4+
{
5+
"type": "html",
6+
"value": "<!-- Generated by documentation.js. Update this documentation by updating the source code. -->"
7+
},
48
{
59
"depth": 1,
610
"type": "heading",

test/fixture/multisignature.output.md

Lines changed: 2 additions & 0 deletions

test/fixture/multisignature.output.md.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
{
22
"type": "root",
33
"children": [
4+
{
5+
"type": "html",
6+
"value": "<!-- Generated by documentation.js. Update this documentation by updating the source code. -->"
7+
},
48
{
59
"depth": 1,
610
"type": "heading",

test/fixture/nearby_params.output.md

Lines changed: 2 additions & 0 deletions

test/fixture/nearby_params.output.md.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
{
22
"type": "root",
33
"children": [
4+
{
5+
"type": "html",
6+
"value": "<!-- Generated by documentation.js. Update this documentation by updating the source code. -->"
7+
},
48
{
59
"depth": 1,
610
"type": "heading",

test/fixture/nest_params.output.md

Lines changed: 2 additions & 0 deletions

test/fixture/nest_params.output.md.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
{
22
"type": "root",
33
"children": [
4+
{
5+
"type": "html",
6+
"value": "<!-- Generated by documentation.js. Update this documentation by updating the source code. -->"
7+
},
48
{
59
"depth": 1,
610
"type": "heading",

test/fixture/newline-in-description.output.md

Lines changed: 2 additions & 0 deletions

test/fixture/newline-in-description.output.md.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
{
22
"type": "root",
33
"children": [
4+
{
5+
"type": "html",
6+
"value": "<!-- Generated by documentation.js. Update this documentation by updating the source code. -->"
7+
},
48
{
59
"depth": 1,
610
"type": "heading",

test/fixture/no-name.output.md

Lines changed: 2 additions & 0 deletions

test/fixture/no-name.output.md.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
{
22
"type": "root",
33
"children": [
4+
{
5+
"type": "html",
6+
"value": "<!-- Generated by documentation.js. Update this documentation by updating the source code. -->"
7+
},
48
{
59
"depth": 1,
610
"type": "heading",

test/fixture/params.output.md

Lines changed: 2 additions & 0 deletions

test/fixture/params.output.md.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
{
22
"type": "root",
33
"children": [
4+
{
5+
"type": "html",
6+
"value": "<!-- Generated by documentation.js. Update this documentation by updating the source code. -->"
7+
},
48
{
59
"depth": 1,
610
"type": "heading",

test/fixture/react-jsx.output.md

Lines changed: 2 additions & 0 deletions

test/fixture/react-jsx.output.md.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
{
22
"type": "root",
33
"children": [
4+
{
5+
"type": "html",
6+
"value": "<!-- Generated by documentation.js. Update this documentation by updating the source code. -->"
7+
},
48
{
59
"depth": 1,
610
"type": "heading",

test/fixture/readme/README.output.md

Lines changed: 2 additions & 0 deletions
Lines changed: 1 addition & 1 deletion

0 commit comments

Comments
 (0)