\( \DeclareMathOperator{\tr}{tr} \newcommand\D{\mathrm{d}} \newcommand\E{\mathrm{e}} \newcommand\I{\mathrm{i}} \newcommand\bigOh{\mathcal{O}} \newcommand{\cat}[1]{\mathbf{#1}} \newcommand\curl{\vec{\nabla}\times} \newcommand{\CC}{\mathbb{C}} \newcommand{\NN}{\mathbb{N}} \newcommand{\QQ}{\mathbb{Q}} \newcommand{\RR}{\mathbb{R}} \newcommand{\ZZ}{\mathbb{Z}} % For +---- metric \newcommand{\BDpos}{} \newcommand{\BDneg}{-} \newcommand{\BDposs}{\phantom{-}} \newcommand{\BDnegg}{-} \newcommand{\BDplus}{+} \newcommand{\BDminus}{-} % For -+++ metric \newcommand{\BDpos}{-} \newcommand{\BDposs}{-} \newcommand{\BDneg}{} \newcommand{\BDnegg}{\phantom{-}} \newcommand{\BDplus}{-} \newcommand{\BDminus}{+} \)
UP | HOME

Documentation Generator

Table of Contents

1. Introduction

The idea of documentation generators seem to date back to 1995 with Javadoc.

The basic idea is that "special" comments will generate HTML (or PDF or…) documentation files when processed by a documentation generator.

Originally, Javadoc was motivated by placing this documentation on the "World Wide Web". Therefore, using HTML in the comments was an obvious design decision.

However, it seems we now realize…that's not the best idea. The general consensus appears to have rallied around using Markdown for the documentation comments.

In short, the basic ingredients:

  • Some way to demarcate a comment as a documentation comment. Javadoc uses /** ... */, and this seems to be a common convention.
  • A choice of markup for the content of the documentation comment. This is usually some flavor of Markdown, but Javadoc's shadow looms large even today.
    • Consider how you'll link to other identifiers. I've seen some Markdown systems use [`identifier`] (the identifier surrounded by backticks within square brackets)
  • A program to read a source file, seek out the documentation comments, and determine what it is documenting exactly.

2. Intent for Programs

The intent of a documentation comment is to document the API, the contract for the function (or class or whatever).

It is not literate programming.

It's the quickest way to say to another programmer, "Here's how to use this function."

3. For proof assistants

With proof assistants, the usefulness of documentation comments is to communicate the "subjective substratum" — the informal discussions of motivation, analogies, problems, examples, intuitions, false leads, etc.

This plays a very different role than in a program. But it is very important.

Without these, a proof script lacks "texture" (as linguists would call it): it's just a grocery list of propositions.

4. References and examples

Last Updated: Tue, 5 Nov 2024 09:01:07 -0800