Browse Source

add install and basic usage to readme

formatter
Brett Langdon 11 years ago
parent
commit
d0b37e439f
1 changed files with 51 additions and 1 deletions
  1. +51
    -1
      README.md

+ 51
- 1
README.md View File

@ -3,4 +3,54 @@ DocAST
[![Build Status](https://travis-ci.org/brettlangdon/docast.svg?branch=master)](https://travis-ci.org/brettlangdon/docast)
Documentation generator for JS via AST parsing.
DocAST is tool to help parse docs strings + additional properties from your
javascript source code.
## Install
### NPM
```bash
npm install docast
```
### git
```bash
git clone git://github.com/brettlangdon/docast.git
cd ./docast
npm install
```
## Basic Usage
The below example shows how you can use DocAST to parse documentation data from
your javascript source code.
### example.js
```javascript
/*
* This function is super cool and does all sorts of cool stuffs
*/
function some(cool, stuff){
if(typeof cool === undefined || typeof stuff === undefined){
throw new Exception('must provide "cool" or "stuff" parameter');
}
if(cool > stuff){
return stuff;
} else if(stuff > cool){
return cool;
} else {
return null;
};
}
```
### Usage
```javascript
var docast = require('docast');
var comments = docast.parse('./example.js');
// this is the result
comments = [ { name: 'some',
params: [ 'cool', 'stuff' ],
returns: [ 'stuff', 'cool', null ],
raises: [ 'Exception' ],
doc: ' This function is super cool and does all sorts of cool stuffs\n ' } ]
```

Loading…
Cancel
Save