• Stars
    star
    109
  • Rank 308,659 (Top 7 %)
  • Language
    Ruby
  • License
    Other
  • Created about 16 years ago
  • Updated over 9 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

JavaScript inline documentation parser

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, your choice of markdown parser, 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.

More Repositories

1

ua-parser

A multi-language port of Browserscope's user agent parser.
Perl
1,975
star
2

specref

An open-source, community-maintained database of Web standards & related references.
JavaScript
156
star
3

Evidence

JavaScript unit testing
JavaScript
87
star
4

modulr-node

Resolves and concatenates CommonJS module dependencies for use in the browser.
JavaScript
59
star
5

unittest_js

Ruby
35
star
6

pr-preview

Adds preview and diff to spec pull requests.
JavaScript
31
star
7

helvetictoc

A time-full tribute to a timeless typeface
JavaScript
14
star
8

modulr

A CommonJS module implementation in Ruby for client-side JavaScript
Ruby
12
star
9

module-grapher

Node library for resolving and graphing Common JS module dependencies.
JavaScript
11
star
10

async-it

Generic asynchronous iterators for node.js.
JavaScript
6
star
11

snippety

A collection of snippets for TextExpander
4
star
12

specs-on-github

This document simply describes how to use GitHub for spec work.
HTML
4
star
13

simple-github

A simple, request-inspired and promise-based wrapper around GitHub's API for node.js.
JavaScript
3
star
14

respec-issues

A small utility to turn ReSpec issues into GitHub issues and link these together via the data-number attribute.
JavaScript
3
star
15

unittest_js_caja_builder

JavaScript
3
star
16

2CV

JavaScript
2
star
17

w3c-testing-plan

Plan proposal for testing the Open Web Platform
2
star
18

datacanvas-viz

Quick d3.js-based visualization for the datacanvas project.
2
star
19

async-memoizer

A memoizer for asynchronous methods obeying node.js conventions.
JavaScript
2
star
20

node-evidence-gatherer

JavaScript
2
star
21

visit

Visits a URL using phantomjs, loads the page, runs the CJS scripts and collects the results.
JavaScript
2
star
22

respec-example

2
star
23

webidl-grammar-post-processor

WebIDL grammar post-processor
JavaScript
2
star
24

fncmp

Just function composition for JavaScript.
JavaScript
1
star
25

feedme

An irc bot that react to people's hunger by posting quotes in french.
JavaScript
1
star
26

smart-library

Joyent Smart Platform JavaScript Library
JavaScript
1
star
27

ORIENTATIONLOCK-UCR

Use cases and requirements for orientation lock in Web applications
1
star