public
Description: JavaScript inline documentation parser
Homepage: http://pdoc.org
Clone URL: git://github.com/tobie/pdoc.git
samleb (author)
Wed Oct 21 18:12:46 -0700 2009
commit  dfc3284f2e24aef5215c927a1f2bcb36759b3029
tree    1a713e3a247916b2b82414b356f4af9fe6c2f33b
parent  02f837ed864babdf39f976471d80eef78d7c47c0
pdoc /
name age message
file .gitignore Mon Nov 17 05:16:35 -0800 2008 Adding gemspec file. [jcoglan]
file CHANGELOG Wed Sep 02 06:25:44 -0700 2009 Prefer Maruku over RDiscount. [tobie]
file LICENSE Mon Apr 07 17:46:28 -0700 2008 Moving exported PDoc to git (yes, I know, that'... [tobie]
directory PDoc.tmbundle/ Mon Apr 28 13:05:25 -0700 2008 Added experimental macros for expanding and col... [savetheclocktower]
file README.markdown Wed Sep 02 06:25:44 -0700 2009 Prefer Maruku over RDiscount. [tobie]
file Rakefile Mon Apr 14 16:46:11 -0700 2008 Log info to Terminal. [tobie]
directory bin/ Tue Mar 17 07:02:29 -0700 2009 Make sure the Website generator makes pages for... [jcoglan]
directory lib/ Loading commit data...
directory output/ Sat Apr 12 20:01:34 -0700 2008 Major overhaul of the API docs template. Tested... [savetheclocktower]
file pdoc.gemspec Sat Oct 10 03:43:02 -0700 2009 Update version in gemspec. [jcoglan]
directory templates/ Tue Aug 25 11:47:14 -0700 2009 Update defautl templates. [tobie]
directory test/
directory vendor/ Wed Sep 16 01:22:37 -0700 2009 Add albino.rb, a wrapper for pygments written b... [tobie]
directory website/ Wed Sep 02 06:25:44 -0700 2009 Prefer Maruku over RDiscount. [tobie]
README.markdown

PDoc

PDoc is an inline comment parser and JavaScript documentation generator written in Ruby. It is designed for documenting Prototype and Prototype-based libraries.

PDoc uses Treetop, a Ruby-based DSL for text parsing and interpretation, and its own ActionView-inspired, ERB-based templating system for HTML generation. Other documentation generators (e.g., DocBook XML) are planned.

Unlike other inline-doc parsers, PDoc does not rely on the JavaScript source code at all; it only parses the comments. This approach, though slightly more verbose, is much better at generating consistent, reliable documentation, and avoids the headaches encountered when documenting highly dynamic languages.

Installation

PDoc depends on Rake, Maruku, and treetop, all of which can be obtained through RubyGems:

gem install rake maruku treetop

Maruku is a more solid alternative to BlueCloth and is compatible with Ruby 1.9.1.

Usage

For hints on how to run PDoc on the command line, consult the built-in Rake tasks (in Rakefile) and the PDoc::Runner class (in lib/pdoc/runner.rb).

How it works

The process of turning inline PDoc comments into a human-friendly document has two phases.

Parsing phase

In this phase, the source files are scanned for PDoc comments, then parsed with the Ruby files generated from the Treetop language grammar. The product of this phase is a tree full of specialized classes, all of which inherit from Treetop::Runtime::SyntaxNode.

The root of the tree is an instance of Documentation::Doc. It comprises one or more instances of Documentation::Section; which in turn comprise language elements like namespaces, classes, constants, etc., all of which have class representations.

Rendering phase

Next, PDoc asks a generator how to translate this abstract tree into a hierarchical document. The default generator outputs organized HTML in a manner similar to RDoc's.

The HTML generator (PDoc::Generators::Html) has associated templates (in the templates directory) that accept syntax nodes and echo their metadata onto the page using ERB. Templates are modular, so it's quite easy to apply a custom "skin" to one's documentation pages.

Furthermore, generators themselves are modular; PDoc can, theoretically, parse once and render to several different targets (HTML, DocBook XML, CHM, PDF, even ScriptDoc.) We hope many such generators will exist in the future.