xilinus / pdoc forked from tobie/pdoc

JavaScript inline documentation parser

This URL has Read+Write access

commit  ddaffda4bdc19dab104a5d0154f0d7535be0617a
tree    97859f510e879f38b71e89854f27257eefe3bfe7
parent  dd1fee10b1500b190fb9362642986ff4cc46a79e
pdoc /
name age message
file .gitignore Mon Nov 17 05:16:35 -0800 2008 Adding gemspec file. [jcoglan]
file CHANGELOG Loading commit data...
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 Sun Nov 09 15:20:19 -0800 2008 Updated README. [savetheclocktower]
file Rakefile Mon Apr 14 16:46:11 -0700 2008 Log info to Terminal. [tobie]
directory bin/
directory lib/
directory output/ Sat Apr 12 20:01:34 -0700 2008 Major overhaul of the API docs template. Tested... [savetheclocktower]
file pdoc.gemspec Mon Nov 17 06:38:17 -0800 2008 Automate file list generation in gemspec. [jcoglan]
directory templates/ Mon Nov 24 06:33:09 -0800 2008 Making the return values in EBNF expressions li... [jcoglan]
directory test/ Sun Dec 21 14:09:40 -0800 2008 Implemented nested arguments in EBNF syntax. [#... [savetheclocktower]
directory website/ Tue Nov 18 07:43:26 -0800 2008 Add rdoc to website. [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, BlueCloth, and treetop, all of which can be obtained through RubyGems:

gem install rake BlueCloth treetop

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.