在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):millermedeiros/mdoc开源软件地址(OpenSource Url):https://github.com/millermedeiros/mdoc开源编程语言(OpenSource Language):CSS 49.4%开源软件介绍(OpenSource Introduction):mdoc - a simple markdown based documentation generatorThis is a simple markdown based documentation generator, it will search all the markdown files inside the "input" directory and output an HTML file for each document, it will also generate a "TOC" (table of contents) for each file and links to all the pages on the index page, it also provides a basic search feature and quick browsing between classes/methods/properties. Reasoning behind it: inline documentation, why I'm ditching it . Markdown syntaxmdoc uses the github "codeblock syntax" to highlight code. E.g.:
Currently the parser considers H2 as sections/methods/properties names and will add them to the TOC at the top of each file and automatically generate deep-links to them. It's important to notice that mdoc only recognizes headers on the atx-style as a new section. The first paragraph after the H2 will be used as description on the sidebar. Currently the search feature only searches copy from the title and description. For a markdown syntax reference check: http://daringfireball.net/projects/markdown/dingus And also check the structure of the example files. InstallYou can install it through NPM:
Basic UsageIn a nodeJS file, create the basic outline with the desired configuration options listed below require('mdoc').run({
// configuration options (specified below)
inputDir: 'docs',
outputDir: 'dist'
}); Run the file ConfigurationSource/Destination Directories (Required)The following two options contain the source directory to read the documentation from and the destination directory to write the finished product to.
Basic settings (Optional)Index FileThese two options both specify what should go in to the index file. The
Site Title TagThis controls what goes in the
Advanced settings (Optional)Custom TemplatesSpecify the path to the custom templates to use. These should be Handlebar template files
Static AssetsSpecify the path to the static asset files (JS/CSS/images, etc)
Outputted File NamesChange the name of the outputted HTML files using a custom replacement string mapOutName: function (outputName) {
return outputName.replace('.html', '_doc.html');
} Display NameChange the name displayed on the sidebar and on the index TOC mapTocName: function (fileName, tocObject, title) {
return fileName.replace('_doc.html', '');
} Include FilesPattern that matches files that should be parsed
Exclude FilesPattern that matches files that shouldn't be parsed
Filter FilesFilters file. Return filterFiles: function (fileInfo) {
return (/math/).test(fileInfo.input);
} Heading LevelSets which heading should be treated as a section start (and is used for TOC) defaults to
Handlebars HelpersYou can also pass custom Handlebars helpers to be used during the compilation. hbHelpers : {
currency: function(val){
var format = require('mout/number/currencyFormat');
return format(val);
},
first: function(context, block) {
return block.fn(context[0]);
}
} Handlebars contextYou can also extend the context that gets provided to the Handlebars templates. ctx : {
version: '1.0.0'
menu: [
{ name: 'Home', link: '/'},
{ name: 'Documentation', link: '/docs'},
{ name: 'API', link: '/docs/api'}
],
site: {
page: {
title: 'API Documentation'
}
}
} Those could be used inside your custom template as follow <ul>
{{#each ctx.menu}}
<li><a href="{{link}}">{{name}}</a></li>
{{/each}}
</ul>
<h2>{{ ctx.site.page.title }}</h2> Also you can use Handlebars template in your markdown files:
Parser overrideIf you want to use another markdown parser you can override the parsing function: parsingFunction: function(markdownText): {
return myParser.markdownToHtml(markdownText);
} ExamplesFor a live example check: MOUT documentation or the unofficial NodeJS api (uses markdown files from nodejs repository as source) Command line interface
For a list of available commands run:
Node moduleCheck files inside the "examples" folder. Run:
Check output inside "examples/basic/doc". Check "examples/advanced" for all the available settings. LicenseReleased under the MIT license. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论