Docs & GitHub Pages

Foundry has a built-in documentation feature that generates an mdbook for all contracts in the src directory. NATSPEC comments are used to populate the content. This can then be built using GitHub Actions and hosted using GitHub pages.

The default configuration is ok, but I've customized it with a GitHub action which on every push to the repo:

  1. Builds the updated docs.

  2. Customizes the config.

  3. Commits the changes to the documentation branch gh-pages.

  4. Publishes the updated docs on GitHub pages.

Viewing Locally

To view the site locally run:

forge doc --build --serve --port=4000
  • This won't have the config customizations made using the GitHub Actions workflow, but it can be useful for local development.

GitHub Actions Workflow

  • Create a workflow .yml file at .github/workflows/deployGitHubPages.yml

Modify:

  • <ADD_TITLE_HERE>

  • <ADD_AUTHOR_HERE>

GitHub Pages Repo Settings

Last updated