Doco is a simple but powerful text-to-web engine.
The Doco Manual
Introduction
Installation
Quick Start Tutorial
Advanced Topic: Styling
Advanced Topic: Table Cell Spanning
Advanced Topic: Variable Substitutions
Advanced Topic: Additional Features
Power Feature: Index Page Generation
Power Feature: Table of Contents
Power Feature: Breadcrumbing
Power Feature: Document Inclusions
Power Feature: Templating
Power Feature: Custom Mappings
Power Feature: Versioning
Power Feature: Snapshotting
Ant Build Integration
Roll Credits..
This manual pertains to release version 0.8, which is available for download here.
You can view this document in sections, as one long page, or in it's source form.
Please aid this project by making support requests and bug reports where necessary.
Producing presentable documentation is mildly uninteresting (strike that), downright boring and often incredibly frustrating.
You've basically got 3 options, in order of user-friendliness.
Or maybe you could try Doco.
It's not aimed at people trying to make amazing-looking websites.
It is aimed at people who need to produce good-looking, highly navigable document sets, quicksmart.
You can use any platform that supports Java J2SE (no, this does not include your phone).
You need be reasonably familiar with your platform's shell.
Environment Variable Name | Value to Set |
---|---|
JAVA_HOME | Where Java was installed to |
PATH | Your original path, plus JAVA_HOME/bin |
Simple, eh?
Note that this guide assumes that a Java 1.4+ JRE is installed, JAVA_HOME is set, and the java executable is in your path (see the installation section). You should also have an open shell (command prompt).
The simplest way to prove to yourself that Doco works in your environment and to learn quickly is to play with a pre-existing project - in this case the Doco manual itself (i.e. the source for the pages you're reading right now).
First get Doco to output the zipped version of its own manual:
java Doco -manual
..this will output a file:
doco_manual.zip
Unzip it (using a tool appropriate to your operating system), then build the HTML version of the manual from the Doco sources using a 'project file' (which tells Doco where to look for sources and where to output the HTML, etc.):
java Doco -dpr doco_manual/doco_manual.dpr
Now point your browser at the locally generated document index.
doco_manual/html/index.html
If you can't see it or it looks funny (it should look like this), please formulate a rude and indignant support request or a bug.
Create a file called basic_cribsheet.txt in the current directory. Paste in the following text.
> Doco Cribsheet (Basic)
Please look at the "source of this document" {basic_cribsheet.txt}.
>> Second Level Heading
Paragraphs are
formatted automatically,
despite line breaks.
>>> Third Level Heading (etc)
+ Relative Heading (+1)
++ Relative Heading (+2)
This is an example of an _italic_ word.
This is an example of _"an italic phrase"_.
This is an example of a *bold* word.
This is an example of *"a bold phrase"*.
This is an example of a --stricken-- word.
This is an example of --"a stricken phrase"--.
This is an example of an +underlined+ word.
This is an example of +"an underlined phrase"+.
?? This is a comment that doesn't appear in the HTML version.
@ This is an example of an unordered list.
@@ List elements can be arbitrarily nested.
@@@ Which is useful.
@ In many circumstances.
# This is an example of an ordered list.
# You can nest these, too. But we did that already.
You can have more than one line per bullet.
This is a single word absolute link to Google {http://www.google.com/}.
This is a phrase link to the "source of this document" {basic_cribsheet.txt}
This is a intra-document link to the "Second Level Heading" {#h2.Second Level Heading}.
Here's an image:
((http://doco.sf.net/style/logo.jpg))
A built in variable is the date, which is Tue Jun 01 14:22:50 BST 2004.
You can reference your own variables, which may or may not be defined: Captain Pugwash.
[ Name | Position | Salary ]
[ Bob | CEO | Massive ]
[ Sue | Secretary, sleeping with Bob | Considerable ]
[ Rita | Secretary, not sleeping with Bob | Pitiful ]
You will find that you need to escape !\{things} sometimes.
Tab preservation works just fine.
ASCII art is old-hat but some people like it.
/-------------- \ data /-------------- \
| Process A |----------->| Process B |
\---------------/ \---------------/
<html> and <xml> tags are not problematic.
Here is an example of styling a single word [red].
Here is an example of "styling a phrase" [blue].
This is an example of a (g)custom mapping(g)
that will expand to a Google search.
Note that bold, italics, strike and underline can be combined if you observe the following markup wrapping precedence from the outside inwards: bold outermost, then italics, then underline, with strike being innermost.
E.g. an emboldened and italicised word must be presented to Doco like *_this_* and NOT like _*this*_.
Great. Now generate the HTML output. We'll do this in the simplest way possible, first.
java Doco -in basic_cribsheet.txt -out basic_cribsheet.html
Point your browser at the output file basic_cribsheet.html.
If you're reasonably observant, you'll notice a few things.
This is what the cribsheet looks like with the Doco CSS.
Download this stylesheet (you can modify it or junk it at your leisure).
Create a directory structure like this (you will need to move the files into the correct place).
quickstart/
source/
basic_cribsheet.txt
style/
default.css
Now run Doco over the hierarchy. This entails using a different mode.
java Doco -from quickstart/source -to quickstart/html
Doco will have generated HTML for all documents in the quickstart/source hierarchy into mirror locations in the quickstart/html directory.
In addition, it has generated you a nice index.html. Take a look at this file in your browser.
quickstart/html/index.html
Now it looks nicer, but the following problems are still present.
To fix these, we need some metadata.
Create a file called quickstart/quickstart.dpr. This is a 'Doco Project File'.
Paste the following text into it.
# Project Information
# -------------------
# The name of the project.
# This will be used by the GUI, eventually.
doco.project.name=Quickstart Cribsheet
# Where the source is.
# This can be a relative or absolute path.
# Relative paths are relative to this document.
doco.project.from=source
# Where to generate documents to.
# This can be a relative or absolute path.
# Relative paths are relative to this document.
doco.project.to=html
# Doco will try to process files with these extensions.
# txt and dsf are processed by default unless overridden.
# doco.sources=dsf,txt
# Doco will generate index files to this filename.
# This is 'index.html' unless overridden.
# doco.index=index.html
# Variables
# ---------
# An example of a custom variable (substitute with (no value for variable 'my.variable'))
# You can define any { key -> value } pair.
# Don't use the prefix 'doco.' - this is reserved for Doco.
my.name=Captain Pugwash
# Custom Mappings
# To make these yourself, you should be reasonably technically minded.
# ---------------
# This converts a "word or phrase" {http://www.google.com/search?q=word or phrase}
# into a www.google.com search.
doco.mapping.(\\s)\\(g\\)(.+?)\\(g\\)=$1"$2"$1{http://www.google.com/search?q=$2}
Now run Doco over this file. The key/value pairs tell it what to do.
java Doco -dpr quickstart/quickstart.dpr
Uh-oh. Nothing happened. Why? Because the source document did not change, Doco sees no reason to regenerate it, that's why. When you end up with a lot of documents you'll appreciate the time saving. Trust me.
You need to modify the quickstart/source/basic_cribsheet.txt file somehow. Meddle with it somehow, save it, run Doco the same way and reload the page in your browser.
You should now be viewing a carbon copy of this.
Since invoking Doco every time you make a change is quite dull, you could always opt to use the daemon mode.
Try this.
java Doco -dpr quickstart/quickstart.dpr -daemon -interval 1
This will cause the process to poll for changes every 1 second.
If you are using Windows then you are unlucky - you will need to open a new MSDOS prompt because this busies your current window indefinitely. UNIX users can of course just put the process in the background.
Make a change to quickstart/source/basic_cribsheet.txt, verify that the daemon output looks like it has done something, then check that the changes havebeen reflected in the HTML output by reloading the page in your browser.
Well done. If you've completed the Quickstart then you know most of Doco's basic features.
Maybe this is as far as you need to go for what you require, but there are a lot more features.
There will be a <link rel.. to style/default.css in every page generated by Doco.
The style directory of each directory in the source hierarchy is inherited by all subdirectories of that directory as mirrored in the output hierarchy. This means you can have disparate style subtrees in the same overall hierarchy.
If you use breadcrumbing, the automatically generated navigational aspects of the page will have a CSS class of navigation.
Also, any blocks that look like this
| some preformatted text
..will be output with a CSS class of raw.
Inlined CSS fragments are also possible by inserting a directive into a document.
// inline style "relative/path/some-style.css" //
..or..
// inline style "/absolute/path/some-style.css" //
..or..
// inline style "http://some.web.location/style.css" //
Note that HREFs for assets used by the CSS are relative to the CSS in the output hierarchy, not to the generated HTML file itself.
You can use any available style class (either in 'default.css' or some inlined CSS) in the normal flow of your document.
Here is an some red text and here is some blue text. And here is a filename.
The above markup looks like this:
Here is an "some red text" [red] and here is "some blue text" [blue].
And here is a filename [code].
Table cell spanning is supported. Note that some rows look the same but have different column spanning schemes (look at the source below it to see what's going on):
Cell 1 | Cell 2 | Cell 3 | Cell 4 |
---|---|---|---|
1 | 2 | 3 | 4 |
1 | 3 | 4 | |
1 | 2 | 4 | |
1 | |||
2 | 4 |
Spanning is achieved with 'extend leftwards' and 'extends rightwards' syntax. Here is the table above's source.
[ Cell 1 | Cell 2 | Cell 3 | Cell 4 ]
[ 1 | 2 | 3 | 4 ]
[ 1 | -> | 3 | 4 ]
[ 1 | 2 | <- | 4 ]
[ 1 | -> | -> | -> ]
[ <- | 2 | -> | 4 ]
It should be obvious that the following rows are not legal, as there is no preceding or following cell to extend:
[ -> | x | x ]
[ x | x | <- ]
You control the look of the table with CSS.
Variables are inserted into your source like this.
My name is $(my.name).
This document last produced on $(doco.date).
Three types of variables can be used in Doco.
Here are the Java variables you can use..
Property | Meaning | Value during this build |
---|---|---|
file.separator | File separator | / |
java.class.path | Java classpath | (too long to show here) |
java.class.version | Java class version number | 48.0 |
java.home | Java installation directory | /usr/java/j2sdk1.4.2_03/jre |
java.vendor | Java vendor-specific string | Sun Microsystems Inc. |
java.vendor.url | Java vendor URL | http://java.sun.com/ |
java.version | Java version number | 1.4.2_03 |
line.separator | Line separator | (a control character) |
os.arch | Operating system architecture | i386 |
os.name | Operating system name | Linux |
os.version | Operating system version | 2.4.22-1.2174.nptlsmp |
path.separator | Path separator (for example, ":") | : |
user.dir | User's current working directory | /home/jd/sourceforge/acmejava-doco/dist |
user.home | User home directory | /home/jd |
user.name | User account name | jd |
Variable | Meaning | Value during this build | Assignation |
---|---|---|---|
doco.date | toString of a new Date object | Tue Jun 01 14:22:50 BST 2004 | Dynamic |
doco.version | The version of Doco used | 0.8 | From doco-variables.properties |
doco.author | The author of Doco | James Dodd (doddjames@yahoo.co.uk) | From doco-variables.properties |
doco.document.version | The version of the document (if versioned) | 0.8 | Dynamic |
doco.document.printable | The name of the printable version of the document (if split into pages) | manual_v0.8_full.html | Dynamic |
These must be placed in your .dpr file and are of the following form.
some.key=some.value
This directive stops Doco from processing the document. This can be useful if your document is in a really a bad way (or extremely immature draft status) and you don't want the output to be viewable yet.
Here is an example of the directive:
// countermand processing (<reason>) //
The <reason> will be output on the console then Doco skips the file that contains this directive.
Doco will automatically place an index page..
index.html
..in each directory it processes for Doco documents. Files of this name that already exist in this directory will be overwritten.
The name of the index file can be altered with an override in your project file.
doco.index=whatever.html
Indexes will not be generated for
Directories containing a .docoignore file will also not appear as subdirectories of parent indexes.
If you place a file with the name
description
..in any given directory, then this is written to the Doco index by way of explanatory text.
The names of your files are automatically and ordered tidied for viewing.
Here is an example index.
A contents section can be inserted anywhere in the document, but of course it's normally best at the top, just after the first heading.
The directive to tell the processor to do this for you is:
// insert automatic index, level <N> //
..where <N> is the depth to which you would like indexing. Anything more than about 5 may suggest an overly-hierarchical document.
You will have noticed a contents section in the first page of this document.
This feature allows you to split the document into chunks, and to navigate forwards, backwards and upwards within it.
The directive used to tell the processor to do this is
// split into pages //
By default (as shown above), Doco will split every section into a separate page. However, it is usual to want breadcrumbing to occur up to a specified level, rather than for all levels.
You do this with an until clause.
// split into pages until level 2 //
Whenever page splitting is enabled, Doco also writes a 'printable' version (i.e. one that is not split into pages) to the file, i.e.
<originalFileName>_full.html
..in the target directory.
You can always reference this file from within the breadcrumbed document using the following variable.
$(doco.document.printable)
Doco has two types of includes - one happens before any Doco markup is parsed, and the other includes directly into the document directly before it's finalized to disk.
Both of them can take relative (to the source document location) and absolute paths.
// include "relative/path/file.txt" before processing //
// include "/absolute/path/Sample.java" before processing and indent //
// include "relative/path/include.html" after processing //
// include "/absolute/path/include.html" after processing //
If the file is not found, an error message is inlined into the document.
*"The file <fileName> does not exist!"*
Doco supports templates, which are really easy to use.
Here are the steps involved in using templates:
Doco does the rest!
Here's an example template.
And here's a document that uses the template.
Since both of these files exist in the Doco manual project, you can view the actual generated result to see what it looks like.
Mappings are defined in your .dpr file.
doco.mapping.<searchExpression>=<replaceExpression>
You need to be reasonably technically minded to be able to understand regex syntax.
Here is an example custom mapping.
# A custom mapping (this is a dictionary.com lookup)
doco.mapping.(\\s)\\(d\\)(.+?)\\(d\\)\\s=$1"$2"$1{http://dictionary.reference.com/search?q=$2}$1
You would use it like this
..which was a nice (d)seque(d) from the previous topic..
While we're about it, you might as well see what segue means (this example uses the same mapping).
Note that the <searchExpression> is subject to some Java Properties loading escaping rules.
It is very likely that you will need to tinker with any custom mapping a few times before you get it working properly.
Doco supports versioning in an unusual but useful way.
To start at the beginning, the directive for versioning is of the form
// version <version> //
..where <version> is completely up to you, e.g. "1.0", "draft" etc.
For the purposes of this explanation, we will assume a document called "func_spec", with a version of "1.0". When a versioned source is processed by Doco, the following things happen:
It is worth noting that if a non-versioned document becomes versioned, any referring pages' links will thenceforce take you to a table of versions rather than the document itself (useful, as the referring document cannot know which version is pertinent to the viewer).
Snapshotting is analagous to petrifying the state of related assets, so that items linked to by your document are effectively frozen in time. This means that if you are including (say) a diagram which you know may change (but your document is pertinent only to what that diagram looks like right now) then you can take a snapshot (copy) and your links will be re-pointed automatically.
Doco does this with the following directive:
// snapshot <pattern> "<codeName>" //
..where <pattern> is a regular expression pattern, and <codeName> is any identifier of your choosing ("alpha", "moses", "2004-10-10" etc.).
An example would be:
// snapshot .*\\.gif "Jan-2004" //
The above directive would snapshot all GIF images with a codename of "Jan-2004".
The <pattern> will partially match against links to other documents, images etc (in fact anything that can be linked to with an HREF). "Partial" matching means that if the linked asset contains the pattern then it's considered a match (rather than requiring an exact match, which would be laborious to enumerate).
The <codeName> is useful as it allows different documents (possibly authored by different people) to share the same frozen assets. Say you and a colleague are working on different technical documentation but you both include a diagram (and that diagram is subject to change, which your documents do not want to reflect). In that case, both of you can agree a codename to use for a certain state of that asset (e.g. "draft", "1.0", "alpha" or some made up funky-sounding name).
There is some behaviour of the snapshotting algorithm that is worth knowing about:
Doco is easily integrated into Ant builds.
<target
name="doco"
description="Documents the Project."
>
<taskdef name="doco"
classname="com.acmejava.doco.DocoAntTask"
classpath="<path_to>/doco-${doco.version).jar"
/>
<doco
dpr="my_project.dpr"
/>
</target>
Thanks to all of the following people who have contributed in one way or another.
If you find Doco useful, please tell us about it.
Company | Business | URL | Usage Profile | Build Integration? |
---|---|---|---|---|
Create Services Ltd | Credit Cards | http://www.createservices.com/ | Technical Documentation | Y |
Trampoline Systems | Collaboration Software | http://www.tramposys.net/ | Technical Documentation | Y |