For node.js modules, the yuidoc.json semantics look strikingly familiar to package.json:
{
"name": "The Foo API",
"description": "The Foo API: a library for doing X, Y, and Z",
"version": "1.2.1",
"url": "http://example.com/",
}
All of these properties are valid in package.json files and in fact are semantically the exact same values (if you are generating docs for the same code-level).
I propose that yuidocs could look for a package.json file and extract the following properties from it:
- name
- description
- version
- url
- logo
For options
I propose those be specified on a yuidoc
property in package.json. So, a sample package.json that yuidoc could parse might look like:
{
"name" : "mkdirp",
"description" : "Recursively mkdir, like `mkdir -p`",
"version" : "0.3.2",
"author" : "James Halliday <[email protected]> (http://substack.net)",
"main" : "./index",
"keywords" : [
"mkdir",
"directory"
],
"repository" : {
"type" : "git",
"url" : "http://github.com/substack/node-mkdirp.git"
},
"scripts" : {
"test" : "tap test/*.js"
},
"devDependencies" : {
"tap" : "~0.2.4"
},
"license" : "MIT/X11",
"engines": { "node": "*" },
"yuidoc": {
"linkNatives": "true",
"paths": "index.js",
"outdir": "docs"
}
}
If you wanted to future-proof this for additional config, you could amend the yuidoc
property to look more like:
...
"yuidoc": {
"url": "http://someurl",
"options": {
"linkNatives": "true"
}
}
...
In this case the yuidoc.url
would override top level url
property (if one existed).
The net benefit of parsing package.json would be one less config file in you project root, less redundancy of name/version/description (you don't have to remember to update it in so many places), and a little more friendliness with node.js (and indeed other communities that use package.json, like jQuery plugins are slated to do).