Home

Awesome

elm-doc

Generate static documentation of your Elm application project.

Requires Python >= 3.6, rsync >= 2.6.7, and macOS or Linux. It may work on Windows but it's untested.

Supported Elm versions:

Usage

Simplest invocation:

$ elm-doc . --output docs --fake-license 'SPDX license name'

The license name is required because elm-doc uses the official Elm binary to validate and generate docs; the official Elm binary only generates docs for a package project, and a package project requires a license to be set. While the license name will not be part of the generated doc, it will be associated with the project in the temporary elm.json file elm-doc generates during the build / validation.

Do no use elm-doc if you'd rather not risk the legal consequences of this fact. (IANAL: my understanding is OSS license doesn't take effect unless you distribute the code it's attached to.)

To view the generated docs, you'll need an HTTP server that can detect mimetypes based on file contents, rather than file extensions.

I personally use spark:

$ (cd doc && ~/go/bin/spark)

You can specify other attributes of the project with --fake-user, --fake-project, and --fake-version.

elm-doc creates a build directory named .elm-doc at the root of the project. You may want to ignore it in your SCM config, or you can change its path with --build-dir.

--validate can check if you have all the necessary documentation in place:

$ elm-doc . \
    --elm-path ./node_modules/.bin/elm \
    --validate

elm-doc assumes you're working on an app, not a package; it will try to generate documentation for all modules found in the application source directories.

You can --exclude-modules by using fnmatch patterns:

$ elm-doc . --output docs --fake-license 'SPDX license name' \
    --exclude-modules '*.Private.*,Blacklist.*'

or --exclude-source-directories entirely:

$ elm-doc . --output docs --fake-license 'SPDX license name' \
    --exclude-source-directories generated

You can also specify which files and directories to include in the list of modules:

$ elm-doc . --output docs \
    src/Whitelist src/Main.elm

Note that the --exclude flag takes no effect if you explicitly specify which files to include, unless you add the --force-exclusion flag:

$ elm-doc . --output docs --fake-license 'SPDX license name' \
    --exclude-modules '*.Private.*,Blacklist.*' \
    --force-exclusion \
    src/Whitelist src/Main.elm

For a full list of options, see:

$ elm-doc --help

Installation

In a Python (>=3.6) virtualenv or globally:

$ pip install --upgrade pip setuptools
$ pip install elm-doc

How it works

This is the rough build process:

Development

Running tests:

$ nix-shell
$ poetry install
$ poetry run tox -e py36,...

Updating the prebuilt frontend code and test fixture:

$ poetry run doit