这里自定义一个 apiAuthor - 开发者
第一步:首先在找到你的apidoc安装目录,我这里是:
C:\Users\Administrator\AppData\Roaming\npm\node_modules\apidoc\
注:以下目录都是以这个为跟目录。
第二步:找到定义文件:
.\node_modules\apidoc-core\lib\index.js
第三步:添加你的信息,这里是我的:
apiauthor : './parsers/api_author.js',
第四步:在你定义的这个目录下添加你刚定义的文件(我的是api_author.js),文件内容自定义,我这里是直接用的api_deprecated.js的内容,哈哈!
var trim = require('../utils/trim');
var unindent = require('../utils/unindent');
function parse(content) {
var author = trim(content);
if (author.length > 0) {
return {
author: {
content: unindent(author)
}
};
}
return {
author: true
};
}
/**
* Exports
*/
module.exports = {
parse : parse,
path : 'local',
method: 'insert',
markdownFields: [ 'author.content' ],
markdownRemovePTags: [ 'author.content' ]
};
第五步:找到渲染模板,改,我这里是:
.\template\index.html
这里我放在了描述前面:
{{#if article.author}}
<p class="deprecated"><span>开发者</span>
{{{markdown article.author.content}}}
</p>
{{/if}}
OK!大功告成,下面看看效果