atomdoc
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -8,3 +8,2 @@ (function() { | ||
this.visibility = 'Private'; | ||
this.sections = []; | ||
} | ||
@@ -32,13 +31,2 @@ | ||
Doc.prototype.toJSON = function() { | ||
return { | ||
visibility: this.visibility, | ||
summary: this.summary, | ||
description: this.description, | ||
sections: this.sections, | ||
delegation: this.delegation, | ||
returnValues: this.returnValues | ||
}; | ||
}; | ||
return Doc; | ||
@@ -45,0 +33,0 @@ |
{ | ||
"name": "atomdoc", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "A atomdoc parser", | ||
@@ -5,0 +5,0 @@ "main": "./lib/atomdoc.js", |
168
README.md
@@ -5,6 +5,4 @@ # AtomDoc parser | ||
## REALLY EXPERIMENTAL | ||
Atomdoc is a code documentation format based on markdown. The atom team writes a lot of markdown, and its rules are our deep in our brains. So rather than adopt some other format we'd need to learn, we decided to build a parser around a few markdown conventions. | ||
Like really really experimental. __Do not use__ for now. The doc format and output will change without warning! This project might go away altogether. | ||
## Usage | ||
@@ -24,2 +22,26 @@ | ||
docString = """ | ||
Public: My awesome method that does stuff, but returns nothing and has | ||
no arguments. | ||
""" | ||
doc = AtomDoc.parse(docString) | ||
``` | ||
`doc` will be an object: | ||
```coffee | ||
{ | ||
"visibility": "Public", | ||
"description": "My awesome method that does stuff, but returns nothing and has\nno arguments.", | ||
"summary": "My awesome method that does stuff, but returns nothing and has\nno arguments." | ||
} | ||
``` | ||
### Maximal example | ||
Using all the features. | ||
```coffee | ||
AtomDoc = require 'atomdoc' | ||
docString = """ | ||
Public: My awesome method that does stuff. | ||
@@ -31,4 +53,4 @@ | ||
* `count` An {Int} representing count | ||
* `callback` A {Function} that will be called when finished | ||
* `count` {Number} representing count | ||
* `callback` {Function} that will be called when finished | ||
* `options` Options {Object} passed to your callback with the options: | ||
@@ -40,7 +62,9 @@ * `someOption` A {Bool} | ||
The events section can have a description if you like. | ||
### contents-modified | ||
* `contents-modified` Fired when this thing happens. | ||
* `options` An options hash | ||
Public: Fired when this thing happens. | ||
* `options` {Object} An options hash | ||
* `someOption` {Object} An options hash | ||
## Examples | ||
@@ -55,3 +79,6 @@ | ||
Returns a {Bool}; true when it does the thing | ||
Returns null in some case | ||
Returns an {Object} with the keys: | ||
* `someBool` a {Boolean} | ||
* `someNumber` a {Number} | ||
""" | ||
@@ -69,53 +96,68 @@ doc = AtomDoc.parse(docString) | ||
My awesome method that does stuff. | ||
It does things and stuff and even more things, this is the description. The | ||
next section is the arguments. They can be nested. Useful for explaining the | ||
arguments passed to any callbacks. | ||
""" | ||
"sections": [{ | ||
"type": "arguments", | ||
"description": "", | ||
"arguments": [{ | ||
""", | ||
"arguments": [ | ||
{ | ||
"name": "count", | ||
"description": "An {Int} representing count", | ||
"type": "Int" | ||
"description": "{Number} representing count", | ||
"type": "Number", | ||
"isOptional": false | ||
}, | ||
{ | ||
"name": "callback" | ||
"description": "A {Function} that will be called when finished" | ||
"type": "Function" | ||
"arguments": [{ | ||
"name": "options" | ||
"description": "Options {Object} passed to your callback with the options:" | ||
"type": "Object" | ||
"arguments": [{ | ||
"name": "someOption", | ||
"description": "A {Bool}", | ||
"type": "Bool" | ||
}, | ||
"children": [ | ||
{ | ||
"name": "anotherOption", | ||
"description": "Another {Bool}", | ||
"type": "Bool" | ||
}] | ||
}] | ||
}] | ||
}, | ||
{ | ||
"type": "events", | ||
"description": "The events section can have a description if you like.", | ||
"events": [{ | ||
"name": "contents-modified" | ||
"description": "Fired when this thing happens." | ||
"type": null | ||
"arguments": [{ | ||
"name": "options", | ||
"description": "An options hash", | ||
"type": null | ||
}] | ||
}] | ||
}, | ||
{ | ||
"type": "examples", | ||
"examples": [{ | ||
"name": "options", | ||
"description": "Options {Object} passed to your callback with the options:", | ||
"type": "Object", | ||
"isOptional": false | ||
"children": [ | ||
{ | ||
"name": "someOption", | ||
"description": "A {Bool}", | ||
"type": "Bool", | ||
"isOptional": false | ||
}, | ||
{ | ||
"name": "anotherOption", | ||
"description": "Another {Bool}", | ||
"type": "Bool", | ||
"isOptional": false | ||
} | ||
], | ||
} | ||
], | ||
"name": "callback", | ||
"description": "{Function} that will be called when finished", | ||
"type": "Function", | ||
"isOptional": false | ||
} | ||
], | ||
"events": [ | ||
{ | ||
"name": "contents-modified", | ||
"summary": "Fired when this thing happens.", | ||
"description": "Fired when this thing happens.", | ||
"visibility": "Public", | ||
"arguments": [ | ||
{ | ||
"children": [ | ||
{ | ||
"name": "someOption", | ||
"description": "{Object} An options hash", | ||
"type": "Object", | ||
"isOptional": false | ||
} | ||
], | ||
"name": "options", | ||
"description": "{Object} An options hash", | ||
"type": "Object", | ||
"isOptional": false | ||
} | ||
] | ||
} | ||
], | ||
"examples": [ | ||
{ | ||
"description": "This is an example. It can have a description", | ||
@@ -125,11 +167,19 @@ "lang": "coffee", | ||
"raw": "```coffee\nmyMethod 20, ({someOption, anotherOption}) ->\n console.log someOption, anotherOption\n```" | ||
}] | ||
}], | ||
"returnValues": [{ | ||
"type": "Bool", | ||
"description": "Returns a {Bool}; true when it does the thing" | ||
}] | ||
} | ||
], | ||
"returnValues": [ | ||
{ | ||
"type": null, | ||
"description": "Returns null in some case" | ||
}, | ||
{ | ||
"type": "Object", | ||
"description": "Returns an {Object} with the keys:\n\n* `someBool` a {Boolean}\n* `someNumber` a {Number}" | ||
} | ||
] | ||
} | ||
``` | ||
## Notes | ||
The parser uses [marked]'s lexer. | ||
@@ -136,0 +186,0 @@ |
23731
182
514