λ

Example of MGL-PAX Common Lisp Documentation Builder

Table of Contents

[in package EXAMPLE-DOCS/DOCS with nicknames EXAMPLE-DOCS]

This is small library includes a few functions with docstrings and a documentation for the system and all included packages.

The purpose is to demonstrate core features of the MGL-PAX documentation builder.

This repository is part of the https://github.com/cl-doc-systems organization, created to compare different Common Lisp documentation systems.

The goal is make it easier for CL software developers to choose proper documentation system and to improve docs in their software!

Resulting documentation can be viewed here:

https://cl-doc-systems.github.io/mgl-pax/

The repository can be used as a template for new libraries if you've choosen MGL-PAX for documenting your library.

Let's review features, provided by MGL-PAX.

λ

1 Pros & Cons of PAX

λ

1.1 Pros

λ

1.2 Cons

But if you prefer another way, it should be easy to write a function which will collect external symbols and generate a MGL-PAX:SECTION object for them.

λ

2 How to build the documentation

MGL-PAX has a number of ways for generation of the docs. But most probably, you'll need only toplevel helpers described in it's section Generating Documentation.

These helpers is able to generate README and HTML docs for an ASDF system.

This example defines it's own wrapper EXAMPLE-DOCS:BUILD-DOCS:

It is as simple, as:

(defun build-docs ()
  (mgl-pax:update-asdf-system-readmes @index :example)
  
  (mgl-pax:update-asdf-system-html-docs @index :example
                                        :target-dir "docs/build/"))

This function is used by docs/scripts/build.ros file to generate documentation from GitHub Actions. Or can be called from the REPL.

λ

3 Handwritten Documentation

I think the ability to write a large pieces of documentation which aren't bound to a function, class or module is an important feature. This way you can tell the user about some toplevel abstractions and give a bird eye view on the library or system.

For example, handwritten parts of the documentation can provide some code snippets to demonstrate the ways, how to use the library:

(loop repeat 42
      collect (foo "bar" 100500))

And when you are talking about some function or class, you can reference it. For example, if I'm talking about the FOO function, I can reference it like this [example/app:foo][function] and it will appear in the code as the link example/app:foo. In most cases you can omit square brakets and just capitalize symbol name.

Comparing MGL-PAX to Coo (here is it's example project, I'd prefer the PAX, because it's ability to mix handwriten sections with documentation extracted from docstrings.

λ

4 Autogenerated API Reference

There is no magically autogenerated reference API. Idea of PAX is that you write docs manually and reference documented symbols. They are automatically exported and this way you library's external API should be documented.

But if you prefer another way, it should be easy to write a function which will collect external symbols and generate a MGL-PAX:SECTION object for them.

λ

5 Packages

λ

5.1 EXAMPLE/APP Package

[in package EXAMPLE/APP]

This is a test package of our example.

It contains only one function definition:

What is interesting is that we can continue writing code for the section. Interleaving blocks of text with references to the different Lisp entities.

At some moment we can reference objects from other packages. But to make them cross-referenced, we have to mention them in some section. For example, here FOO references EXAMPLE/UTILS:DO-THE-JOB, which is desribed in the EXAMPLE/UTILS Package.

λ

5.2 EXAMPLE/UTILS Package

[in package EXAMPLE/UTILS]