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:
Builds the updated docs.
Customizes the config.
Commits the changes to the documentation branch
gh-pages.Publishes the updated docs on GitHub pages.
Viewing Locally
To view the site locally run:
forge doc --build --serve --port=4000This 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
.ymlfile at.github/workflows/deployGitHubPages.yml
GitHub Pages Repo Settings
The branch gh-pages is created by the Actions workflow, so this step can only be completed after the Action has run successfully for the first time.

Last updated