2012-01-10 16:11:35 +00:00
|
|
|
# J Literate Programming
|
|
|
|
|
2015-05-13 01:30:23 +00:00
|
|
|
* [Source](https://git.jdb-labs.com/jdb-labs/jlp)
|
|
|
|
* [Annotated Source and Documentation](https://doc.jdb-labs.com/jlp/current/)
|
|
|
|
|
2012-01-10 16:11:35 +00:00
|
|
|
## Overview
|
2011-12-27 18:02:45 +00:00
|
|
|
*Jonathan's Literate Programming* is my take on literate programming.
|
2011-08-22 20:54:38 +00:00
|
|
|
This project grew out of a desire for a documentation system that:
|
|
|
|
|
2011-08-25 12:13:39 +00:00
|
|
|
* generates all documentation from source-code comments,
|
|
|
|
* is capable of facilitating both JavaDoc-style API documentation as well as
|
|
|
|
literate programming style of documentation,
|
|
|
|
* has pluggable formatting (default to Markdown),
|
|
|
|
|
2011-12-27 18:02:45 +00:00
|
|
|
It is inspired by Donald Knuth's concept of literate programming, as well as
|
|
|
|
the Docco system. I wanted something that provided the readability of Docco
|
|
|
|
but was more full-featured. To that end, JLP currently features:
|
|
|
|
|
|
|
|
* *Documentation alongside code, distinct from normal comments.*
|
|
|
|
|
|
|
|
JLP uses a javadoc-like extra delimiter to seperate normal comments from
|
|
|
|
JLP comments.
|
|
|
|
|
|
|
|
* *Support for multiple languages out of the box.*
|
|
|
|
|
|
|
|
JLP allows you to define custom comment delimiters for any language that
|
|
|
|
supports single-line or multi-line comments. It comes configured with
|
|
|
|
default settings for several languages. Ultimately I hope to cover most
|
|
|
|
of the common programming languages.
|
|
|
|
|
|
|
|
* *Syntax highligting.*
|
|
|
|
|
|
|
|
All code blocks will be highlighted according to the language they are
|
|
|
|
written in.
|
|
|
|
|
2012-01-03 23:04:01 +00:00
|
|
|
This project is in its infancy and some of the larger goals are still unmet:
|
|
|
|
|
2011-12-27 18:02:45 +00:00
|
|
|
* *Code awareness.*
|
|
|
|
|
|
|
|
JLP will understand the code it is processing. This will require building
|
|
|
|
a parser for each supported language. By doing so JLP will be able to
|
|
|
|
generate javadoc-style API documentation intelligently, and allow the
|
|
|
|
author to reference code features in a native way (think javadoc @link
|
|
|
|
but more generic).
|
|
|
|
|
|
|
|
* *Documentation Directives*
|
|
|
|
|
|
|
|
Generally I want documentation to conform to code, not code to
|
|
|
|
documentation, but I think some processing directives to JLP (how to
|
|
|
|
combine several files into one, or split one in to many for example)
|
|
|
|
would be useful.
|
|
|
|
|
|
|
|
In the same line of thought, it would be usefull to be able to switch
|
|
|
|
the presentation layer of the documentation system depending on the type
|
|
|
|
of file being displayed. For example, interface definitions and core
|
|
|
|
pieces of the API may work better with a side-by-side layout whereas
|
|
|
|
implementation details may work better in an interleaved layout.
|
|
|
|
JLP processing directives would allow the author to specify which is
|
|
|
|
intended on a file (or block?) level.
|
|
|
|
|
2012-01-10 16:11:35 +00:00
|
|
|
## Project Architecture
|
2011-12-27 18:02:45 +00:00
|
|
|
|
2015-05-13 01:30:23 +00:00
|
|
|
JLP processes it's own documentation. The latest documentation is available at
|
|
|
|
https://doc.jdb-labs.com/jlp/current/
|
2013-08-13 17:02:09 +00:00
|
|
|
|
|
|
|
Below are some starting points.
|
|
|
|
|
2012-01-10 16:11:35 +00:00
|
|
|
### Control and Flow
|
2011-12-27 18:02:45 +00:00
|
|
|
|
2015-05-13 01:30:23 +00:00
|
|
|
* [JLPMain](https://doc.jdb-labs.com/jlp/current/src/main/groovy/com/jdblabs/jlp/JLPMain.groovy.html)
|
2011-12-27 18:02:45 +00:00
|
|
|
|
|
|
|
The entry point to the JLP executable. Parses the command line input and
|
|
|
|
sets up the processor.
|
|
|
|
|
2015-05-13 01:30:23 +00:00
|
|
|
* [Processor](https://doc.jdb-labs.com/jlp/current/src/main/groovy/com/jdblabs/jlp/Processor.groovy.html)
|
2011-12-27 18:02:45 +00:00
|
|
|
|
|
|
|
The Processor processes one batch of input files to create a set of output files.
|
|
|
|
It holds the intermediate state needed by the generators and coordinates the
|
2012-01-03 23:04:01 +00:00
|
|
|
work of the parsers and generators for each of the input files. This
|
|
|
|
processor only generates HTML documentation and will likely be renamed in
|
|
|
|
the future to reflect this.
|
|
|
|
|
2015-05-13 01:30:23 +00:00
|
|
|
* [JLPBaseGenerator](https://doc.jdb-labs.com/jlp/current/src/main/groovy/com/jdblabs/jlp/JLPBaseGenerator.groovy.html)
|
2012-01-03 23:04:01 +00:00
|
|
|
|
|
|
|
The Generator processes one input file. It parses the AST for the input file
|
|
|
|
and emits the final documentation for the file. JLPBaseGenerator
|
|
|
|
implementations are expected to be tightly coupled to Processor
|
|
|
|
implementations.
|
|
|
|
|
2015-05-13 01:30:23 +00:00
|
|
|
* [LiterateMarkdownGenerator](https://doc.jdb-labs.com/jlp/current/src/main/groovy/com/jdblabs/jlp/LiterateMarkdownGenerator.groovy.html)
|
2012-01-03 23:04:01 +00:00
|
|
|
|
|
|
|
This implemetation of JLPBaseGenerator generates literate-style
|
2013-08-13 16:30:59 +00:00
|
|
|
documentation (as opposed to API-style), using
|
|
|
|
[Markdown](http://daringfireball.net/projects/markdown/) to format the
|
2012-01-03 23:04:01 +00:00
|
|
|
documentation blocks.
|
|
|
|
|
2012-01-10 16:11:35 +00:00
|
|
|
### Parsing
|
2011-12-27 18:02:45 +00:00
|
|
|
|
2015-05-13 01:30:23 +00:00
|
|
|
* [JLPParser](https://doc.jdb-labs.com/jlp/current/src/main/groovy/com/jdblabs/jlp/JLPParser.groovy.html)
|
2011-12-27 18:02:45 +00:00
|
|
|
|
|
|
|
A very simple interface for parsing JLP input.
|
|
|
|
|
2015-05-13 01:30:23 +00:00
|
|
|
* [JLPPegParser](https://doc.jdb-labs.com/jlp/current/src/main/groovy/com/jdblabs/jlp/JLPPegParser.groovy.html)
|
2012-01-03 23:04:01 +00:00
|
|
|
|
2013-08-13 16:30:59 +00:00
|
|
|
A [PEG parser](http://en.wikipedia.org/wiki/Parsing_expression_grammar)
|
|
|
|
implemented using the [parboiled](http://www.parboiled.org) library. This
|
|
|
|
is the default source code parser. It is able to parse JLP documentation
|
|
|
|
but leaves code unparsed. It can be parameterized to fit the differing
|
|
|
|
documentation styles of source languages.
|
2012-01-03 23:04:01 +00:00
|
|
|
|
2012-01-10 16:11:35 +00:00
|
|
|
### Abstract Syntax Tree
|
2011-12-27 18:02:45 +00:00
|
|
|
|
2015-05-13 01:30:23 +00:00
|
|
|
* [SourceFile](https://doc.jdb-labs.com/jlp/current/src/main/groovy/com/jdblabs/jlp/JLPPegParserSourceFile.groovy.html)
|
2011-12-27 18:02:45 +00:00
|
|
|
|
|
|
|
The top-level AST element. This represents a source file.
|