Skip to content

Commit

Permalink
Implement basic RequireJSParser.
Browse files Browse the repository at this point in the history
Add partial jasmine spec for RequireJSParser.getDependencies
  • Loading branch information
David Martin committed Aug 3, 2011
1 parent 6f8788e commit 507de08
Show file tree
Hide file tree
Showing 22 changed files with 603 additions and 33 deletions.
6 changes: 6 additions & 0 deletions README.md
Expand Up @@ -58,6 +58,12 @@ CoffeeDoc can be run from the command line:

Generated documentation is saved to the `docs/` folder under the current directory. If you wish to document several modules, make sure you generate all the docs with a single command -- this ensures that they will all appear in the `index.html` file.

### Testing ###

Running the tests require that you have jasmine-node installed. If you've pull the source and installed the package using `npm link`, this will have been downloaded for you. The execute the tests, run the following in the `coffeedoc/` folder:

jasmine-node --coffee test/

### How it works ###

CoffeeDoc uses the CoffeeScript parser to generate a parse tree for the given source files. It then extracts the relevant information from the parse tree: class and function names, class member functions, function argument lists and docstrings.
Expand Down
16 changes: 2 additions & 14 deletions lib/coffeedoc.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

181 changes: 178 additions & 3 deletions lib/parsers.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions package.json
Expand Up @@ -29,5 +29,7 @@
"bin": {
"coffeedoc": "./bin/coffeedoc"
},
"devDependencies": {}
}
"devDependencies": {
"jasmine-node": ">=1.0.6"
}
}
13 changes: 1 addition & 12 deletions src/coffeedoc.coffee
Expand Up @@ -20,7 +20,7 @@ exports.documentModule = (script, parser) ->
AST parsers are defined in the `parsers.coffee` module
###
nodes = getNodes(script)
nodes = parser.getNodes(coffeescript.nodes(script))
first_obj = nodes[0]
if first_obj?.type == 'Comment'
docstring = removeLeadingWhitespace(first_obj.comment)
Expand All @@ -35,17 +35,6 @@ exports.documentModule = (script, parser) ->

return doc

getNodes = (script) ->
###
Generates the AST from coffeescript source code. Adds a 'type' attribute
to each node containing the name of the node's constructor, and returns
the expressions array
###
root_node = coffeescript.nodes(script)
root_node.traverseChildren false, (node) ->
node.type = node.constructor.name
return root_node.expressions

getFullName = (variable) ->
###
Given a variable node, returns its full name
Expand Down

0 comments on commit 507de08

Please sign in to comment.