-
Notifications
You must be signed in to change notification settings - Fork 194
Open
Description
I found that dox does a pretty good job on its own for handling ES-2015 and the modules syntax. However when trying to document my API, I found it impossible to tag my re-exported module methods.
For example:
/**
* hrmmm...
*/
export { html } from './util/tagged-template';So I came up with this very naive and not at all production ready parser that you can add easily and it might cover your use cases:
const dox = require('dox');
const parseArgs = str => {
const arg = /export\s+\{(.*)\}/g.exec(str)[1];
if (arg.indexOf(',') > -1) {
return arg.split(',').map(str => str.trim()).filter(Boolean)[0];
}
else if (arg.indexOf('as') > -1) {
return arg.split(' as ')[1].trim();
}
return arg.trim();
};
// Handle ES6 export syntax.
dox.contextPatternMatchers.push((string, parentContext) => {
if (string.indexOf('export') > -1) {
const name = parseArgs(string);
if (name) {
return {
type: 'property',
name,
string,
};
}
}
});raphaelokon and VladyslavLukyanenko
Metadata
Metadata
Assignees
Labels
No labels