Documentation parser, adapts to any language and will help you document all the things.
Docs, addapts to any language and will help you document all the things.
Where there is development there is a need for documentation. There are several great libraries for all sorts of files, written by brilliant developers, libraries like [SassDoc][sass-doc], [JSDoc][js-doc], [JavaDoc][java-doc], [Jazzy][jazzy], [StyleDocco][styledocco], [KSS][kss], [Hologram][hologram], [DSS][dss] and several more. All of these libraries do a very good job for documenting their respective languages. However there are very few projects that only require 1 file type. Which means if you really want to document all your code you may have to use 3 or 4 of these documentation generators. Each of the generators have their own way of documenting and their annotations, and their own document site which just makes it harder to keep all your documentation in one spot.
Docs fixes all these issues by giving you the ability to generate documentation for all your files. While giving you control over what annotations you want to use in each file type.
files: file globs to be parsed to get the documentation
default
``js`
[ 'app//', 'src//', '*.md' ]
ignore: files globs to be ignored
default
`js`
[
'.*', // all dot files
'node_modules/', 'bower_components/', 'jspm_packages/', // package managers
'dist/', 'build/', 'docs/', // normal folders
'tests/', 'coverage/' // unit tests and coverage results
]
watch: when true it will watch files for changes
default false
raw: Will return the raw data by file, aka data won't be sorted
default false
languages: This is an object of comment styles for various languages.
default
`js
{
// annotation identifier that can be change on a file specific basis if needed.
// While this is a setting, it probably should probably never be changed. If it does
// need to be changed it should be changed to be a special character.
prefix: '@',
// header comment style
// @note {10} only 1 of these can be used per file
header: { start: '////', line: '///', end: '////', type: 'header' },
// body comment style
body: { start: '', line: '///', end: '', type: 'body' },
// inline comments for body comments
inline: { start: '', line: '///#', end: '', type: 'inline' },
// this is used for any interpolations that might occur in annotations.
// I don't see this needing to change but just incase I'm making it a setting.
// @note {10} This setting is used to create a RegExp so certain characters need to be escaped
interpolation: {
start: '\\${',
end: '}'
},
}
`
for other predefined languages see the defined languages
`js
import parser from 'docs-parser'
import fs from 'fs-extra-promisify'
parser({ files: 'app/*/' })
.then((data) => fs.outputJson('docs/docs.json', data))
`
documentation for it is coming soon (if your curious just look at src/annotations/*)
Note: the comments below are using the comment defaults which are slashes please see defined languages for other language specific comment styles
`scss`
////
/// @author Tyler Benton
/// @page functions/numbers
/// @description Useful number functions
////
`scss`
/// @author Tyler Benton
/// @page functions/numbers
/// @description
/// This function does something awesome, I swear.
@function some-function(){
// ...
}
`scss`
/// @name happypanda
/// @type {object}
const happypanda = {
smile() { ///# @property {function} happypanda.smile - This makes the panda smile
return 'smile'
},
}
html
``
[sass-doc]: https://github.com/SassDoc/sassdoc
[js-doc]: https://github.com/jsdoc3/jsdoc
[java-doc]: http://www.oracle.com/technetwork/java/javase/documentation/index-jsp-135444.html
[jazzy]: https://github.com/realm/jazzy
[styledocco]: https://github.com/jashkenas/docco
[kss]: https://github.com/kneath/kss
[hologram]: https://github.com/trulia/hologram
[dss]: https://github.com/DSSWG/DSS
[npm-url]: https://www.npmjs.com/package/cameleon
[npm-image]: https://nodei.co/npm/cameleon.png?downloads=true
[travis-url]: https://travis-ci.org/tjbenton/docs?branch=master
[travis-image]: https://travis-ci.org/tjbenton/docs.svg?style=flat-square
[license-image]: http://img.shields.io/npm/l/sassdoc.svg?style=flat-square
[license-url]: LICENSE.md