Skip to content

Commit 35e17be

Browse files
wooormtmcw
authored andcommitted
Rename mdast to remark
Note that the AST now carries the name “mdast”, meaning utilities (such as mdast-util-inject) keep their name. This name-change includes the `mdast` formatter, which also changed to `remark`. Additionally: * Update relating packages. * Fix a bug where `text` nodes without value were [generated](https://github.com/wooorm/documentation/blob/6b905aefb160dde8d7c911daa4bd959cbec4aebe/lib/output/markdown_ast.js#L144).
1 parent 2043610 commit 35e17be

File tree

6 files changed

+21
-21
lines changed

6 files changed

+21
-21
lines changed

docs/NODE_API.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Returns **string** potentially linked HTML
1818

1919
# commentsToAST
2020

21-
Given a hierarchy-nested set of comments, generate an mdast-compatible
21+
Given a hierarchy-nested set of comments, generate an remark-compatible
2222
Abstract Syntax Usable for generating Markdown output
2323

2424

@@ -583,7 +583,7 @@ split from the main function to handle hierarchially nested comments
583583

584584

585585

586-
Returns **Object** mdast-compatible AST
586+
Returns **Object** remark-compatible AST
587587

588588

589589

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,6 @@ module.exports.expandInputs = expandInputs;
183183
module.exports.formats = {
184184
html: require('./lib/output/html'),
185185
md: require('./lib/output/markdown'),
186-
mdast: require('./lib/output/markdown_ast'),
186+
remark: require('./lib/output/markdown_ast'),
187187
json: require('./lib/output/json')
188188
};

lib/commands/readme.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
var fs = require('fs');
4-
var mdast = require('mdast');
4+
var remark = require('remark');
55
var inject = require('mdast-util-inject');
66
var chalk = require('chalk');
77
var disparity = require('disparity');
@@ -38,7 +38,7 @@ module.exports.parseArgs = function (yargs) {
3838

3939
function readme(documentation, parsedArgs) {
4040
var readmeOptions = parsedArgs.commandOptions;
41-
readmeOptions.format = 'mdast';
41+
readmeOptions.format = 'remark';
4242
/* eslint no-console: 0 */
4343
var log = readmeOptions.q ? function () {}
4444
: console.log.bind(console, '[documentation-readme] ');
@@ -51,7 +51,7 @@ function readme(documentation, parsedArgs) {
5151
throw err;
5252
}
5353
var readmeContent = fs.readFileSync(readmeFile, 'utf8');
54-
mdast.use(plugin, {
54+
remark.use(plugin, {
5555
section: readmeOptions.section,
5656
toInject: docsAst
5757
}).process(readmeContent, onInjected.bind(null, readmeContent));
@@ -81,8 +81,8 @@ function readme(documentation, parsedArgs) {
8181
}
8282
}
8383

84-
// wrap the inject utility as an mdast plugin
85-
function plugin(mdast, options) {
84+
// wrap the inject utility as an remark plugin
85+
function plugin(remark, options) {
8686
return function transform(targetAst, file, next) {
8787
if (!inject(options.section, targetAst, options.toInject)) {
8888
return next(new Error('Heading ' + options.section + ' not found.'));

lib/output/markdown.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

3-
var mdast = require('mdast'),
4-
toc = require('mdast-toc'),
3+
var remark = require('remark'),
4+
toc = require('remark-toc'),
55
markdownAST = require('./markdown_ast');
66

77
/**
@@ -15,7 +15,7 @@ var mdast = require('mdast'),
1515
* @return {undefined} calls callback
1616
*/
1717
module.exports = function (comments, opts, callback) {
18-
var processor = mdast().use(toc);
18+
var processor = remark().use(toc);
1919
markdownAST(comments, opts, function (err, ast) {
2020
var processedAST = processor.run(ast);
2121
return callback(null, processor.stringify(processedAST));

lib/output/markdown_ast.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
var mdast = require('mdast'),
1+
var remark = require('remark'),
22
u = require('unist-builder'),
33
formatType = require('documentation-theme-utils').formatType,
44
formatInlineTags = require('../format_inline_tags'),
55
hljs = require('highlight.js');
66

77
/**
8-
* Given a hierarchy-nested set of comments, generate an mdast-compatible
8+
* Given a hierarchy-nested set of comments, generate an remark-compatible
99
* Abstract Syntax Tree usable for generating Markdown output
1010
*
1111
* @param {Array<Object>} comments nested comment
@@ -25,7 +25,7 @@ function commentsToAST(comments, opts, callback) {
2525
*
2626
* @param {number} depth nesting of the comment, starting at 1
2727
* @param {Object} comment a single comment
28-
* @returns {Object} mdast-compatible AST
28+
* @returns {Object} remark-compatible AST
2929
*/
3030
function generate(depth, comment) {
3131

@@ -37,7 +37,7 @@ function commentsToAST(comments, opts, callback) {
3737
u('text', ' '),
3838
!!param.type && u('strong', formatType(param.type)),
3939
u('text', ' ')
40-
].concat(mdast.parse(formatInlineTags(param.description)).children)
40+
].concat(remark.parse(formatInlineTags(param.description)).children)
4141
.concat([
4242
!!param.default && u('paragraph', [
4343
u('text', ' (optional, default '),
@@ -74,7 +74,7 @@ function commentsToAST(comments, opts, callback) {
7474
u('strong', formatType(property.type)),
7575
u('text', ' ')
7676
]
77-
.concat(mdast.parse(formatInlineTags(property.description)).children)
77+
.concat(remark.parse(formatInlineTags(property.description)).children)
7878
.filter(Boolean)),
7979
property.properties && propertyList(property.properties)
8080
].filter(Boolean));
@@ -95,7 +95,7 @@ function commentsToAST(comments, opts, callback) {
9595
u('text', 'Returns '),
9696
u('strong', formatType(returns.type)),
9797
u('text', ' ')
98-
].concat(mdast.parse(formatInlineTags(returns.description)).children));
98+
].concat(remark.parse(formatInlineTags(returns.description)).children));
9999
});
100100
}
101101

@@ -141,10 +141,10 @@ function commentsToAST(comments, opts, callback) {
141141
})));
142142
}
143143

144-
return [u('heading', { depth: depth }, [u('text', comment.name)])]
144+
return [u('heading', { depth: depth }, [u('text', comment.name || '')])]
145145
.concat(githubLink(comment))
146146
.concat(augmentsLink(comment))
147-
.concat(mdast.parse(formatInlineTags(comment.description)).children)
147+
.concat(remark.parse(formatInlineTags(comment.description)).children)
148148
.concat(paramSection(comment))
149149
.concat(propertySection(comment))
150150
.concat(examplesSection(comment))

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
"highlight.js": "^8.4.0",
2727
"js-yaml": "^3.3.1",
2828
"jsdoc-inline-lex": "^1.0.1",
29-
"mdast": "^2.0.0",
30-
"mdast-toc": "^1.1.0",
29+
"remark": "^3.0.0",
30+
"remark-toc": "^2.0.0",
3131
"mdast-util-inject": "^1.1.0",
3232
"micromatch": "^2.1.6",
3333
"mime": "^1.3.4",

0 commit comments

Comments
 (0)