new: Add generated documentation website
📝 Description
This pull request implements a new generated documentation site that is automatically pushed to GitHub Pages.
The below preview URLs can be preview the documentation site in your browser:
- Latest Commit: https://lgarber-akamai.github.io/linode-cli/new/doc-generation/
- Latest Release: https://lgarber-akamai.github.io/linode-cli/latest
Rendering
This PR uses Sphinx with the Read the Docs theme to render documentation. The Sphinx configuration and all relevant static files are stored under the docs directory.
Command Documentation Generation
Due to the complexity and abundance of CLI commands, the logic to generate documentation pages for CLI commands is located in the linodecli/documentation directory.
The linodecli/documentation/templates directory contains various Jinja2 templates which are dynamically rendered using the structures defined in linodecli/documentation/template_data.py.
CLI documentation pages are rendered to a user-defined directory when linode-cli generate-docs is called. This is an indirect dependency of the make generate-docs target, which will automatically render the command documentation into the docs/_generated directory before executing any Sphinx commands.
Publishing
To automatically publish the documentation to a publicly available URL, this PR adds a new documentation.yml GitHub Actions workflow file.
This workflow has three jobs:
-
Build the documentation and upload it as an artifact
- This runs on all pushes and PRs.
-
Pull down the built docs from the first step and commit them to the
_documentationbranch- This only runs on releases and pushes to trusted branches (
main,dev) - The
_documentationbranch automatically be created if it does not already exist.- This branch should be manually configured with force-push protections in place.
- GitHub pages should be manually configured to publish from the this branch branch.
- This only runs on releases and pushes to trusted branches (
-
Pull down the built docs from the first step and upload them as a release asset.
- This only runs on releases.
The Documentation Branch
This PR uses a dedicated documentation branch because it allows us to make multiple versions of the documentation available at at time. Additionally, this allows us to manually rebase any sensitive/unwanted documentation details.
This branch stores all relevant versions as subdirectories, with the latest directory and index.html files being updated on-demand by job #2 (mentioned above).
✔️ Testing
The following test steps assume you have pulled down this PR locally and run make install.
Unit Testing
make testunit
Documentation Rendering
- Build the documentation for the Linode CLI locally using the
generate-docstarget:
make generate-docs
-
Ensure the documentation generates successfully.
-
Open the documentation index in your browser:
file:///path/to/my/linode-cli/docs/build/html/index.html
- Ensure all documentation is as expected.
Publishing
- Create a
new/doc-generationbranch on your fork containing the changes from this PR:
git checkout -b new/doc-generation
git push -u fork new/doc-generation
- Ensure the
BuildandCommit to Pages Branchjobs under theBuild Documentationworkflow run successfully under your fork. - Navigate to the Settings -> Pages page of your fork.
- Set the source to
Deploy from a branch, the target branch to the_documentationbranch, and the path to/ (root). - Save your changes and wait for the rendered documentation to become available at
MYGHUSERNAME.github.io/linode-cli/new/doc-generation. - Ensure version in the top-left reflects the latest commit on your
new/doc-generationbranch. - Publish a release pointing at your fork's
new/doc-generationbranch with the formatvX.X.X. - Wait for the release's documentation to become available at
MYGHUSERNAME.github.io/linode-cli/latest. - Ensure the version in the top-left reflects the published version.
📷 Preview
Configuration Page
| Create Command | Update Command |
|---|---|
| View Command | List Command |
|---|---|