docforthΒΆ

Docforth is a pretty-printer for Forth programs.

Docforth works just like any other ANS Forth: you compile and run your program with it. But as it compiles your code, docforth generates the HTML documentation for each source file.

docforth’s aim is to make Forth source easier to understand. Definitions are in bold. Each compiled or interpreted word links back to its definition. ANS Forth words link back to the definition in the standard (this is done using the reference list in To Know Forth).

Some examples:

And of course docforth documents itself.

Download docforth.fs.

docforth is an ANS Forth: the input program must be ANS Forth compatible in order for docforth to compile it. docforth does this in the same way as Only Standard Definitions.

To use docforth, create a file that includes the source code you want to document, say toplevel.fs:

.( Generating documentation )
s" mycode.fs" included
.( Finished documentation generation )

then from your Forth do:

s" docforth.fs" included
s" toplevel.fs" document

docforth will generate the documentation for file mycode.fs in mycode.fs.html, and similarly for every file included by mycode.fs.