Skip to content

Writing and generating documentation

Sam Estep edited this page Feb 1, 2022 · 12 revisions

Documenting typescript

We use typedoc. To generate docs locally, run in penrose-web:

  • typedoc --mode modules --out docs src --includeDeclarations --ignoreCompilerErrors --exclude "**/*__*/**" --exclude "**/*.test.tsx" --exclude "**/node_modules/**"
  • npx serve docs

Docs are auto-served here by GitHub Actions on every push to master.

  • TODO: We should have an npm run docs command too.

Documenting Penrose using Haddock

Penrose uses haddock to automatically generate documentation. We follow Haddock's specific markup language when documenting our code. Here is a nice cheat sheet to keep around when writing haddock comments.

Generating HTML Documentation Site

  • If you use cabal:
cabal haddock --hyperlink-source --executables
              --html-location='http://hackage.haskell.org/package/penrose/docs'
              --haddock-options=--no-print-missing-docs
  • If you use stack: Note that you have to make sure src is clean and in sync with upstream because it will parse all .hs files in src even if they are untracked. You can run the following command or execute script/mkdoc.sh
stack exec -- haddock --html src/*.hs  --hyperlinked-source --odir=dist/docs
  • After the generation, haddock would report a path to index.html of the documentation site relative to TOP
  • By default, all top-level functions will appear in the documentation page. Adding {-# OPTIONS_HADDOCK prune #-} will hide undocumented ones and only show documented ones.
Clone this wiki locally