website | twitter

Saturday, August 16, 2008

Documentation and Programming Language

A number of major programming languages have its own documentation system. Those variations themselves interest me very much. I picked up some of them and examined.

There are some interesting points to characterize those systems.

  • Text base VS Memory base: A text based documentation system is implemented as just a text formatter. But some are integrated in the language itself, so you can access the documentation in run time. Emacs Lisp is a significant example of Memory based documentation. I think Memory based documentation is more useful though, sometimes Text base is handy because it doesn't need to load a program only for the documentation.
  • Description part and Reference part: A documentation might include a description part, which describes overall goals and functions of a part like a class or a module. In contrast with description part, a reference part describes detail of a particular entity like a function or a variable. A reference part is connected with its source code of definition.

Perl

Perl's documentation is described by POD (Plain Old Documentation). POD is a text based system. It has only description part.

POD is a very simple markup language and it has only enough mechanism to represent traditional UNIX manual style which includes certain sections like NAME, SYNOPSIS, DESCRIPTION, etc.

A POD document is embedded in a Perl program as a comment and the Perl's parser just ignores it. A POD parser just ignores program. POD doesn't use any information from the program source code.

http://search.cpan.org/perldoc?perlpod

Java

JavaDoc is the standard documentation tool for Java. It is a text based and it has both description part and reference part.

JavaDoc parser uses not only comments but also program codes to extract type information and class hierarchy. Even it works if you don't write a comment. Very structured HTML documentation is generated by the tool.

http://java.sun.com/j2se/javadoc/

Emacs Lisp

Emacs Lisp has memory based documentation. And it has only reference part.

Emacs Lisp's documentation is highly integrated with Emacs editor. You can access help document for every functions and variables without external tool.

A documentation is described as a first comment in a function or a variable definition. This comment is parsed by Emacs lisp parser, and shown by help command e.g. M-x describe-function. Help system of Emacs Lisp doesn't have description part, but info manual of Emacs lisp complements overall information.

http://www.gnu.org/software/emacs/emacs-lisp-intro/html_node/defun.html

Python

Python has memory based and text based documentation. And it has description part and reference part.

Basically Python's documentation is same as Lisp's. A documentation is described as a first comment of an entity (module, class, variable, etc...), and parsed by Python parser. You can access the documentation through __doc__ property in run time.

I don't know much about Python. But Python is unique because there seems to be a way to extract documentation by text processing like Java and Perl. I'll learn about it later.

http://www.python.org/dev/peps/pep-0257/

Squeak Smalltalk

Squeak Smalltalk doesn't have documentation system. It is not necessary because the IDE is strong enough. But you can see IDE itself as a memory based documentation system. Class comment is used as a description part, and method comment is used as a reference part. Class browser has mode to hide source code but comment.

1 comment:

 
Creative Commons License
This work is licensed under a Creative Commons Attribution 3.0 Unported License.