From 361cdf081663fcd6a69dd233727d878d1bfe72c8 Mon Sep 17 00:00:00 2001 From: Tobie Langel Date: Thu, 10 Apr 2008 14:09:12 +0200 Subject: [PATCH] Added documentation. --- README.markdown | 225 +---------------------- website/{ => html}/documentation.html | 0 website/{ => html}/images/pdoc.jpg | Bin website/{ => html}/index.html | 6 +- website/{ => html}/stylesheets/main.css | 0 website/{ => html}/stylesheets/reset.css | 0 website/markdown/syntax.markdown | 224 ++++++++++++++++++++++ 7 files changed, 234 insertions(+), 221 deletions(-) rename website/{ => html}/documentation.html (100%) rename website/{ => html}/images/pdoc.jpg (100%) rename website/{ => html}/index.html (59%) rename website/{ => html}/stylesheets/main.css (100%) rename website/{ => html}/stylesheets/reset.css (100%) create mode 100644 website/markdown/syntax.markdown diff --git a/README.markdown b/README.markdown index 3b8751e..223bda0 100644 --- a/README.markdown +++ b/README.markdown @@ -1,224 +1,9 @@ -Documentation -============= +PDoc +==== -Comments --------- +PDoc is an inline comment parser and JavaScript documentation generator written in Ruby. It is designed for documenting [Prototype](http://prototypejs.org) and Prototype-based libraries. -Documentation comments start with `/**` and end with `**/`. Each new line starts with `*`. +PDoc uses [Treetop](http://treetop.rubyforge.org/), a Ruby-based DSL for text parsing and interpretation, and it's own, ActionView-inspired, ERB-based templating system for HTML generation. Other documentation generators (for example, for DocBook XML) are planned. - /** ... - * ... - **/ - -Tags ----- - -The first line of a comment is reserved for tags. Tags are separated by a comma followed by whitespace (", "). They can be either a tag name or a key / value pair separated by a colon and a space (`: `). - -Currently accepted tags are: `deprecated`, `section:`, `alias of:`, `related to:` - - /** deprecated, section: dom, alias of: Element#descendantOf - * Element#childOf(@element, className) -> Element - * ... - **/ - -EBNF ----- - -The lines directly following tags are reserved for the EBNF description of the documented object. Typically, there's only one EBNF per documented object. However, some objects might require more than one. - - /** - * Element#down(@element[, cssSelector][, index]) -> Element | null - * ... - **/ - - /** - * Element#writeAttribute(@element, attribute[, value = true]) -> Element - * Element#writeAttribute(@element, attributes) -> Element - * ... - **/ - -### Arguments - -For all methods, functions, etc. parentheses around the arguments are required even if no arguments are present. -The syntax for arguments is as follows: - -#### required arguments - - /** - * Event.stop(event) -> Event - * ... - **/ - -#### optional arguments - -Optional arguments are surrounded by squared brackets (`[]`). - - /** - * String#evalJSON([sanitize]) -> Object | Array - * ... - **/ - -A default value may be indicated using the equal sign (`=`). - - /** - * String#evalJSON([sanitize = false]) -> Object | Array - * ... - **/ - - -Note that the argument separating comas belong _inside_ the brackets. - - /** - * Event.findElement(event[, cssSelector]) -> Element | null - * ... - **/ - -Arguments can be described below the EBNF description using the following syntax: - - - argumentName (acceptedTypes...): description. - -For example (notice the 4 space indent in the last line): - - /** - * Event.findElement(event[, cssSelector]) -> Element | null - * - event (Event): a native Event instance - * - cssSelector (String): a optional CSS selector which uses - * the same syntax found in regular CSS. - **/ - -### Supported EBNF types - -#### Namespace - - /** - * Ajax - * ... - **/ - - /** - * Prototype.Browser - * ... - **/ - -#### Classes - -Classes require a `class` prefix: - - /** - * class Ajax.Base - * ... - **/ - -Sub-classes can indicate their parent just like in the Ruby syntax: - - /** - * class Ajax.Request < Ajax.Base - * ... - **/ - -Where `Ajax.Base` is the parent class and `Ajax.Request` the subclass. - -Included mixins are indicated like so: - - /** - * class CustomHash - * includes Enumerable, Comparable - **/ - -#### Mixins - -Mixins are indicated by a `mixin` prefix: - - /** - * mixin Enumerable - * ... - **/ - -#### Constructors - -Constructors require the `new` prefix and their arguments. - - /** - * new Element(tagName[, attributes]) - * ... - **/ - - /** - * new Foobar() - * ... - **/ - -#### Klass Methods - -Klass methods are identified by a dot (`.`). - - /** - * Array.from([iterable]) -> Array - * ... - **/ - -#### Instance Methods - -Instance methods are identified by the hash symbol (`#`). - - /** - * Array#first() -> Array element - * ... - **/ - -#### Utilities - -Utilities are global functions starting with a dollar-sign (`$`). - - /** - * $w(string) -> Array - * ... - **/ - -#### Methodized Methods - -Methodized methods are methods which are both available as a class method and an instance method, in which case the first argument becomes the instance object itself. For example, all of `Element`'s instance methods are methodized and thus also available as class methods of `Element`. Methodized methods are indicated by prefixing their first argument with the `@` symbol. - - /** - * Element#hide(@element) -> Element - * ... - **/ - -#### Klass Properties - -Klass properties are identified by a dot (`.`). - - /** - * Ajax.Responders.responders -> Array - * ... - **/ - -#### Instance Properties - -Instance properties are identified by the hash symbol (`#`). - - /** - * Ajax.Response#responseText -> String - * ... - **/ - -#### Constants - -Constant must have their value specified using the equal sign (`=`). - - /** - * Prototype.JSONFilter = /^\/\*-secure-([\s\S]*)\*\/\s*$/ - * ... - **/ - -### Events - -Some methods can fire native or custom events. These are indicated below the arguments descriptions: - - /** - * Ajax.Request#respondToReadyState(readyState) -> undefined - * - readyState (Number): a number from 0 to 4 corresponding to the state of the request. - * fires ajax:created, ajax:completed - **/ +Contrary to other inline documentation parser, PDoc does not rely on the JavaScript source code at all: it only parses the comments. This does imply being slightly more verbose when documenting the source code, but makes for a consistent, readable documentation and avoids the usual issues encountered when documenting highly dynamic languages. diff --git a/website/documentation.html b/website/html/documentation.html similarity index 100% rename from website/documentation.html rename to website/html/documentation.html diff --git a/website/images/pdoc.jpg b/website/html/images/pdoc.jpg similarity index 100% rename from website/images/pdoc.jpg rename to website/html/images/pdoc.jpg diff --git a/website/index.html b/website/html/index.html similarity index 59% rename from website/index.html rename to website/html/index.html index cd3090e..7e9ac91 100644 --- a/website/index.html +++ b/website/html/index.html @@ -26,7 +26,11 @@

PDoc

-

PDoc is a upcoming inline documentation parser for Prototype and Prototype-based libraries.

+

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 it’s own, ActionView-inspired, ERB-based templating system for HTML generation. Other documentation generators (for example, for DocBook XML) are planned.

+ +

Contrary to other inline documentation parser, PDoc does not rely on the JavaScript source code at all: it only parses the comments. This does imply being slightly more verbose when documenting the source code, but makes for a consistent, readable documentation and avoids the usual issues encountered when documenting highly dynamic languages.