diff --git a/.github/workflows/test-starter-pack.yml b/.github/workflows/test-sphinx-stack.yml similarity index 85% rename from .github/workflows/test-starter-pack.yml rename to .github/workflows/test-sphinx-stack.yml index e50e4d8f..bfbf5036 100644 --- a/.github/workflows/test-starter-pack.yml +++ b/.github/workflows/test-sphinx-stack.yml @@ -1,7 +1,7 @@ -# This workflow tests the starter pack. -# Don't run this workflow on any repos that use the starter pack. +# This workflow tests the Sphinx Stack. +# Don't run this workflow on any repos that use the Sphinx Stack. -name: Test starter pack +name: Test Sphinx Stack on: push: @@ -10,7 +10,7 @@ on: jobs: test-docs: - name: Test on docs folder + name: Test on docs directory runs-on: ubuntu-latest steps: - name: Check out repo diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c6831f2..cf12b974 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,10 +8,11 @@ * Remove `reuse/` directory * Rename `.sphinx/` directory to `_dev/` * Add default configuration for copyright and license statements +* Remove docs and project-specific configuration ### Changed -* `docs/conf.py` [#562](https://github.com/canonical/sphinx-docs-starter-pack/pull/562), [#576](https://github.com/canonical/sphinx-docs-starter-pack/pull/576), [#590](https://github.com/canonical/sphinx-docs-starter-pack/pull/590), [#598](https://github.com/canonical/sphinx-docs-starter-pack/pull/598) +* `docs/conf.py` [#562](https://github.com/canonical/sphinx-docs-starter-pack/pull/562), [#576](https://github.com/canonical/sphinx-docs-starter-pack/pull/576), [#590](https://github.com/canonical/sphinx-docs-starter-pack/pull/590), [#595](https://github.com/canonical/sphinx-docs-starter-pack/pull/595), [#598](https://github.com/canonical/sphinx-docs-starter-pack/pull/598) * `docs/Makefile` [#575](https://github.com/canonical/sphinx-docs-starter-pack/pull/575), [#590](https://github.com/canonical/sphinx-docs-starter-pack/pull/590) * `docs/requirements.txt` [#590]([#590](https://github.com/canonical/sphinx-docs-starter-pack/pull/590)) * `docs/reuse/` [#576](https://github.com/canonical/sphinx-docs-starter-pack/pull/576) @@ -19,6 +20,8 @@ * `docs/_templates/footer.html` [#594](https://github.com/canonical/sphinx-docs-starter-pack/pull/594) * `docs/requirements.txt` [#596](https://github.com/canonical/sphinx-docs-starter-pack/pull/596) * `docs/redirects.txt` [#598](https://github.com/canonical/sphinx-docs-starter-pack/pull/598) +* `docs/.sphinx/update_sp.py` [#595](https://github.com/canonical/sphinx-docs-starter-pack/pull/595) +* `.github/workflows/test-sphinx-stack.yml` [#595](https://github.com/canonical/sphinx-docs-starter-pack/pull/595) ## 1.6 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a17d8e28..11de6792 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,15 +1,23 @@ -# Contributing to the Starter Pack +# Contributing to Sphinx Stack development -The Starter Pack provides a shared foundation for Sphinx documentation projects, and contributions help improve the documentation of all its users. The Documentation Practice team performs most of the work, but all contributors are welcome. +The Sphinx Stack is a shared foundation for Sphinx documentation projects, and +contributions help improve the documentation of all its users. The Documentation +Practice team performs most of the work, but all contributors are welcome. Common contributions include: - Bug fixes: Build errors, broken links, configuration issues -- Documentation: How-to guides on Starter Pack features and usage, syntax references, troubleshooting information -- Improvements: Better defaults, new extensions, workflow enhancements, new or improved style rules +- Improvements: Better defaults, new extensions, workflow enhancements, new or improved + style rules - Dependency updates: Security patches, compatibility fixes, better tooling -If you run into any problems or see room for improvement, we encourage you to open an issue or even contribute a fix. +If you run into any problems or see room for improvement, we encourage you to open an +issue or even contribute a fix. + +> This guide only covers contributions to development. If you're interested in +> contributing to the Sphinx Stack documentation, refer to the [documentation +> repository's +> guide](https://github.com/canonical/sphinx-stack-docs/blob/main/CONTRIBUTING.md). ## Review the project expectations @@ -17,62 +25,78 @@ Review these three documents before contributing: ### Ubuntu Code of Conduct -When contributing, you must abide by the [Ubuntu Code of Conduct](https://ubuntu.com/community/ethos/code-of-conduct). Projects governed by Canonical expect good conduct and excellence from every member. +When contributing, you must abide by the [Ubuntu Code of +Conduct](https://ubuntu.com/community/ethos/code-of-conduct). Projects governed by +Canonical expect good conduct and excellence from every member. ### Canonical Contributor License Agreement -Code contributions can only be accepted from contributors who have signed our [Contributor License Agreement (CLA)](https://ubuntu.com/legal/contributors). Signing the agreement grants Canonical permission to use your contributions, and you remain the copyright owner of your work (no copyright assignment occurs). +Code contributions can only be accepted from contributors who have signed our +[Contributor License Agreement (CLA)](https://ubuntu.com/legal/contributors). Signing +the agreement grants Canonical permission to use your contributions, and you remain the +copyright owner of your work (no copyright assignment occurs). -Review the terms of the agreement before signing it or committing anything. If you agree and choose to sign it, your work can be incorporated into the repository. +Review the terms of the agreement before signing it or committing anything. If you agree +and choose to sign it, your work can be incorporated into the repository. ### Open source license -The Starter Pack is licensed under [GPL-3.0](LICENSE). Documentation for this project is licensed under CC-BY-SA 3.0. +The Sphinx Stack is licensed under [GPL-3.0](LICENSE). ## Report an issue or open a request -If you find a bug or feature gap in the Starter Pack, look for it in the [project's GitHub issues](https://github.com/canonical/sphinx-docs-starter-pack/issues) first. Add your voice to the thread if you have fresh input. +If you find a bug or feature gap in the Sphinx Stack, look for it in the [project's +GitHub issues](https://github.com/canonical/sphinx-stack/issues) first. Add +your voice to the thread if you have fresh input. -If the bug or feature doesn't have an issue, [open one](https://github.com/canonical/sphinx-docs-starter-pack/issues/new/choose). +If the bug or feature doesn't have an issue, [open +one](https://github.com/canonical/sphinx-stack/issues/new/choose). -## What belongs in the Starter Pack +## What belongs in the Sphinx Stack -The Starter Pack is designed to be a minimal, flexible foundation for diverse documentation projects. +The Sphinx Stack is designed to be a minimal, flexible foundation for diverse +documentation projects. -**Belongs in the Starter Pack:** +**Belongs in the Sphinx Stack:** - Bug fixes for core functionality - Improvements to default configuration that benefit all users -- Documentation about existing features - Dependency updates for security or compatibility -**May not belong in the Starter Pack:** -- Optional tooling or features (these should be opt-in and implemented by projects using the Starter Pack) -- Opinionated formatting or linting rules that would cause a sizable portion of existing doc sets to fail checks suddenly +**May not belong in the Sphinx Stack:** +- Optional tooling or features (these should be opt-in and implemented by projects using + the Sphinx Stack) +- Opinionated formatting or linting rules that would cause a sizable portion of existing + doc sets to fail checks suddenly - Changes that conflict with existing workflows - Features that are project-specific rather than general-purpose -- UI-related changes may be better suited for the ongoing alternative theme update project (ask maintainers) +- UI-related changes may be better suited for the ongoing alternative theme update + project (ask maintainers) -When in doubt, open an issue first to discuss whether the change aligns with the project's goals. +When in doubt, open an issue first to discuss whether the change aligns with the +project's goals. ## Development setup -Create a [personal fork](https://github.com/canonical/sphinx-docs-starter-pack/fork) of the repository, then clone it and add the upstream remote: +Create a [personal fork](https://github.com/canonical/sphinx-stack/fork) of +the repository, then clone it and add the upstream remote: -With [SSH](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account): +With +[SSH](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account): ```bash -git clone git@github.com:/sphinx-docs-starter-pack -cd sphinx-docs-starter-pack -git remote add upstream git@github.com:canonical/sphinx-docs-starter-pack +git clone git@github.com:/sphinx-stack +cd sphinx-stack +git remote add upstream git@github.com:canonical/sphinx-stack git fetch upstream ``` -With [HTTPS](https://docs.github.com/en/get-started/git-basics/about-remote-repositories#cloning-with-https-urls): +With +[HTTPS](https://docs.github.com/en/get-started/git-basics/about-remote-repositories#cloning-with-https-urls): ```bash -git clone https://github.com//sphinx-docs-starter-pack -cd sphinx-docs-starter-pack -git remote add upstream https://github.com/canonical/sphinx-docs-starter-pack +git clone https://github.com//sphinx-stack +cd sphinx-stack +git remote add upstream https://github.com/canonical/sphinx-stack git fetch upstream ``` @@ -88,15 +112,21 @@ make html ### Research the topic -All significant work should be tied to an existing issue. Before starting, comment on the issue to have it assigned to you. +All significant work should be tied to an existing issue. Before starting, comment on +the issue to have it assigned to you. #### Minor changes -Check [GitHub issues](https://github.com/canonical/sphinx-docs-starter-pack/issues) for existing reports. If none exist, [open one](https://github.com/canonical/sphinx-docs-starter-pack/issues/new/choose) and state your interest in working on it. +Check [GitHub issues](https://github.com/canonical/sphinx-stack/issues) for +existing reports. If none exist, [open +one](https://github.com/canonical/sphinx-stack/issues/new/choose) and state +your interest in working on it. #### Major changes -Describe your proposal in the issue thread, including the plan, tests, and documentation. For new documentation pages, propose a [Diátaxis](https://diataxis.fr) category. +Describe your proposal in the issue thread, including the plan, tests, and +documentation. For new documentation pages, propose a [Diátaxis](https://diataxis.fr) +category. ### Create a development branch @@ -107,15 +137,16 @@ git fetch upstream git checkout -b ``` -Name your branch `-` (e.g., `issue-235-add-string-sanitizer`), keeping it under 80 characters. +Name your branch `-` (e.g., `issue-235-add-string-sanitizer`), +keeping it under 80 characters. ### Make your changes Follow these guidelines: - Use separate commits for each logical change, and for changes to different components -- Keep the Starter Pack minimal by default; optional features are best implemented - by the projects using the Starter Pack rather than the Starter Pack itself +- Keep the Sphinx Stack minimal by default; optional features are best implemented + by the projects using the Sphinx Stack rather than the Sphinx Stack itself ### Commit a change @@ -134,7 +165,8 @@ To determine the commit type, check the file history with `git log --oneline **Tip** > -> If you're unsure which type to use, the commit may be doing too much, so split it into smaller commits instead. Select the highest-ranked type that fits: +> If you're unsure which type to use, the commit may be doing too much, so split it into +> smaller commits instead. Select the highest-ranked type that fits: > > - `ci` > - `build` @@ -149,34 +181,47 @@ To determine the commit type, check the file history with `git log --oneline **Tip** > -> You can configure your Git client to sign commits by default for any local repository by running `git config --global commit.gpgsign true`. Once you have done this, you no longer need to add `-S` to your commits explicitly. +> You can configure your Git client to sign commits by default for any local repository +> by running `git config --global commit.gpgsign true`. Once you have done this, you no +> longer need to add `-S` to your commits explicitly. > > See [GitHub Docs - Signing commits](https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits) for more information. -If you've made an unsigned commit and encounter the "Commits must have verified signatures" error when pushing your changes to the remote: +If you've made an unsigned commit and encounter the "Commits must have verified +signatures" error when pushing your changes to the remote: -1. Amend the most recent commit by signing it without changing the commit message, and push again: +1. Amend the most recent commit by signing it without changing the commit message, and + push again: ```bash git commit --amend --no-edit -n -S git push ``` -2. If you still encounter the same error, confirm that your GitHub account has been set up properly to sign commits as described in the [GitHub Docs - About commit signature verification](https://docs.github.com/en/authentication/managing-commit-signature-verification/about-commit-signature-verification). +2. If you still encounter the same error, confirm that your GitHub account has been set + up properly to sign commits as described in the [GitHub Docs - About commit signature + verification](https://docs.github.com/en/authentication/managing-commit-signature-verification/about-commit-signature-verification). > **Tip** > - > If you use SSH keys to sign your commits, make sure to add a "Signing Key" type in your GitHub account. See [GitHub Docs - Adding a new SSH key to your account](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account) for more information. + > If you use SSH keys to sign your commits, make sure to add a "Signing Key" type in + > your GitHub account. See [GitHub Docs - Adding a new SSH key to your + > account](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account) + > for more information. ### Test the change @@ -203,15 +248,18 @@ make run ### Document the change -This documentation uses [Diátaxis](https://diataxis.fr). For small changes, update existing how-to guides and references. For major changes or new flows, create new pages in the appropriate category. +This documentation is sourced from +[canonical/sphinx-stack-docs](https://github.com/canonical/sphinx-stack-docs) and uses +[Diátaxis](https://diataxis.fr). For small changes, update existing how-to guides and +references. For major changes or new flows, create new pages +in the appropriate category. -Run the same basic checks locally that GitHub runs on PRs; see [Test the change](#test-the-change). +Run the same basic checks locally that GitHub runs on PRs; see [Test the +change](#test-the-change). #### Changelog guidance -Doc-only changes generally do not require changelog entries. However, reviewers may request one for notable additions such as significant new how-to guides or reference documentation. - -For non-documentation changes, ensure that feature changes and fixes are documented in the relevant release notes. +Ensure that feature changes and fixes are documented in the relevant release notes. ### Push the branch and open a PR @@ -219,7 +267,8 @@ For non-documentation changes, ensure that feature changes and fixes are documen git push -u origin ``` -Next, open a PR on GitHub. Format its title as a conventional commit (GitHub may do this automatically for single-commit branches). +Next, open a PR on GitHub. Format its title as a conventional commit (GitHub may do this +automatically for single-commit branches). ### Describing PRs @@ -231,13 +280,13 @@ Your PR should include the following details: - Testing: How reviewers can verify the change or test the fix - Reversibility: For costly-to-reverse decisions, explain reasoning and reversal steps -Make sure to peek at the preview for documentation changes (find the `Read the Docs build` check and click `...` - `View details`). If your PR adds or changes specific documentation pages, include links to the preview pages in the PR description. - ## CI/CD pipeline -The repository configures multiple automated checks. Some are conditional based on target branch or changed files. +The repository configures multiple automated checks. Some are conditional based on +target branch or changed files. -If a check fails, review the logs for remediation guidance. For failures unrelated to your changes, rebase against the latest base branch. +If a check fails, review the logs for remediation guidance. For failures unrelated to +your changes, rebase against the latest base branch. ### Checks on all PRs @@ -256,20 +305,29 @@ These run on every PR and on pushes to `main`: #### CLA check in CI -When you open a pull request (PR) against the `main` branch, a mandatory automated check verifies that you have signed the CLA. It uses the [canonical/has-signed-canonical-cla](https://github.com/canonical/has-signed-canonical-cla) GitHub Action. +When you open a pull request (PR) against the `main` branch, a mandatory automated check +verifies that you have signed the CLA. It uses the +[canonical/has-signed-canonical-cla](https://github.com/canonical/has-signed-canonical-cla) +GitHub Action. If you haven't signed the CLA: 1. The check will fail with a message indicating the CLA requirement 2. Visit to review and sign the agreement -3. Once signed, re-run the check if you have permissions, or ask a maintainer to do so. Pushing a new commit also triggers re-evaluation. +3. Once signed, re-run the check if you have permissions, or ask a maintainer to do so. + Pushing a new commit also triggers re-evaluation. -The CLA check only runs on PRs to `main`. Internal team members working on other branches should ensure they have signed the CLA before their changes are merged to `main`. +The CLA check only runs on PRs to `main`. Internal team members working on other +branches should ensure they have signed the CLA before their changes are merged to +`main`. ### Checks on changes to `docs/` only - Markdown style check: Runs `pymarkdownlnt` on Markdown files -- Automatic documentation checks: Runs upstream documentation workflow checks. - The project uses [canonical/documentation-workflows](https://github.com/canonical/documentation-workflows) for automatic documentation checks. To modify this part of CI behavior, pass inputs to upstream workflows rather than creating or customizing local copies. +- Automatic documentation checks: Runs upstream documentation workflow checks.The + project uses + [canonical/documentation-workflows](https://github.com/canonical/documentation-workflows) + for automatic documentation checks. To modify this part of CI behavior, pass inputs to + upstream workflows rather than creating or customizing local copies. ### Optional checks (allowed to fail) @@ -282,27 +340,21 @@ PRs are typically reviewed within a week. ### Responding to feedback -Push additional commits to address feedback (commit locally rather than via GitHub UI to avoid sync conflicts). +Push additional commits to address feedback (commit locally rather than via GitHub UI to +avoid sync conflicts). -Rebase your branch before requesting a review to keep your commits clean. Once review has started, avoid rebasing to maintain the review history and make it easier for reviewers to see what changed. +Rebase your branch before requesting a review to keep your commits clean. Once review +has started, avoid rebasing to maintain the review history and make it easier for +reviewers to see what changed. ### Common feedback themes Reviewers may request: - Wording, terminology, or formatting changes -- Consistency with existing documentation patterns +- Consistency with existing patterns - Proper reST or MyST markup style - Minimal examples before listing options -- Terminology: Align naming with existing documentation and code - Cross-references: Use proper reST or MyST syntax - Examples: Start minimal, then show options; include verification steps - Theme compatibility: Test in both light and dark modes - -## Release process - - - -## Branch management policy - - diff --git a/LICENSE b/LICENSE index 31081ad4..f288702d 100644 --- a/LICENSE +++ b/LICENSE @@ -1,13 +1,3 @@ -License for Canonical Starter Pack -================================== - -Unless otherwise stated, all code in this repository is licensed under -the following GPL license. -Documentation for this project is licensed under CC-BY-SA 3.0. - -Starter Pack code ------------------ - GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 @@ -682,13 +672,3 @@ may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . - -Starter Pack documentation --------------------------- - -Copyright 2024 Canonical Ltd. - -This work is licensed under the Creative Commons Attribution-Share Alike 3.0 -Unported License. To view a copy of this license, visit -http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative -Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA. \ No newline at end of file diff --git a/README.md b/README.md index 526c7d55..831e27c7 100644 --- a/README.md +++ b/README.md @@ -1,41 +1,63 @@ -# Canonical's Sphinx Starter Pack +# Sphinx Stack -*A pre-configured repository to build and publish documentation with Sphinx.* +[![Sphinx Stack test](https://github.com/canonical/sphinx-stack/actions/workflows/test-sphinx-stack.yml/badge.svg)](https://github.com/canonical/sphinx-stack/actions/workflows/test-sphinx-stack.yml) -## Description +A standard set of tools for building and publishing Sphinx documentation. -The Documentation Starter Pack includes: +The Sphinx Stack contains a set of CLI commands and a default set of extensions, +configuration options, and tests. -* A bundled [Sphinx] theme, configuration, and extensions -* Support for both reStructuredText (reST) and MyST Markdown -* Build checks for links, spelling, and inclusive language -* Customisation support layered over a core configuration +## Basic usage -See the full documentation: https://canonical-starter-pack.readthedocs-hosted.com/ +To try out the Sphinx Stack, clone it locally and navigate to the `/docs` directory: -## Structure +```shell +git clone git@github.com:canonical/sphinx-stack.git +cd docs +``` -This section outlines the structure of this repository, and some key files. +Then, run the command -### `docs/` +```shell +make run +``` -This directory contains the documentation for the Starter Pack itself. +This will create a Python virtual environment, install necessary dependencies, build the +documentation, and serve it to http://127.0.0.1:8000. -To view it in your browser, navigate to this directory and type `make run`. +To learn more about how to install and configure the Sphinx Stack for your own project, +see the [Set up a new +project](https://canonical-sphinx-stack.readthedocs-hosted.com/stable/tutorial/set-up/) +guide in the official documentation. -### `.github/workflows/` +## Requirements and limitations -This directory contains files used for documentation build checks via GitHub's CI. +The Sphinx Stack is designed for projects hosted on GitHub. This is necessary to run the +automatic checks in .github/workflows, and to publish your documentation on Read the +Docs. -The file `test-starter-pack.yml` tests the functionality of the Starter Pack project. +If you have a project that is hosted on a different versioning platform, like Launchpad, +[reach out to us](#reach-out). -## Contributing +## Community and support -We welcome contributions to this project! If you have suggestions, bug fixes, or improvements, please open an issue or submit a pull request. +The Sphinx Stack is an open-source project that warmly welcomes community involvement. -Please read and sign our [Contributor Licence Agreement (CLA)] before submitting any changes. The agreement grants Canonical permission to use your contributions. The author of a change remains the copyright owner of their code (no copyright assignment occurs). +If you’re new to the community, make sure to read through the [Ubuntu Code of +Conduct](https://ubuntu.com/community/code-of-conduct) first. - +### Reach out -[Sphinx]: https://www.sphinx-doc.org/ -[Contributor Licence Agreement (CLA)]: https://ubuntu.com/legal/contributors +* Report an issue or make a suggestion via + [GitHub](https://github.com/canonical/sphinx-stack/issues) +* Come chat with the Canonical Documentation team in our [public Matrix + channel](https://matrix.to/#/#documentation:ubuntu.com) + +### Contribute + +The Sphinx Stack provides a shared foundation for Sphinx documentation projects, and +contributions help improve the documentation of all its users. + +* See [CONTRIBUTING.md](CONTRIBUTING.md) for more details on contributing to + development or documentation. +* Check [open issues](https://github.com/canonical/sphinx-stack/issues) diff --git a/docs/_dev/update_sp.py b/docs/_dev/update_sp.py index b4da5858..13129216 100755 --- a/docs/_dev/update_sp.py +++ b/docs/_dev/update_sp.py @@ -1,28 +1,29 @@ #! /usr/bin/env python -# Initial update script for the starter pack. +# Initial update script for the Sphinx Stack. # # Requires some manual intervention, but makes identifying updates and differences easier. # # For debugging, please run this script with DEBUGGING=1 -# e.g. user@device:~/git/Canonical/sphinx-docs-starter-pack/docs$ DEBUGGING=1 python _dev/update_sp.py +# e.g. user@device:~/git/Canonical/sphinx-stack/docs$ DEBUGGING=1 python .sphinx/update_sp.py import glob import logging import os -import requests import re import subprocess import sys -from requests.exceptions import RequestException + +import requests from packaging.version import parse as parse_version +from requests.exceptions import RequestException SPHINX_DIR = os.path.abspath(os.path.dirname(__file__)) -DOCS_DIR = os.path.abspath(os.path.join(SPHINX_DIR, '..')) +DOCS_DIR = os.path.abspath(os.path.join(SPHINX_DIR, "..")) REQUIREMENTS = os.path.join(DOCS_DIR, "requirements.txt") SPHINX_UPDATE_DIR = os.path.join(SPHINX_DIR, "update") -GITHUB_REPO = "canonical/sphinx-docs-starter-pack" +GITHUB_REPO = "canonical/sphinx-stack" GITHUB_API_BASE = f"https://api.github.com/repos/{GITHUB_REPO}" GITHUB_API_DEV_DIR = f"{GITHUB_API_BASE}/contents/docs/_dev" GITHUB_RAW_BASE = f"https://raw.githubusercontent.com/{GITHUB_REPO}/main" @@ -43,7 +44,7 @@ def main(): except FileNotFoundError: print("WARNING\nWARNING\nWARNING") print( - "You need to update to at least version 1.0.0 of the starter pack to start using the update function." + "You need to update to at least version 1.0.0 of the Sphinx Stack to start using the update function." ) print("You may experience issues using this functionality.") logging.debug("No local version found. Setting version to None") @@ -61,7 +62,7 @@ def main(): logging.debug("Comparing versions") if parse_version(local_version) < parse_version(latest_release): logging.debug("Local version is older than the release version.") - print("Starter pack is out of date.\n") + print("Sphinx Stack is out of date.\n") # Identify and download '_dev' dir files to '_dev/update' files_updated, new_files = update_static_files() @@ -130,7 +131,7 @@ def main(): except FileNotFoundError: print("requirements.txt not found") print( - "The updated starter pack has moved requirements.txt out of the '_dev' dir" + "The updated Sphinx Stack has moved requirements.txt out of the '_dev' dir" ) print("requirements.txt not checked, please update your requirements manually") @@ -142,7 +143,7 @@ def update_static_files(): for item in query_api(GITHUB_API_DEV_DIR).json(): logging.debug(f"Checking {item['name']}") - # Checks existing files in '_dev' starter pack static root for changed SHA + # Checks existing files in '_dev' Sphinx Stack static root for changed SHA if item["name"] in files and item["type"] == "file": index = files.index(item["name"]) if item["sha"] != get_git_revision_hash(paths[index]): @@ -162,9 +163,7 @@ def update_static_files(): # Checks nested files '_dev/**/**.*' for changed SHA (single level of depth) elif item["type"] == "dir": logging.debug(item["name"] + " is a directory") - for nested_item in query_api( - f"{GITHUB_API_DEV_DIR}/{item['name']}" - ).json(): + for nested_item in query_api(f"{GITHUB_API_DEV_DIR}/{item['name']}").json(): logging.debug(f"Checking {nested_item['name']}") if nested_item["name"] in files: index = files.index(nested_item["name"]) @@ -189,7 +188,7 @@ def update_static_files(): SPHINX_UPDATE_DIR, item["name"], nested_item["name"] ), ) - # Downloads NEW files in '_dev' starter pack static root + # Downloads NEW files in '_dev' Sphinx Stack static root else: if item["type"] == "file": logging.debug(f"No local version found of {item['name']}") diff --git a/docs/_dev/version b/docs/_dev/version index 810ee4e9..cd5ac039 100644 --- a/docs/_dev/version +++ b/docs/_dev/version @@ -1 +1 @@ -1.6 +2.0 diff --git a/docs/conf.py b/docs/conf.py index 5a328587..aa203a43 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -2,8 +2,6 @@ import os import textwrap -import yaml - # Configuration for the Sphinx documentation builder. # All configuration specific to your project should be done in this file. # @@ -13,151 +11,92 @@ # A complete list of built-in Sphinx configuration values: # https://www.sphinx-doc.org/en/master/usage/configuration.html # -# Our Starter Pack uses the custom Canonical Sphinx extension -# to keep all documentation based on it consistent and on brand: +# The Sphinx Stack uses the Canonical Sphinx theme to keep all documentation consistent +# and on brand: # https://github.com/canonical/canonical-sphinx - ####################### # Project information # ####################### # Project name -# -# TODO: Update with the official name of your project or product +# TODO: Update with the official name of your project or product (e.g., "Ubuntu Server") +project = "Project" -project = "Documentation Starter Pack" +# Author name; used in the default copyright statement in the page footer author = "Canonical Ltd." -# The year in the copyright statement defaults to the current year, so -# individual document versions show when they were built. -# TODO: If the date must be a range, like in a software license, replace -# 2026 with the starting year of development and use: -# -# copyright = f"2026-{datetime.date.today().year}" - +# The year in the copyright statement copyright = f"{datetime.date.today().year}" -# Sidebar documentation title; best kept reasonably short -# -# TODO: To include a version number, add it here (hardcoded or automated). -# -# TODO: To disable the title, set to an empty string. - +# Sidebar documentation title +# To disable the title, set it to an empty string. html_title = project + " documentation" - # Documentation website URL -# -# TODO: Update with the official URL of your docs or leave empty if unsure. -# -# NOTE: The Open Graph Protocol (OGP) enhances page display in a social graph -# and is used by social media platforms; see https://ogp.me/ - -ogp_site_url = "https://canonical-starter-pack.readthedocs-hosted.com/" - +ogp_site_url = os.environ.get("READTHEDOCS_CANONICAL_URL", "/") # Preview name of the documentation website -# -# TODO: To use a different name for the project in previews, update as needed. - +# TODO: To use a different name for the project in previews, update the next line. ogp_site_name = project - # Preview image URL -# -# TODO: To customise the preview image, update as needed. - +# TODO: To customise the preview image, update the next line. ogp_image = "https://assets.ubuntu.com/v1/cc828679-docs_illustration.svg" - # Product favicon; shown in bookmarks, browser tabs, etc. - -# TODO: To customise the favicon, uncomment and update as needed. - -# html_favicon = '_static/favicon.png' - +# TODO: To customise the favicon, uncomment and update the next line. +# html_favicon = ".sphinx/_static/favicon.png" # Dictionary of values to pass into the Sphinx context for all pages: # https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-html_context - html_context = { # Product page URL; can be different from product docs URL - # - # TODO: Change to your product website URL, - # dropping the 'https://' prefix, e.g. 'ubuntu.com/lxd'. - # - # TODO: If there's no such website, - # remove the {{ product_page }} link from the page header template - # (usually _templates/header.html; also, see README.rst). - "product_page": "documentation.ubuntu.com", + # TODO: Change to your product website URL, dropping the 'https://' prefix (e.g., + # 'ubuntu.com/lxd'). If there's no such website, remove the {{ product_page }} + # link from the _templates/header.html file. + "product_page": "", # Product tag image; the orange part of your logo, shown in the page header - # # TODO: To add a tag image, uncomment and update as needed. # 'product_tag': '_static/tag.png', # Your Discourse instance URL - # # TODO: Change to your Discourse instance URL or leave empty. - # - # NOTE: If set, adding ':discourse: 123' to an .rst file - # will add a link to Discourse topic 123 at the bottom of the page. - "discourse": "https://discourse.ubuntu.com", + "discourse": "", # Your Mattermost channel URL - # # TODO: Change to your Mattermost channel URL or leave empty. - "mattermost": "https://chat.canonical.com/canonical/channels/documentation", + "mattermost": "", # Your Matrix channel URL - # # TODO: Change to your Matrix channel URL or leave empty. - "matrix": "https://matrix.to/#/#documentation:ubuntu.com", - # Your documentation GitHub repository URL - # + "matrix": "", + # Your documentation GitHub repository URL If set, links for viewing the + # documentation source files and creating GitHub issues are added at the bottom of + # each page. # TODO: Change to your documentation GitHub repository URL or leave empty. - # - # NOTE: If set, links for viewing the documentation source files - # and creating GitHub issues are added at the bottom of each page. - "github_url": "https://github.com/canonical/sphinx-docs-starter-pack", + "github_url": "", # Docs branch in the repo; used in links for viewing the source files - # - # TODO: To customise the branch, uncomment and update as needed. "repo_default_branch": "main", # Docs location in the repo; used in links for viewing the source files - # - # TODO: To customise the directory, uncomment and update as needed. "repo_folder": "/docs/", # TODO: To enable or disable the Previous / Next buttons at the bottom of pages # Valid options: none, prev, next, both - # "sequential_nav": "both", + # "sequential_nav": "", # TODO: To enable listing contributors on individual pages, set to True "display_contributors": False, # Required for feedback button "github_issues": "enabled", - # Inherit the author value + # Passes the top-level 'author' value to the theme "author": author, - # The Starter Pack uses CC-BY-SA as the license - # - # TODO: If your docs need another license, specify it instead of 'CC-BY-SA'. - # For the name, we recommend using the standard shorthand identifier from - # https://spdx.org/licenses - # - # For the URL, link directly to the license statement, typically found on - # the product's home page or in its GitHub project. - # - # TODO: If your documentation is a part of the code repository of your project, - # it inherits the code license instead; specify it instead of 'CC-BY-SA'. + # Documentation license information "license": { - "name": "CC-BY-SA-3.0", - "url": "https://github.com/canonical/sphinx-docs-starter-pack/blob/main/LICENSE", + # TODO: Specify your project's license. + # For the name, we recommend using the standard shorthand identifier from + # https://spdx.org/licenses + "name": "", + # TODO: Link directly to your project's license statement. + "url": "", }, } -html_extra_path = [] - -# Allow opt-in build of the OpenAPI "Hello" example so docs stay clean by default. -if os.getenv("OPENAPI", ""): - tags.add("openapi") - html_extra_path.append("how-to/assets/openapi.yaml") - # TODO: To enable the edit button on pages, uncomment and change the link to a # public repository on GitHub or Launchpad. Any of the following link domains # are accepted: @@ -166,14 +105,12 @@ # - https://git.launchpad.net/example # # html_theme_options = { -# 'source_edit_link': 'https://github.com/canonical/sphinx-docs-starter-pack', +# 'source_edit_link': 'https://github.com/canonical/sphinx-stack', # } -# Project slug; see https://meta.discourse.org/t/what-is-category-slug/87897 -# -# TODO: If your documentation is hosted on https://docs.ubuntu.com/, -# uncomment and update as needed. - +# Project slug +# TODO: If your documentation is hosted on https://documentation.ubuntu.com/, +# uncomment and set to the RTD slug. # slug = '' ####################### @@ -181,28 +118,23 @@ ####################### # Use RTD canonical URL to ensure duplicate pages have a specific canonical URL - html_baseurl = os.environ.get("READTHEDOCS_CANONICAL_URL", "/") # sphinx-sitemap uses html_baseurl to generate the full URL for each page: - sitemap_url_scheme = "{link}" # Include `lastmod` dates in the sitemap: - sitemap_show_lastmod = True -# Exclude generated pages from the sitemap: - +# TODO: Exclude pages that aren't user-facing from the sitemap (e.g., module pages +# generated by autodoc). +# Pages excluded from the sitemap: sitemap_excludes = [ "404/", "genindex/", "search/", ] -# TODO: Add more pages to sitemap_excludes if needed. Wildcards are supported. -# For example, to exclude module pages generated by autodoc, add '_modules/*'. - ################################ # Template and asset locations # ################################ @@ -210,7 +142,6 @@ # html_static_path = ["_static"] # templates_path = ["_templates"] - ############# # Redirects # ############# @@ -237,8 +168,8 @@ # ". llms_txt_description = textwrap.dedent( """\ - This is the documentation for the Sphinx Starter Pack, a template repository - that helps you set up, build, and publish Sphinx documentation. + This is the documentation for the Sphinx Stack, a template repository that helps you + set up, build, and publish Sphinx documentation. """ ) @@ -251,9 +182,6 @@ ########################### # A regex list of URLs that are ignored by 'make linkcheck' -# -# TODO: Remove or adjust the ACME entry after you update the contributing guide - linkcheck_ignore = [ "http://127.0.0.1:8000", "https://github.com", @@ -263,13 +191,14 @@ r"https://.*\.sourceforge\.(net|io)/.*", ] - # A regex list of URLs where anchors are ignored by 'make linkcheck' - linkcheck_anchors_ignore_for_url = [r"https://github\.com/.*"] -# give linkcheck multiple tries on failure +# How long the link checker will wait for a response for each request +# TODO: Decrease to improve run time or increase if links frequently time out. # linkcheck_timeout = 30 + +# Give linkcheck multiple tries on failure linkcheck_retries = 3 ######################## @@ -278,18 +207,14 @@ # Custom MyST syntax extensions; see # https://myst-parser.readthedocs.io/en/latest/syntax/optional.html -# # NOTE: By default, the following MyST extensions are enabled: -# substitution, deflist, linkify - +# - substitution +# - deflist +# - linkify # myst_enable_extensions = set() - # Custom Sphinx extensions; see # https://www.sphinx-doc.org/en/master/usage/extensions/index.html - -# NOTE: The canonical_sphinx extension is required for the Starter Pack. - extensions = [ "canonical_sphinx", "notfound.extension", @@ -315,65 +240,42 @@ ] # Excludes files or directories from processing - exclude_patterns = [ "doc-cheat-sheet*", ".venv*", ] -# Adds custom CSS files, located under 'html_static_path' - +# Adds custom CSS files, located remotely or in 'html_static_path'. # html_css_files = [ # "https://assets.ubuntu.com/v1/d86746ef-cookie_banner.css", # ] - -# Adds custom JavaScript files, located under 'html_static_path' - +# Adds custom JavaScript files, located remotely or in 'html_static_path'. # html_js_files = [ # "https://assets.ubuntu.com/v1/287a5e8f-bundle.js", # ] - -# Specifies a reST snippet to be appended to each .rst file -# If you have many entries, consider creating a reuse/substitutions.txt file -# and loading it here instead. +# Appends extra markup to the end of every document written in reST # rst_epilog = """ -# .. include:: reuse/substitutions.txt -# """ -rst_epilog = """ -.. |RST| replace:: :abbr:`reST (reStructuredText)` -.. |version_number| replace:: 0.1.0 -.. |rest_text| replace:: *Multi-line* text - that uses basic **markup**. -.. |site_link| replace:: Website link -.. _site_link: https://example.com -""" +# """ # Feedback button at the top; enabled by default -# -# TODO: To disable the button, uncomment this. - +# TODO: Disable the button if your project is unsuitable for public feedback. # disable_feedback_button = True - # Your manpage URL -# # TODO: To enable manpage links, uncomment and replace {codename} with required # release, preferably an LTS release (e.g. noble). Do *not* substitute # {section} or {page}; these will be replaced by sphinx at build time # # NOTE: If set, adding ':manpage:' to an .rst file # adds a link to the corresponding man section at the bottom of the page. - # manpages_url = 'https://manpages.ubuntu.com/manpages/{codename}/en/' + \ # 'man{section}/{page}.{section}.html' - # Specifies a reST snippet to be prepended to each .rst file # This defines a :center: role that centers table cell content. # This defines a :h2: role that styles content for use with PDF generation. - rst_prolog = """ .. role:: center :class: align-center @@ -385,30 +287,8 @@ :class: vale-ignore """ -# Workaround for https://github.com/canonical/canonical-sphinx/issues/34 - -if "discourse_prefix" not in html_context and "discourse" in html_context: - html_context["discourse_prefix"] = f"{html_context['discourse']}/t/" - -# Workaround for substitutions.yaml -# If the user has a reuse/substitutions.yaml file, load from there. -# Otherwise, use the manual definitions below. - -if os.path.exists("./reuse/substitutions.yaml"): - with open("./reuse/substitutions.yaml", "r") as fd: - myst_substitutions = yaml.safe_load(fd.read()) -else: - myst_substitutions = { - "version_number": "0.1.0", - "formatted_text": "*Multi-line* text\n that uses basic **markup**.", - "site_link": "[Website link](https://example.com)" - } - -# Add configuration for intersphinx mapping -# Map only the Sphinx documentation sets that you need to link to from your docs set. -intersphinx_mapping = { - "sphinxcontrib-mermaid": ( - "https://sphinxcontrib-mermaid-demo.readthedocs.io/en/latest", - None, - ) -} +# Configuration for Intersphinx projects +# +# intersphinx_mapping = { +# "snap": ("https://snapcraft.io/docs/", None), +# } diff --git a/docs/contribute/index.rst b/docs/contribute/index.rst index 47504e5c..aa76b710 100644 --- a/docs/contribute/index.rst +++ b/docs/contribute/index.rst @@ -2,8 +2,3 @@ Contribute ========== - -.. toctree:: - :maxdepth: 1 - - Test the Ulwazi theme \ No newline at end of file diff --git a/docs/contribute/test-ulwazi-theme.md b/docs/contribute/test-ulwazi-theme.md deleted file mode 100644 index 787cdec9..00000000 --- a/docs/contribute/test-ulwazi-theme.md +++ /dev/null @@ -1,280 +0,0 @@ ---- -myst: - html_meta: - description: How to test the Ulwazi theme in a documentation project based on Canonical's Sphinx Starter Pack. -relatedlinks: "[Ulwazi on PyPI](https://pypi.org/project/ulwazi), [Vanilla](https://vanillaframework.org), [sphinx-basic-ng](https://github.com/pradyunsg/sphinx-basic-ng)" ---- - -(how-to-test-ulwazi-theme)= - -# Test the Ulwazi theme - -Ulwazi is a Sphinx theme built on Vanilla, with the base layout and functionality derived from sphinx-basic-ng. - -This guide outlines the steps required to use the Ulwazi theme in your Sphinx documentation project. - -We recommend creating a new branch of your repository and testing Ulwazi in that branch. -You can build the Ulwazi-themed documentation locally from the branch or open a PR and view the changes in its RTD preview. - -## Update the dependencies - -In your project's Python requirements (`requirements.txt`), replace the Canonical Sphinx package with Ulwazi and its dependencies: - -```{code-block} diff -:caption: requirements.txt - -- canonical-sphinx -+ sphinx -+ build -+ sphinx-autobuild -+ canonical-sphinx-config @ git+https://github.com/Canonical/canonical-sphinx-config.git@main -+ myst-parser~=4.0 -+ sphinx-basic-ng -+ sphinxcontrib-jquery -+ beautifulsoup4 -+ packaging -+ sphinxcontrib-svg2pdfconverter[CairoSVG] -+ sphinx-last-updated-by-git -+ sphinx-sitemap -+ sphinx-terminal -+ ulwazi -``` - -Be ready to add any other missing extensions if you see errors about them. - -## Main configuration - -Updating the project configuration is the most critical step in this process. - -There are two main ways to do that: - -* Simple way -- Adapt the [Sample `conf.py` for Ulwazi](https://github.com/canonical/ulwazi/blob/main/docs/default-conf.py) by adjusting the values for your specific documentation. -* Hard way -- Adapt your existing configuration by adding all required values. - -We strongly recommend trying the first option (the simple way) first as it proved to be faster and less troublesome, yet enough for testing the theme. -Choose the hard way if your project already has significant `conf.py` customisation that would be difficult to recreate from the Sample `conf.py` for Ulwazi. - -### The simple way - -Here is the simple way of trying Ulwazi: - -1. Copy the [Sample `conf.py` for Ulwazi](https://github.com/canonical/ulwazi/blob/main/docs/default-conf.py) file inside your documentation folder. -2. Rename the old `conf.py` to some other name, like `old-conf.py`. -3. Rename the sample configuration file to `conf.py`. -4. Open the old and new files side by side and update relevant values in the new configuration file for your specific product and documentation. - -### The hard way - -The following instructions describe the modifications needed to support Ulwazi in an existing `conf.py` file. -Use this approach if you want to preserve as much of your original `conf.py` as possible, for example in a heavily customised deployment or when troubleshooting a configuration issue. - -For an example of all the changes, see the [Charmed Apache Kafka Ulwazi PR](https://github.com/canonical/kafka-operator/pull/444/files#diff-85933aa74a2d66c3e4dcdf7a9ad8397f5a7971080d34ef1108296a7c6b69e7e3). - -#### Set the theme - -Tell Sphinx to use Ulwazi as the theme: - -```{code-block} python -:caption: conf\.py - -html_theme = "ulwazi" -``` - -#### Update the extensions - -In the list of extensions, replace Canonical Sphinx with Ulwazi and its dependencies: - -```{code-block} diff -:caption: extensions in conf\.py - --"canonical-sphinx~=0.6", -+"ulwazi", -+"sphinx_terminal", -+"canonical_sphinx_config", -+"myst_parser", -+"sphinxcontrib.jquery", -``` - -If you need **PDF output**, add `sphinx_modern_pdf_style` to the extensions list and `sphinx-modern-pdf-style` to `requirements.txt`. - -```{caution} -Your project may require additional extensions beyond those listed here. -``` - -#### Add the required variables - -Add and fill the following variables immediately before `html_context = {`: - -```python -# TODO: Adjust to point to the repository where your documentation source files -# are stored. - -github_repo = - -# TODO: Select the default syntax for docs source files. -# This is for a fallback view/edit source code buttons. - -default_source_extension = ".md" - -# TODO: Change to your product website URL, -# dropping the 'https://' prefix, e.g. 'ubuntu.com/lxd'. - -product_page = -``` - -If your project is written in reST, set `default_source_extension` to `".rst"`. - -#### Update the HTML context - -You need to make several updates to the `html_context` dictionary. - -The code snippets in this section might not match the exact layout of `html_context` in your `conf.py`. - -Add these new variables, including the top-level variables you declared earlier: - -```{code-block} python -:caption: html_context in conf\.py - -"product_page": product_page, # was: "your-product.example.com" -"github_url": github_repo, # was: "https://github.com/your-org/your-repo" -"license": { - "name": "Apache-2.0", # TODO: set your license - "url": github_repo + "/blob/main/LICENSE", -}, -``` - -Add these entries so the theme can display the project name and author without duplicating them: - -```{code-block} python -:caption: html_context in conf\.py - -"project": project, -"author": author, -``` - -Add these entries to configure the settings related to your GitHub repository. -`default_edit_url` and `default_view_url` serve as fallback URLs for the view/edit source buttons on pages that do not have a specific source file path set. - -```{code-block} python -:caption: html_context in conf\.py - -"feedback": True, -"github_issues": "enabled", -"default_source_extension": default_source_extension, -"default_edit_url": github_repo + "/edit/main/docs/index" + default_source_extension, -"default_view_url": github_repo + "/blob/main/docs/index" + default_source_extension, -``` - -Add the horizontal navigation menu configuration: - -```{code-block} python -:caption: html_context in conf\.py - -# Horizontal Nav Menu -"company": "Canonical", -# "link1_URL": "https://example.com/", -# "link1_name": "First optional link", -# "link2_URL": "https://example.com/", -# "link2_name": "Second optional link", -``` - -Uncomment and adjust the parameters for `link1` and `link2` if you want to add the links in the top navigation bar. - -Add main logo parameters and adjust their values for your documentation: - -```{code-block} python -:caption: html_context in conf\.py - -# Canonical Product menu -# Uncomment if you need a product menu added on the top of every page -# "add_product_menu": True, - -"logo_link_URL": "https://documentation.ubuntu.com", -"logo_img_URL": "https://assets.ubuntu.com/v1/82818827-CoF_white.svg", -"logo_title": "Canonical", -``` - -Add the following parameters for the footer. - -```{code-block} python -:caption: html_context in conf\.py - -# TODO: Customize the footer. -"footer": { - # Whether to add the product name as the first entry. - "product": True, - # Whether to add the license as the second entry. - "license": True, - # List your footer entries. Accepts HTML tags. - "entries": [ - 'Manage your tracker settings', - ] -} -``` - -#### Add syntax highlighting - -Add these syntax highlighting settings after the list of extensions: - -```{code-block} python -:caption: conf\.py - -highlight_language = "none" # default -pygments_style = "autumn" # see https://pygments.org/styles for more -``` - -#### Configure the sitemap - -Add the lastmod setting to the sitemap section: - -```{code-block} python -:caption: conf\.py - -sitemap_show_lastmod = True -``` - -#### Configure PDF output - -If you need to render your docs to PDF, add the following at the end of the configuration: - -```{code-block} python -:caption: conf\.py - -set_modern_pdf_config = True -``` - -#### Update the copyright - -The Ulwazi theme expects a plain year string rather than the older {spellexception}`CC-BY-SA` format. - -```{code-block} python -:caption: conf\.py - -copyright = f"{datetime.date.today().year}" -``` - -The license information is now conveyed through the "license" key in "html_context". - -## Test the documentation - -Once configuration is complete, make sure the required extensions are listed in both the `extensions` list in `conf.py` and the `requirements.txt` file. - -Build the documentation from scratch by first cleaning out any existing build files: - -```shell -cd docs -make clean -make run -``` - -If the build fails, check the build logs to identify the cause. -Common issues are: - -1. Missing extensions -2. Missing required values in `conf.py` - -Fix any issues and rebuild. - -Once the build succeeds, a local server starts at http://127.0.0.1:8000. Open that URL in your browser to verify that the pages render correctly. - -Report issues or feature requests in the [Ulwazi GitHub repository](https://github.com/canonical/ulwazi/issues/new). diff --git a/docs/explanation/assets/components.yaml b/docs/explanation/assets/components.yaml deleted file mode 100644 index 4918b05c..00000000 --- a/docs/explanation/assets/components.yaml +++ /dev/null @@ -1,68 +0,0 @@ -# This file contains the recipes for the Mermaid diagrams used in components.md -documentation_architecture: - - diagram_name: "Sphinx" - description: "The core process of transforming source files into HTML using Sphinx." - mermaid_code: | - graph LR - A["Source Files
(.rst or .md)"] -->|provides content to| C[Sphinx] - B["Configuration
(docs/conf.py)"] -->|provides settings to| C - C -->|generates| D[Built HTML Pages] - rendered_image: "sphinx.png" - - - diagram_name: "Python environment" - description: "The relationship between the host system and the virtual environment." - mermaid_code: | - graph LR - subgraph Host ["Host"] - direction LR - pip[pip] -->|installs| PD["Project dependencies"] - python3[python3] --> Sphinx - venv[venv] -->|creates| VE["Virtual environment"] - subgraph VE ["Virtual environment"] - direction LR - PD -->|extend| Sphinx - end - Sphinx -->|builds| HTML[HTML] - end - rendered_image: "python-starter-pack.png" - - - diagram_name: "Extensions" - description: "How built-in and third-party extensions are integrated and activated via requirements and conf.py." - mermaid_code: | - graph TD - Python -->|installs the contents of| Reqs[/"requirements.txt"\] - Reqs -->|specifies| ThirdParty["Third-party extensions"] - Sphinx -->|provides| BuiltIn["Built-in Sphinx extensions"] - subgraph Deps ["Various dependencies"] - BuiltIn - ThirdParty - end - BuiltIn -->|are activated in| Conf[/"Project configuration file (docs/conf.py)"\] - ThirdParty -->|are activated in| Conf - rendered_image: "extensions.png" - - - diagram_name: "Read the Docs" - description: "Details the declaration of build logic in the RTD configuration file for hosting." - mermaid_code: | - graph TD - Sphinx -->|is declared in| RTD_Conf[/"RTD configuration file (.readthedocs.yaml)"\] - Conf_py["conf.py"] -->|is declared in| RTD_Conf - Python_Ver["Python version"] -->|is declared in| RTD_Conf - RTD_Conf -->|defines the build logic for| RTD["Read the Docs (RTD)"] - RTD -->|builds and hosts| HTML[/"HTML"\] - rendered_image: "rtd-build.png" - - - diagram_name: "Third-party extensions" - description: "Focuses on the specific installation path for external dependencies via pip and requirements." - mermaid_code: | - graph TD - Python[Python] - Reqs[/"requirements.txt"\] - Sphinx[Sphinx] - subgraph Deps ["Various dependencies"] - BuiltIn["Built-in Sphinx extensions"] - ThirdParty["Third-party extensions"] - end - Python -->|installs the contents of| Reqs - Reqs -->|specifies| ThirdParty - rendered_image: "third-party-extensions.png" \ No newline at end of file diff --git a/docs/explanation/assets/extensions.png b/docs/explanation/assets/extensions.png deleted file mode 100644 index 182275c7..00000000 Binary files a/docs/explanation/assets/extensions.png and /dev/null differ diff --git a/docs/explanation/assets/python-starter-pack.png b/docs/explanation/assets/python-starter-pack.png deleted file mode 100644 index 5aece070..00000000 Binary files a/docs/explanation/assets/python-starter-pack.png and /dev/null differ diff --git a/docs/explanation/assets/rtd-build.png b/docs/explanation/assets/rtd-build.png deleted file mode 100644 index e423a6ba..00000000 Binary files a/docs/explanation/assets/rtd-build.png and /dev/null differ diff --git a/docs/explanation/assets/sphinx.png b/docs/explanation/assets/sphinx.png deleted file mode 100644 index 710fbe59..00000000 Binary files a/docs/explanation/assets/sphinx.png and /dev/null differ diff --git a/docs/explanation/assets/third-party.png b/docs/explanation/assets/third-party.png deleted file mode 100644 index f7720999..00000000 Binary files a/docs/explanation/assets/third-party.png and /dev/null differ diff --git a/docs/explanation/build.rst b/docs/explanation/build.rst deleted file mode 100644 index 1fb8ce7b..00000000 --- a/docs/explanation/build.rst +++ /dev/null @@ -1,78 +0,0 @@ -.. meta:: - :description: Learn about the function, structure, and design of the build process in Canonical's Starter Pack. - -:relatedlinks: [GNU Make](https://www.gnu.org/software/make/) - - -.. _build: - -Build -====== - -Canonical's Starter Pack uses Make as its build system. Make was chosen because it's -well-tested and available on all platforms. The majority of the build configuration is -defined in ``docs/Makefile``. - -Make is also the user interface for operating a project's docs. Authors and developers -call all docs actions with ``make ``. - -The docs build depends on environment variables like ``BUILDDIR`` to locate critical -files. They are conditional variables, so other systems can invoke the build at -different locations without changing the docs ``Makefile``. - -Being primarily a Python project, all dependencies are stored in a virtual environment, -``docs/.venv`` by default. The environment is ephemeral and subject to frequent change. -Installing the Starter Pack initializes it, while cleaning and updating tears it -down and rebuilds it. - - -.. _explanation-parent-project-build: - -Parent projects and the build ------------------------------ - -The Starter Pack is arranged as a standalone project. When it's used in a larger -project, the docs are a subsystem among other components. - -If the parent project uses a build system, Make or otherwise, the doc build exists in -parallel with the parent build. When embedded, the virtual environment and build recipe -files would be arranged along these lines: - -.. code-block:: - - Project - │ - ├── ... - ├── docs - │ ├── ... - │ ├── .venv - │ └── Makefile - ├── src - │ └── ... - ├── - └── - -With embedded docs, the parent build doesn't mesh with the docs build, which can cause -difficulty: - -- Contributors typically call the build commands from the root of the project. Some will - find it inconvenient to run the docs commands by switching to the ``docs`` directory - or manually calling the docs Makefile with ``make -C docs ``. -- Storing multiple virtual environments bloats the host system. It's reasonable for - project maintainers to prefer a shared build environment. -- The Starter Pack's update process can make changes to many files in the ``docs`` - directory. Updating is potentially much simpler if the parent project modifies only - a minimum of files in the directory. -- With quality assurance and continuous integration, it's simpler if the project can use - the same interface to run local and remote checks. More specifically, the parent build - system and CI need a way to call the Starter Pack's ``links``, ``spelling``, and - ``vale`` checks. - -One possible resolution is for the parent build to manually recreate the docs build, -tightly coupling the parent build to the existing docs configuration. But this poses -another challenge, because the docs ``Makefile`` might change during a Starter Pack -update, requiring a rewrite of the parent build recipes. - -The solution to these complications is to create a bridge between the two builds, from -the parent build to the docs ``Makefile``. -:ref:`bridge-project-and-docs-builds` is a guide for how to do this. diff --git a/docs/explanation/components.rst b/docs/explanation/components.rst deleted file mode 100644 index 79b402ea..00000000 --- a/docs/explanation/components.rst +++ /dev/null @@ -1,137 +0,0 @@ -.. meta:: - :description: A breakdown of Canonical's Sphinx Starter Pack that covers its constituent elements and their purpose. - -.. _explanation-structure: - -Starter Pack structure -======================= - -The Starter Pack is a template `Sphinx `__ -project. It provides a default file structure, a theme, and dependencies for Canonical -documentation. - - -Sphinx ------- - -Sphinx is a documentation static site generator that converts reStructuredText or -Markdown files into HTML. It's the core software in the Starter Pack. - -``docs/conf.py`` is a configuration file that defines the properties of the Sphinx -project such as project metadata and extensions. - -.. figure:: assets/sphinx.png - :class: with-border - - Sphinx as a documentation static site generator - - -Python ------- - -Because Sphinx is a Python application, the Starter Pack depends on Python and a Python -package manager. Most of its dependencies are Python packages. Local builds of the -Starter Pack require a Python virtual environment to isolate the project from the host -system. - -To be able to work on a Starter Pack project, your host needs Python 3.11, pip, and venv. - -.. figure:: assets/python-starter-pack.png - :class: with-border - - Python's role in the Starter Pack - - -Sphinx extensions ------------------ - -The syntax and behavior of Sphinx can be modified with extensions. These can be used to -create diagrams, test code, and more. - -The Starter Pack includes a curated and tested set of extensions. - -.. figure:: assets/extensions.png - :class: with-border - - Extension types - - -Built-in extensions -~~~~~~~~~~~~~~~~~~~ - -Built-in extensions do not need to be installed separately from Sphinx and can be -enabled through the configuration file. The ``conf.py`` file has already been -configured to enabled typical extensions necessary for documentation work. - - -Third-party extensions -~~~~~~~~~~~~~~~~~~~~~~ - -If an extension is not built into Sphinx, you must include it in the -``requirements.txt`` file before enabling it in the Sphinx configuration file. - -Extensions are Python packages, and the Starter Pack manages them with a -`requirements.txt `__ -file. - -.. figure:: assets/third-party.png - :class: with-border - - Third-party extensions - - -Markdown support -^^^^^^^^^^^^^^^^ - -By default, Sphinx uses reStructuredText. Markdown is supported through the `MyST parser -`_, which is enabled with the -``myst-parser`` extension. - - -Canonical theme -^^^^^^^^^^^^^^^ - -The Canonical theme is packaged as a standalone `canonical-sphinx -`_) extension. It is based on `Furo -`__ and is designed to follow Canonical branding. - - -Command-line tools ------------------- - -The Starter Pack uses Make as its local build system. The Starter Pack's Makefile -provides a command-line interface for setting up the virtual environment, installing -dependencies, building the documentation, and more. - - -Makefile -~~~~~~~~ - -Some of the Makefile targets (such as ``html`` and ``linkcheck``) provide Sphinx-native -functionality for building documentation or performing tests in a simplified form while -managing required dependencies. For example, instead of using the ``sphinx-build -linkcheck SOURCEDIR OUTPUTDIR`` command, you can use ``make linkcheck``. - -See :ref:`build` to learn how the local build process works. - -Additionally, the Makefile provides commands to trigger third-party CLI tools, such as -the Vale prose linter for :ref:`Style guide linting `. - - -Read The Docs configuration file --------------------------------- - -Read The Docs is a documentation building and hosting platform. It takes the -documentation created using Sphinx (or other tools) and builds and publishes it online. - -If you are publishing your documentation through Read the Docs, the Read the Docs build -logic is declared in ``.readthedocs.yaml``. The Starter Pack comes with a pre-configured -``.readthedocs.yaml`` with default values that should work for the majority of projects. - -See :ref:`publish-on-rtd` to learn how configure your Read the Docs instance. - -.. figure:: assets/rtd-build.png - :class: with-border - - Read the Docs build configuration - diff --git a/docs/explanation/index.rst b/docs/explanation/index.rst index e4a11125..f8ded01b 100644 --- a/docs/explanation/index.rst +++ b/docs/explanation/index.rst @@ -1,20 +1,4 @@ -.. meta:: - :description: Explore topics about the concepts and ideas in Canonical's Starter Pack. - - .. _explanation: Explanation =========== - -Explore topics about the concepts and ideas in Canonical's Starter Pack. - -The Starter Pack is built using standard Python tools, and is both deep and flexible. - -.. toctree:: - :maxdepth: 1 - - components - build - sitemaps - diff --git a/docs/explanation/sitemaps.rst b/docs/explanation/sitemaps.rst deleted file mode 100644 index d588d2c2..00000000 --- a/docs/explanation/sitemaps.rst +++ /dev/null @@ -1,190 +0,0 @@ -.. meta:: - :description: An in-depth look at the sitemaps feature in the Starter Pack, including configuration, validation, and versioning. - -.. _sitemaps: - -Sitemaps -========= - -The latest version of the Starter Pack generates a sitemap for your documentation -using the `sphinx-sitemap `_ -extension. - -This page goes over the nuances of configuring sitemaps, as well as how the -extension must be configured in your Starter Pack project. - -Read the Docs-generated sitemaps ---------------------------------- - -RTD generates a basic sitemap pointing to the index page, and relies on -crawlers to index the site. This is sufficient for some projects, but RTD -does not generate sitemaps for subprojects. - -This means any project under the Ubuntu documentation library project must -generate its own sitemap. - -``sphinx-sitemap``-generated sitemaps --------------------------------------- - -The standard Starter Pack uses the ``dirhtml`` builder for Sphinx recipes in the -project's Makefile. - -If your project uses an older version of the Starter Pack or -changes the builder, the links generated by the sitemap will be malformed. Either -:ref:`update to the latest version of the Starter Pack ` or -ensure your project's recipes use the ``dirhtml`` builder, not ``html``. - -Ensure ``sphinx-sitemap`` has been added to your ``docs/requirements.txt`` file. - -Add ``sphinx_sitemap`` to ``extensions`` in your configuration file (:file:`docs/conf.py`): - -.. code-block:: - - extensions = ['sphinx_sitemap'] - -Sitemap configuration -^^^^^^^^^^^^^^^^^^^^^ - -The Starter Pack's configuration file (:file:`docs/conf.py`) includes default sitemap configuration. - -The ``sphinx-sitemap`` extension requires a ``html_baseurl`` variable to be configured. - -This is set by default as follows: - -.. code-block:: python - - html_baseurl = os.environ.get("READTHEDOCS_CANONICAL_URL", "/") - -When building on Read the Docs, this sets ``html_baseurl`` dynamically to the value of the -``READTHEDOCS_CANONICAL_URL`` environment variable, which resolves to the full URL of the documentation -including the version and language (if applicable). - -In local builds and builds on other hosts, ``html_baseurl`` defaults to ``/``. - -The ``sitemap_url_scheme`` variable is set to ``'{link}'`` by default. This uses the value of ``html_baseurl`` to generate -the full URL for each page for the sitemap. - -.. note:: - - If you are implementing a sitemap on an RTD instance that is not a subproject, - and it uses ``{link}`` for the ``sitemap_url_scheme``, RTD will replace your - sitemap with their own. - - This is a known bug. The only current workaround is to use a different - `sitemap name `_ - and a custom ``robots.txt`` pointing to it. - -``lastmod`` configuration -^^^^^^^^^^^^^^^^^^^^^^^^^^ - -As of version 2.7.0, the sitemap extension supports adding a ``lastmod`` date. -Make sure that your configuration file has:: - - sitemap_show_lastmod = True - -Exclude pages -------------- - -Pages can be excluded from the sitemap by adding them to `sitemap_excludes` in :file:`docs/conf.py`:: - - sitemap_excludes = [ - '404/', - 'genindex/', - 'search/', - ] - -Wildcards are supported. For example, ``_modules/*`` excludes the path ``_modules/`` and all paths such as ``_modules/foo/bar/``. For details, see `Excluding Pages `_. - -Validate your sitemap ---------------------- - -A sitemap will be available at different locations, depending on how it is -generated. - -Read the Docs generated sitemaps are available at the base domain of a project, -while sitemaps generated with this extension will be placed in the base of the URL -schema used. - -For example, two sitemaps are generated for the Sphinx sitemap's documentation -as it is hosted on RTD: - -* The first is generated by RTD and is available at the root of the domain: https://sphinx-sitemap.readthedocs.io/sitemap.xml -* The second is generated by the `sphinx-sitemap` extension and is available at the base of the URL schema used by the RTD instance: https://sphinx-sitemap.readthedocs.io/en/latest/sitemap.xml - -.. dropdown:: How to specify a sitemap - - A `robots.txt` file dictates which sitemap is used to index a website. You - can use a custom `robots.txt` file by creating your own and adding it to - `html_static_path` in your configuration file. An example can be found in the - `Ubuntu documentation library `_ - project. - -Support multiple versions -------------------------- - -The sphinx-sitemap extension doesn't support multiple versions by default. Configuring -your versioned documentation to use an appropriate version may be sufficient, as search -engines and other web systems crawl websites for the purposes of indexing. - -If you want sitemaps for all your documentation's versions, you need to deploy your own -``robots.txt`` file and sitemap index. Supporting multiple versions is recommended for -documentation with LTS releases, as it makes past versions more prominent to search -engines. - -For this task, we'll use the Starter Pack as an example. Let's assume it has three -versions, 1.0, 2.0, and 3.0, and uses the URL schema of ``/``. - -First, ensure each version of your documentation has a sitemap generated by this -extension with the appropriate version. - -Next, create a ``sitemapindex.xml`` file in the same directory as the configuration -file, and point to the sitemap files of each of your documentation sets: - -.. code-block:: xml - :caption: sitemapindex.xml - - - - https://canonical-starter-pack.readthedocs-hosted.com/stable/sitemap.xml - - - https://canonical-starter-pack.readthedocs-hosted.com/3.0/sitemap.xml - - - https://canonical-starter-pack.readthedocs-hosted.com/2.0/sitemap.xml - - - https://canonical-starter-pack.readthedocs-hosted.com/1.0/sitemap.xml - - - -Create a ``robots.txt`` file in the same directory as the configuration file. - -If necessary, block any paths you don't want crawled. Google describes how to do this in -`How to write and submit a robots.txt file -`__. - -At the end of ``robots.txt``, point to the future path of ``sitemapindex.xml``: - -.. code-block:: - :caption: robots.txt - - Sitemap: https://canonical-starter-pack.readthedocs-hosted.com/stable/sitemapindex.xml - -Lastly, add both new files to the configuration file: - -.. code-block:: - :caption: conf.py - - html_extra_path = [ - "sitemapindex.xml", - "robots.txt", - ] - -This provides a ``sitemapindex.xml`` file which points to the ``sphinx-sitemap`` -generated sitemap for each version. - -You may want to automate the generation of the ``sitemapindex.xml`` file. To see how -this is done for the Ubuntu documentation library project, which generates a sitemap -containing subproject sitemaps, see `the script here -`_. diff --git a/docs/how-to/assets/mermaid.txt b/docs/how-to/assets/mermaid.txt deleted file mode 100644 index 68ec1b56..00000000 --- a/docs/how-to/assets/mermaid.txt +++ /dev/null @@ -1,313 +0,0 @@ -mermaid-diagram-flowchart-start -``````{tab-set} - -`````{tab-item} Diagram -```{image} https://assets.ubuntu.com/v1/34c7105c-screenshot_from_2025_10_13_15_05_56.png -``` -````` - -`````{tab-item} MyST - -````{code-block} md -```{mermaid} -flowchart LR - A([New PR]) - B[Needs review] - C{Review approved?} - D{Merge conflicts?} - E[Needs work] - F[Needs CI] - G{Passed testing?} - H[Ready for merge] - I[(PR merged)] - J{Comments addressed?} - K[(PR closed)] - - A --> B - B --> C - C -- no --> E - C -- yes --> D - D -- yes --> E - D -- no --> F - F --> G - G -- yes --> H - G -- no --> E - H --> I - E --> J - J -- yes --> B - J -- no --> K -``` -```` - -````` - -`````{tab-item} rST - -````{code-block} rst -.. mermaid:: - - flowchart LR - A([New PR]) - B[Needs review] - C{Review approved?} - D{Merge conflicts?} - E[Needs work] - F[Needs CI] - G{Passed testing?} - H[Ready for merge] - I[(PR merged)] - J{Comments addressed?} - K[(PR closed)] - - A --> B - B --> C - C -- no --> E - C -- yes --> D - D -- yes --> E - D -- no --> F - F --> G - G -- yes --> H - G -- no --> E - H --> I - E --> J - J -- yes --> B - J -- no --> K -```` - -````` -`````` -mermaid-diagram-flowchart-end - -mermaid-diagram-sequence-start -``````{tab-set} - -`````{tab-item} Diagram - -```{image} https://assets.ubuntu.com/v1/a7eb0fcf-screenshot_from_2025_10_13_15_08_06.png -``` - -````` - -`````{tab-item} Custom CSS - -First, create a Mermaid stylesheet in the {file}`_static` directory and -customize it as needed. For example, {file}`mermaid-sequence.css`. - -Then, enable custom stylesheets in {file}`conf.py`. -Uncomment this line so Sphinx can use local stylesheets: - -```{code-block} py -:caption: conf\.py - -html_static_path = ["_static"] -``` - -Link to your custom Mermaid stylesheet: - -```{code-block} py -:caption: conf\.py - -html_css_files = [ - "mermaid-sequence.css", -] -``` - -Here's an example stylesheet that changes the default typefaces and colors of Mermaid components. -It also sets a solid background color for all Mermaid diagrams. - -```{code-block} css -:caption: mermaid-sequence.css - -.actor { - stroke: #eb6536 !important; - stroke-width: 2; - fill: #f5b29b !important; -} - -text.actor { - fill: black; - stroke: none; - font-family: Helvetica; -} - -.actor-line { - stroke: #77216f; -} - -.mermaid { - background-color: #f0f0f0; - border: 1px solid #ccc; - border-radius: 6px; - padding: 0.5em; -} -``` -````` - -`````{tab-item} MyST - -````{code-block} md -```{mermaid} -sequenceDiagram - participant User - participant Snap as snapd (Client) - participant Store as Snap Store - participant System - - User->>Snap: snap install hello - Snap->>Store: Request snap info and download - Store-->>Snap: Return snap package - Snap->>System: Install and mount snap - System-->>Snap: Installation result - Snap-->>User: Confirm snap is installed -``` -```` - -````` - -`````{tab-item} rST - -````{code-block} rst -.. mermaid:: - - sequenceDiagram - participant User - participant Snap as snapd (Client) - participant Store as Snap Store - participant System - - User->>Snap: snap install hello - Snap->>Store: Request snap info and download - Store-->>Snap: Return snap package - Snap->>System: Install and mount snap - System-->>Snap: Installation result - Snap-->>User: Confirm snap is installed -```` - -````` -`````` -mermaid-diagram-sequence-end - -mermaid-diagram-timeline-start -``````{tab-set} - -`````{tab-item} Diagram - -```{image} https://assets.ubuntu.com/v1/24895eed-screenshot_from_2025_10_13_15_06_35.png -``` - -````` - -`````{tab-item} MyST - -````{code-block} md -:emphasize-lines: 2 -```{mermaid} -%%{init: {"theme":"forest"}}%% -timeline - title Ubuntu recent releases - - 2020 : 20.04 LTS (Focal Fossa) : 20.10 (Groovy Gorilla) - 2021 : 21.04 (Hirsute Hippo) : 21.10 (Impish Indri) - 2022 : 22.04 LTS (Jammy Jellyfish) : 22.10 (Kinetic Kudu) - 2023 : 23.04 (Lunar Lobster) : 23.10 (Mantic Minotaur) - 2024 : 24.04 LTS (Noble Numbat) : 24.10 (Oracular Oriole) - 2025 : 25.04 (Plucky Puffin) -``` -```` - -````` - -`````{tab-item} rST - -````{code-block} rst -:emphasize-lines: 3 - -.. mermaid:: - - %%{init: {"theme":"forest"}}%% - timeline - title Ubuntu recent releases - - 2020 : 20.04 LTS (Focal Fossa) : 20.10 (Groovy Gorilla) - 2021 : 21.04 (Hirsute Hippo) : 21.10 (Impish Indri) - 2022 : 22.04 LTS (Jammy Jellyfish) : 22.10 (Kinetic Kudu) - 2023 : 23.04 (Lunar Lobster) : 23.10 (Mantic Minotaur) - 2024 : 24.04 LTS (Noble Numbat) : 24.10 (Oracular Oriole) - 2025 : 25.04 (Plucky Puffin) -```` - -````` -`````` -mermaid-diagram-timeline-end - -mermaid-diagram-state-start -``````{tab-set} - -`````{tab-item} Diagram - -```{image} https://assets.ubuntu.com/v1/dd4fb237-screenshot_from_2025_10_13_15_08_51.png -``` - -````` - -`````{tab-item} MyST - -````{code-block} md -:emphasize-lines: 3-6, 17-20 - -```{mermaid} -stateDiagram-v2 - classDef review fill:#FCE83A - classDef approved fill:#2DCCFF - classDef published fill:#56F000 - classDef archived fill:#7B8089 - - [*] --> Draft - Draft --> Review : submit for review - Review --> Draft : changes requested - Review --> Approved : review passed - Approved --> Build : trigger build - Build --> Published : build success - Build --> Draft : build failed - Published --> Archived : old version - - class Review review - class Approved approved - class Published published - class Archived archived -``` -```` - -````` - -`````{tab-item} rST - -````{code-block} rst -:emphasize-lines: 4-7, 18-21 - -.. mermaid:: - - stateDiagram-v2 - classDef review fill:#FCE83A - classDef approved fill:#2DCCFF - classDef published fill:#56F000 - classDef archived fill:#7B8089 - - [*] --> Draft - Draft --> Review : submit for review - Review --> Draft : changes requested - Review --> Approved : review passed - Approved --> Build : trigger build - Build --> Published : build success - Build --> Draft : build failed - Published --> Archived : old version - - class Review review - class Approved approved - class Published published - class Archived archived -```` - -````` -`````` -mermaid-diagram-state-end \ No newline at end of file diff --git a/docs/how-to/assets/openapi._rst b/docs/how-to/assets/openapi._rst deleted file mode 100644 index 396913a9..00000000 --- a/docs/how-to/assets/openapi._rst +++ /dev/null @@ -1,22 +0,0 @@ -.. raw:: html - - -
- - - \ No newline at end of file diff --git a/docs/how-to/assets/openapi.yaml b/docs/how-to/assets/openapi.yaml deleted file mode 100644 index 4e53d08c..00000000 --- a/docs/how-to/assets/openapi.yaml +++ /dev/null @@ -1,24 +0,0 @@ -openapi: 3.0.3 -info: - title: Hello API - version: 1.0.0 -paths: - /hello: - get: - summary: Say hello - parameters: - - in: query - name: name - schema: - type: string - responses: - "200": - description: OK - content: - application/json: - schema: - type: object - properties: - message: - type: string - example: "Hello, world!" diff --git a/docs/how-to/assets/troubleshoot-stable-zombie-version.png b/docs/how-to/assets/troubleshoot-stable-zombie-version.png deleted file mode 100644 index 624aac1a..00000000 Binary files a/docs/how-to/assets/troubleshoot-stable-zombie-version.png and /dev/null differ diff --git a/docs/how-to/build-and-preview.rst b/docs/how-to/build-and-preview.rst deleted file mode 100644 index fce9147c..00000000 --- a/docs/how-to/build-and-preview.rst +++ /dev/null @@ -1,167 +0,0 @@ -.. meta:: - :description: How to set up your environment and use make commands to build and preview documentation locally. - -.. _build-and-preview: - -Build and preview -================= - -The Starter Pack provides a :file:`Makefile` that defines :command:`make` commands to build and view the documentation. - -This guide describes how to set up your environment and use these commands to build and preview the documentation locally. - -For more advanced information, including how to embed your docs build with your project build, see: - -- :ref:`build` -- :ref:`bridge-project-and-docs-builds` - -Install prerequisite software ------------------------------ - -The documentation framework that the Starter Pack uses bundles most prerequisites in a Python virtual environment, so you don't need to worry about installing them. -There are only a few packages that you need to install on your host system. - -Before you start, make sure that you have ``make``, ``python3``, ``python3-venv``, and ``python3-pip`` on your system:: - - sudo apt update - sudo apt install make python3 python3-venv python3-pip - -Python environment ------------------- - -The Python prerequisites from the :file:`docs/requirements.txt` file are automatically installed when you build the documentation. - -If you want to install them manually, you can run the following command from within your documentation folder:: - - make install - -This command creates a virtual environment (:file:`.venv/`) and installs dependency software within it. - -If you want to remove the installed Python packages (for example, to enforce a re-installation), run the following command from within your documentation folder:: - - make clean - -.. note:: - - By default, the Starter Pack uses the latest compatible version of all tools and does not pin its requirements. - This might change temporarily if there is an incompatibility with a new tool version. - There is therefore no need to use a tool like Renovate to automatically update the requirements. - - - If you encounter the error ``locale.Error: unsupported locale setting`` when activating the Python virtual environment, include the environment variable in the command and try again: ``LC_ALL=en_US.UTF-8 make run`` - - -.. important:: - Run these commands from within your documentation folder. - -.. _build-docs: - -Build the documentation ------------------------ - -To build the documentation, run the following command:: - - make html - -This command installs the required tools and renders the output to the :file:`_build/` folder in your documentation folder. - -.. important:: - When you run :command:`make html` again, it updates the documentation for changed files only. - - This speeds up the build, but it can cause you to miss warnings or errors that were displayed before. - To force a clean build, see :ref:`build-clean`. - -Make sure that the documentation builds without any warnings (warnings are treated as errors). - -.. _build-clean: - -Run a clean build ------------------ - -To delete all existing output files and build all files again, run the following command:: - - make clean-doc html - -To delete both the existing output files and the Python environment and build the full documentation again, run the following command:: - - make clean html - -View the documentation ----------------------- - -To view the documentation output, run the following command:: - - make serve - -This command builds the documentation and serves it on :literalref:`http://127.0.0.1:8000/`. - - -Live view ---------- - -Instead of building the documentation for each change and then serving it, you can run a live preview of the documentation:: - - make run - -This command builds the documentation and serves it on :literalref:`http://127.0.0.1:8000/`. -When you change a documentation file and save it, the documentation will be automatically rebuilt and refreshed in the browser. - -If you need project-specific options for ``sphinx-autobuild`` such as ``--ignore`` or ``--watch``, pass them through ``SPHINX_AUTOBUILD_OPTS``:: - - make run SPHINX_AUTOBUILD_OPTS="--ignore '**/*.gen.rst' --watch ../data/" - -If you call ``make run`` from a :ref:`parent project's build `, pass the variable explicitly to the sub-Make call to ensure it reaches the docs Makefile:: - - $(MAKE) -C docs run SPHINX_AUTOBUILD_OPTS="$(SPHINX_AUTOBUILD_OPTS)" - -This approach allows command-line overrides to work intuitively from the parent context. - -.. important:: - The :command:`run` target is very convenient while working on documentation updates. - - However, it is quite error-prone because it displays warnings or errors only when they occur. - If you save other files later, you might miss these messages. - - Therefore, you should always :ref:`build-clean` before finalising your changes. - -Build a PDF ------------ - -Build a PDF locally with the following command: - -.. code-block:: none - - make pdf - -PDF generation requires specific software packages. If these files are not found, a prompt will be presented and the generation will stop. - -Required software packages include: - -* dvipng -* fonts-freefont-otf -* latexmk -* plantuml -* tex-gyre -* texlive-font-utils -* texlive-fonts-recommended -* texlive-lang-cjk -* texlive-latex-extra -* texlive-latex-recommended -* texlive-xetex -* xindy - -On Linux, required packages can be installed with: - -.. code-block:: none - - make pdf-prep-force - -.. note:: - - When generating a PDF, the index page is considered a 'foreword' and will not be labelled with a chapter. - -.. important:: - - When generating a PDF, it is important to not use additional headings before a ``toctree``. Documents referenced by the - ``toctree`` will be nested under any provided headings. - - A ``rubric`` directive can be combined with the ``h2`` class to provide a heading-styled rubric in the HTML output. See the default ``index.rst`` for an example. - Rubric-based headings aren't included as entries in the table of contents or the navigation sidebar. diff --git a/docs/how-to/configure-your-project.rst b/docs/how-to/configure-your-project.rst deleted file mode 100644 index b9d99b72..00000000 --- a/docs/how-to/configure-your-project.rst +++ /dev/null @@ -1,178 +0,0 @@ -.. meta:: - :description: How to configure project-specific parameters. - -.. _configure-your-project: - -Configure your project -====================== - -While the Starter Pack provides default configuration values for most settings, you'll need to set project-specific parameters like the project name to ensure the documentation reflects your project accurately. - -.. important:: - - After setting up your repository with the Starter Pack, you should track the changes made to the Starter Pack. - - Changes to the look and feel, as well as common functionality, will be automatically available through updates to the `Canonical Sphinx `_ extension. - - Changes to files that are part of the Starter Pack, for example changes made during steps in :ref:`run-documentation-checks`, might require you to manually update your repository with the required files. - See the Starter Pack's `change log `_ for the most relevant (and of course all breaking) changes. - -Configuration for a Starter Pack based documentation is set in the :file:`docs/conf.py` Sphinx configuration file. - -The Starter Pack's default configuration is prepared in a way that makes sense for most projects. -However, you must set some critical parameters that are unique for your project, like the project's name. - -In addition, you can find some optional parameters or add your own configuration parameters to the file. - -Required customisation ----------------------- - -You must check and update some of the parameters specific to your project. -Mandatory parameters are commented with the `TODO` keyword. - -The following are some highlights of the available configuration parameters. - -Update the project information -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Edit the :file:`docs/conf.py` file and update the configuration in the ``Project information`` section. -See the comments in the file for more information about each setting. - -Open Graph configuration -^^^^^^^^^^^^^^^^^^^^^^^^ - -When you post a link to your documentation somewhere (for example, on Mattermost or Discourse), it might be shown with a preview. -This preview is configured through the Open Graph Protocol (:spellexception:`OGP`) configuration. - -If you don't know yet where your documentation will be hosted, you can leave the URL empty. -If you do, specify the hosting URL. -You can leave the defaults for the website name and the preview image or specify your own. - -Optional customisation ----------------------- - -The Starter Pack contains several features that you can configure, or turn off if they aren't suitable for your documentation. - -Modify the template -~~~~~~~~~~~~~~~~~~~ - -The default Starter Pack templates provide an initial configuration for your documentation set, including: - -- Header template - The top section of the page that contains your product's tag image and name, a link to your product's page (if available), and a drop-down menu for "More resources". -- Footer template - The bottom section of the page that contains sequential navigation controls, copyright information, licensing details, and other relevant links. - -These project settings are configured in :file:`docs/conf.py` and are generally sufficient for most cases. -However, if you have additional requirements -- such as adding links to announcements or videos that are not part of the documentation -- you can override the default templates to customize them as needed. - -See the :ref:`custom-html-templates` guide for details on how to do so. - -Deactivate the feedback button -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -By default, the Starter Pack includes a feedback button at the top of each page. -This button redirects users to your GitHub issues page, and populates an issue for them with details of the page they were on when they clicked the button. - -If your project does not use GitHub issues, set the ``github_issues`` variable in the :file:`docs/conf.py` file to an empty value to disable both the feedback button and the issue link in the footer. - -If you want to deactivate the feedback button, but keep the link in the footer, set ``disable_feedback_button`` in the :file:`docs/conf.py` file to ``True``. - -Configure the contributor display -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -By default, the Starter Pack will display a list of contributors at the bottom of each page. -This requires the GitHub URL and folder to be configured. - -If you want to turn this contributor listing off, you can do so by setting the ``display_contributors`` variable in the :file:`docs/conf.py` file to ``False``. - -To configure that only recent contributors are displayed, you can set the ``display_contributors_since`` variable. -It takes any Linux date format (for example, a full date, or an expression like "3 months"). - -Add redirects -~~~~~~~~~~~~~ - -If you rename a source file, its URL will change. To prevent broken links, you should -add a redirect from the old URL to the new URL in this case. - -You can add redirects in the ``docs/redirects.txt`` file. The paths for internal -redirects are relative to the root of the docs project. - -.. code-block:: - - "path/to/old/page" "path/to/new/page" - -Destination paths can also be external URLs. - -.. code-block:: - - "path/to/old/page" "https://example.com/new-page" - -Configure included extensions -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -The Starter Pack includes a set of extensions that are useful for all documentation sets. -Some extensions are :ref:`enabled by default ` within the Starter Pack, but you can customize the selection in the :file:`docs/conf.py` file. - -The ``canonical_sphinx`` extension is required for the Starter Pack and provides the Furo-based theme and custom templates. - -To add new extensions needed for your documentation set, add them to the ``extensions`` parameter in :file:`docs/conf.py`. - -.. note:: - - If any additional extensions need specific Python packages, ensure they are installed alongside the other requirements by adding them to the :file:`docs/requirements.txt` file. - -Add page-specific configuration -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -You can override some global configuration for specific pages. - -For example, you can configure whether to display Previous/Next buttons at the bottom of pages by setting the ``sequential_nav`` variable in the :file:`docs/conf.py` file. - -.. code:: python - - html_context = { - ... - "sequential_nav": "both" - } - -You can then override this default setting for a specific page (for example, to turn off the Previous/Next buttons by default, but display them in a multi-page tutorial). - -To do so, add `file-wide metadata `_ at the top of a page. -See the following examples for how to enable Previous/Next buttons for one page: - -|RST|:: - - :sequential_nav: both - - [Page contents] - -MyST:: - - --- - sequential_nav: both - --- - - [Page contents] - -Possible values for the ``sequential_nav`` field are ``none``, ``prev``, ``next``, and ``both``. -See the :file:`docs/conf.py` file for more information. - -Another example for page-specific configuration is the ``hide-toc`` field (provided by `Furo `_), which can be used to hide the page-internal table of content. -See `Hiding Contents sidebar `_. - -Add your own configuration --------------------------- - -Custom configuration parameters for your project can be used to extend or override the common configuration, or to define additional configuration that is not covered by the common ``conf.py`` file. - -The following links can help you with additional configuration: - -- `Sphinx configuration `_ -- `Sphinx extensions `_ -- `Furo documentation `_ (Furo is the Sphinx theme we use as our base) - -If you need additional Python packages for any custom processing you do in your documentation, add them to the :file:`docs/requirements.txt` file. - -Disable failure on warning --------------------------- - -The docs build (``make html``) is, by default, set to fail when a warning (``WARNING`` in the build log) is encountered. To disable this setting, remove the ``--failure-on-warning`` option from the command specified in the ``html`` target in the ``Makefile``. diff --git a/docs/how-to/contributing-myst.md b/docs/how-to/contributing-myst.md deleted file mode 100644 index 2efcd9c6..00000000 --- a/docs/how-to/contributing-myst.md +++ /dev/null @@ -1,231 +0,0 @@ ---- -myst: - html_meta: - description: How to contribute code, documentation, and tests to the Starter Pack. -orphan: true ---- - - - - -# How to contribute - -We believe that everyone has something valuable to contribute, whether you're a coder, a writer, or a tester. Here's how and why you can get involved: - -- **Why join us?** Work with like-minded people, develop your skills, connect with diverse professionals, and make a difference. -- **What do you get?** Personal growth, recognition for your contributions, early access to new features, and the joy of seeing your work appreciated. -- **Start early, start easy**: Dive into code contributions, improve documentation, or be among the first testers. Your presence matters, regardless of experience or the size of your contribution. - -The guidelines below will help keep your contributions effective and meaningful. - -## Code of conduct - -When contributing, you must abide by the [Ubuntu Code of Conduct](https://ubuntu.com/community/docs/ethos/code-of-conduct). - -## Licence and copyright - - - -By default, all contributions to ACME are made under the AGPLv3 licence. See the [licence](https://github.com/canonical/ACME/blob/main/COPYING) in the ACME GitHub repository for details. - -All contributors must sign the [Canonical contributor licence agreement](https://canonical.com/legal/contributors), which grants Canonical permission to use the contributions. The author of a change remains the copyright owner of their code (no copyright assignment occurs). - -## Releases and versions - - - -ACME uses [semantic versioning](https://semver.org/); major releases occur once or twice a year. - -The release notes can be found [TODO: here](https://example.com). - -## Environment setup - - - -To work on the project, you need the following prerequisites: - -- [TODO: Prerequisite 1](http://example.com) -- [TODO: Prerequisite 2](http://example.com) - -To install and configure these tools: - -```bash -TODO: prerequisite command 1 -TODO: prerequisite command 2 -``` - -## Submissions - - - -If you want to address an issue or a bug in ACME, notify in advance the people involved to avoid confusion; also, reference the issue or bug number when you submit the changes. - -- Fork [our GitHub repository](https://github.com/canonical/ACME) and add the changes to your fork, properly structuring your commits, providing detailed commit messages, and signing your commits. - -- Make sure the updated project builds and runs without warnings or errors; this includes linting, documentation, code, and tests. - -- Submit the changes as a [pull request (PR)](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork). - -Your changes will be reviewed in due time; if approved, they will eventually be merged. - -### Describing pull requests - - - -To be properly considered, reviewed, and merged, your pull request must provide the following details: - -- **Title**: Summarise the change in a short, descriptive title. -- **Description**: Explain the problem that your pull request solves. Mention any new features, bug fixes, or refactoring. -- **Relevant issues**: Reference any [related issues, pull requests, and repositories](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/autolinked-references-and-urls). -- **Testing**: Explain whether new or updated tests are included. -- **Reversibility**: If you propose decisions that may be costly to reverse, list the reasons and suggest steps to reverse the changes if necessary. - -### Commit structure and messages - - - -Use separate commits for each logical change, and for changes to different components. Prefix your commit messages with the names of components they affect, using the code tree structure. For example, start a commit that updates the ACME service with `ACME/service:`. - -Use [conventional commits](https://www.conventionalcommits.org/) to ensure consistency across the project: - -```none -Ensure correct permissions and ownership for the content mounts - -* Work around an ACME issue regarding empty dirs: https://github.com/canonical/ACME/issues/12345 - -* Ensure the source directory is owned by the user running a container. - -Links: -- ... -- ... -``` - -Such structure makes it easier to review contributions and simplifies porting fixes to other branches. - -### Signing commits - - - -To improve contribution tracking, we use the developer certificate of origin -([DCO 1.1](https://developercertificate.org/) and require signed commits (using -the `-S` or `---gpg-sign` option) for all changes that go into the ACME project. - -```{code-block} none -git commit -S -m "acme/component: updated life cycle diagram" -``` - -Signed commits will have a GPG, SSH, or S/MIME signature that is -cryptographically verifiable, and will be marked with a "Verified" or -"Partially verified" badge in GitHub. This verifies that you made the changes or -have the right to commit it as an open-source contribution. - -To set up locally signed commits and tags, see [GitHub Docs - About commit -signature verification](https://docs.github.com/en/authentication/managing-commit-signature-verification/about-commit-signature-verification). - -````{tip} -You can configure your Git client to sign commits by default for any local -repository by running: - -```{code-block} none -git config --global commit.gpgsign true -``` - -Once you have configured this, you no longer need to add ``-S`` to your -commits explicitly. - -See [GitHub Docs - Signing commits](https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits) for more information. -```` - -If you've made an unsigned commit and encounter the "Commits must have verified -signatures" error when pushing your changes to the remote: - -1. Amend the most recent commit by signing it without changing the commit -message, and push again: - - ```{code-block} none - git commit --amend --no-edit -n -S - git push - ``` - -1. If you still encounter the same error, confirm that your GitHub account has -been set up properly to sign commits as described in the [GitHub Docs - About -commit signature verification](https://docs.github.com/en/authentication/managing-commit-signature-verification/about-commit-signature-verification). - ```{tip} - If you use SSH keys to sign your commits, make sure to add a "Signing Key" - type in your GitHub account. See - [GitHub Docs - Adding a new SSH key to your account](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account) - for more information. - ``` - -## Code - -### Formatting and linting - - - -ACME relies on these formatting and linting tools: - -- [TODO: Tool 1](http://example.com) -- [TODO: Tool 2](http://example.com) - -To configure and run them: - -```bash -TODO: lint command 1 -TODO: lint command 2 -``` - -### Structure - -- **Check linked code elements**: Ensure coupled code elements, files, and directories are adjacent. For instance, store test data close to the corresponding test code. -- **Group variable declaration and initialisation**: Declare and initialise variables together to improve code organisation and readability. -- **Split large expressions**: Break down large expressions into smaller self-explanatory parts. Use multiple variables where appropriate to make the code more understandable and choose names that reflect their purpose. -- **Use blank lines for logical separation**: Insert a blank line between two logically separate sections of code to improve its structure and readability. -- **Avoid nested conditions**: Avoid nesting conditions to improve readability and maintainability. -- **Remove dead code and redundant comments**: Drop unused or obsolete code and comments to promote a cleaner code base and reduce confusion. -- **Normalise symmetries**: Treat identical operations consistently, using a uniform approach to improve consistency and readability. - -### Best practices - - - -## Tests - - - -All code contributions must include tests. - -To run the tests locally before submitting your changes: - -```bash -TODO: test command 1 -TODO: test command 2 -``` - -## Documentation - -ACME's documentation is stored in the `DOCDIR` directory of the repository. It is based on the [Canonical Starter Pack](https://canonical-starter-pack.readthedocs-hosted.com/stable/) and hosted on [Read the Docs](https://about.readthedocs.com/). - -For general guidance, refer to the [Starter Pack guide](https://canonical-starter-pack.readthedocs-hosted.com/stable/). - -For syntax help and guidelines, refer to the syntax guides contained in the [rST](project:#rst-syntax) and [MyST](project:#myst-syntax) syntax guides. - -In structuring, the documentation employs the [Diátaxis](https://diataxis.fr/) approach. - -To run the documentation locally before submitting your changes: - -```bash -make run -``` - -### Automatic checks - -GitHub runs automatic checks on the documentation to verify spelling, validate links, and suggest inclusive language. - -You can (and should) run the same checks locally: - -```bash -make spelling -make linkcheck -make woke -``` diff --git a/docs/how-to/contributing.rst b/docs/how-to/contributing.rst deleted file mode 100644 index 82f97354..00000000 --- a/docs/how-to/contributing.rst +++ /dev/null @@ -1,330 +0,0 @@ -.. meta:: - :description: How to contribute code, documentation, and tests to the Starter Pack. - -:orphan: - -.. TODO: Replace all mentions of ACME with your project name -.. TODO: Update all sections containing TODOs; make sure no TODOs are left - - -How to contribute -================= - -We believe that everyone has something valuable to contribute, -whether you're a coder, a writer or a tester. -Here's how and why you can get involved: - -- **Why join us?** Work with like-minded people, develop your skills, - connect with diverse professionals, and make a difference. - -- **What do you get?** Personal growth, recognition for your contributions, - early access to new features and the joy of seeing your work appreciated. - -- **Start early, start easy**: Dive into code contributions, - improve documentation, or be among the first testers. - Your presence matters, - regardless of experience or the size of your contribution. - - -The guidelines below will help keep your contributions effective and meaningful. - - -Code of conduct ---------------- - -When contributing, you must abide by the -`Ubuntu Code of Conduct `_. - - -Licence and copyright ---------------------- - -.. TODO: Update with your license details or drop if excessive - -By default, all contributions to ACME are made under the AGPLv3 licence. -See the `licence `_ -in the ACME GitHub repository for details. - -All contributors must sign the `Canonical contributor licence agreement -`_, -which grants Canonical permission to use the contributions. -The author of a change remains the copyright owner of their code -(no copyright assignment occurs). - - -Releases and versions ---------------------- - -.. TODO: Add your release and versioning details or drop if excessive - -ACME uses `semantic versioning `_; -major releases occur once or twice a year. - -The release notes can be found `TODO: here `_. - - -Environment setup ------------------ - -.. TODO: Update with your prerequisites or drop if excessive - -To work on the project, you need the following prerequisites: - -- `TODO: Prerequisite 1 `_ -- `TODO: Prerequisite 2 `_ - - -To install and configure these tools: - -.. code-block:: console - - TODO: prerequisite command 1 - TODO: prerequisite command 2 - - -Submissions ------------ - -.. TODO: Suggest your own PR process or drop if excessive - -If you want to address an issue or a bug in ACME, -notify in advance the people involved to avoid confusion; -also, reference the issue or bug number when you submit the changes. - -- `Fork - `_ - our `GitHub repository `_ - and add the changes to your fork, - properly structuring your commits, - providing detailed commit messages - and signing your commits. - -- Make sure the updated project builds and runs without warnings or errors; - this includes linting, documentation, code and tests. - -- Submit the changes as a `pull request (PR) - `_. - - -Your changes will be reviewed in due time; -if approved, they will be eventually merged. - - -Describing pull requests -~~~~~~~~~~~~~~~~~~~~~~~~ - -.. TODO: Update with your own checklist or drop if excessive - -To be properly considered, reviewed and merged, -your pull request must provide the following details: - -- **Title**: Summarise the change in a short, descriptive title. - -- **Description**: Explain the problem that your pull request solves. - Mention any new features, bug fixes or refactoring. - -- **Relevant issues**: Reference any - `related issues, pull requests and repositories `_. - -- **Testing**: Explain whether new or updated tests are included. - -- **Reversibility**: If you propose decisions that may be costly to reverse, - list the reasons and suggest steps to reverse the changes if necessary. - - -Commit structure and messages -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -.. TODO: Update with your own guidelines or drop if excessive - -Use separate commits for each logical change, -and for changes to different components. -Prefix your commit messages with names of components they affect, -using the code tree structure, -e.g. start a commit that updates the ACME service with ``ACME/service:``. - -Use `conventional commits `_ -to ensure consistency across the project: - -.. code-block:: none - - Ensure correct permissions and ownership for the content mounts - - * Work around an ACME issue regarding empty dirs: - https://github.com/canonical/ACME/issues/12345 - - * Ensure the source directory is owned by the user running a container. - - Links: - - ... - - ... - - -Such structure makes it easier to review contributions -and simplifies porting fixes to other branches. - - -Signing commits -~~~~~~~~~~~~~~~ - -.. TODO: Update with your suggestions or drop if excessive - -To improve contribution tracking, we use the developer certificate of origin -(`DCO 1.1 `_) and require signed commits -(using the ``-S`` or ``--gpg-sign`` option) for all changes that go into the -ACME project. - -.. code-block:: none - - git commit -S -m "acme/component: updated life cycle diagram" - -Signed commits will have a GPG, SSH, or S/MIME signature that is -cryptographically verifiable, and will be marked with a "Verified" or -"Partially verified" badge in GitHub. This verifies that you made the changes or -have the right to commit it as an open-source contribution. - -To set up locally signed commits and tags, see `GitHub Docs - About commit -signature verification `_. - -.. tip:: - - You can configure your Git client to sign commits by default for any local - repository by running ``git config --global commit.gpgsign true``. - Once you have configured this, you no longer need to add ``-S`` to your - commits explicitly. - - See `GitHub Docs - Signing commits `_ for more information. - -If you've made an unsigned commit and encounter the "Commits must have verified -signatures" error when pushing your changes to the remote: - -1. Amend the most recent commit by signing it without changing the commit - message, and push again: - - .. code-block:: none - - git commit --amend --no-edit -n -S - git push -#. If you still encounter the same error, confirm that your GitHub account has - been set up properly to sign commits as described in the `GitHub Docs - About - commit signature verification `_. - - .. tip:: - - If you use SSH keys to sign your commits, make sure to add a "Signing Key" - type in your GitHub account. See - [GitHub Docs - Adding a new SSH key to your account](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account) - for more information. - -Code ----- - -Formatting and linting -~~~~~~~~~~~~~~~~~~~~~~ - -.. TODO: Update with your linting configuration setup or drop if excessive - -ACME relies on these formatting and linting tools: - -- `TODO: Tool 1 `_ -- `TODO: Tool 2 `_ - - -To configure and run them: - -.. code-block:: console - - TODO: lint command 1 - TODO: lint command 2 - - -Structure -~~~~~~~~~ - -- **Check linked code elements**: - Check that coupled code elements, files and directories are adjacent. - For instance, store test data close to the corresponding test code. - -- **Group variable declaration and initialisation**: - Declare and initialise variables together - to improve code organisation and readability. - -- **Split large expressions**: - Break down large expressions - into smaller self-explanatory parts. - Use multiple variables where appropriate - to make the code more understandable - and choose names that reflect their purpose. - -- **Use blank lines for logical separation**: - Insert a blank line between two logically separate sections of code. - This improves its structure and makes it easier to understand. - -- **Avoid nested conditions**: - Avoid nesting conditions to improve readability and maintainability. - -- **Remove dead code and redundant comments**: - Drop unused or obsolete code and comments. - This promotes a cleaner code base and reduces confusion. - -- **Normalise symmetries**: - Treat identical operations consistently, using a uniform approach. - This also improves consistency and readability. - - -Best practices -~~~~~~~~~~~~~~ - -.. TODO: Update with your best practices or drop if excessive - - -Tests ------ - -.. TODO: Update with your testing framework details or drop if excessive - -All code contributions must include tests. - -To run the tests locally before submitting your changes: - -.. code-block:: console - - TODO: test command 1 - TODO: test command 2 - - -Documentation -------------- - -ACME's documentation is stored in the ``DOCDIR`` directory of the repository. -It is based on the `Canonical Starter Pack -`_ -and hosted on `Read the Docs `_. - -For syntax help and guidelines, -refer to the Canonical syntax guides -(:ref:`reStructuredText ` and :ref:`MyST `). - -In structuring, -the documentation employs the `Diátaxis `_ approach. - -To run the documentation locally before submitting your changes: - -.. code-block:: console - - make run - - -Automatic checks -~~~~~~~~~~~~~~~~ - -GitHub runs automatic checks on the documentation -to verify spelling, validate links and suggest inclusive language. - -You can (and should) run the same checks locally: - -.. code-block:: console - - make spelling - make linkcheck - make woke diff --git a/docs/how-to/index.rst b/docs/how-to/index.rst index 7050375e..d7a5b154 100644 --- a/docs/how-to/index.rst +++ b/docs/how-to/index.rst @@ -1,44 +1,4 @@ -.. meta:: - :description: Explore the essential guides and procedures in Canonical's Starter Pack. - - .. _how-to-guides: How-to guides ============= - -These guides will walk you through the processes involving setting up, -maintaining, and contributing to the Starter Pack. - -Basic setup and maintenance ---------------------------- - -Set up, configure, update, and customize your project to keep it organized and aligned with -your documentation needs. - -.. toctree:: - :maxdepth: 1 - - configure-your-project - build-and-preview - run-documentation-checks - publish-on-rtd - update-starter-packs/index.rst - troubleshooting - -Optional features and customisation ------------------------------------ - -As your documentation grows, you may need more advanced features to support richer content. This -can include customising the build system, adding diagrams as code, rendering API references, interactive -tables, and custom HTML. - -While some of these features are available by default in the Starter Pack, others may require additional -extensions. - -The following guides will help you get started: - -.. toctree:: - :maxdepth: 2 - - optional-customisation/index.rst diff --git a/docs/how-to/optional-customisation/add-documentation-testing.rst b/docs/how-to/optional-customisation/add-documentation-testing.rst deleted file mode 100644 index d89b6511..00000000 --- a/docs/how-to/optional-customisation/add-documentation-testing.rst +++ /dev/null @@ -1,330 +0,0 @@ -.. meta:: - :description: How to use Spread to automatically test commands in documentation and keep them in sync with your product. - -.. _how-to-add-documentation-testing: - -Use Spread to test commands in documentation -============================================ - -It's challenging to keep documentation in sync with products as they evolve. This -process is aided by *Spread*, a test distributor that can work through your -documentation and report failures in GitHub workflows. - -By using Spread tests, you can rely on the tests as the source of truth for commands -in your documentation, enabling fully tested documentation at build time. - -What you'll need ----------------- - -* `Multipass `_ installed on your machine -* `Spread `_ installed on your machine - -.. warning:: - - Spread requires elevated permissions to run as root. Use the - `Go install method `_ - recommended in the Spread README to install Spread. - -Create a test suite -------------------- - -From the root of your project, create the file ``spread.yaml`` and insert the -following contents: - -.. code-block:: yaml - :caption: project_name/spread.yaml - - project: project_name - - path: /project_name - -Match the ``project`` name to your main directory's name. -The ``path`` designates the directory where the Spread -materials exist. - -So that Spread knows about your tests, add the -following section to the end of ``spread.yaml``: - -.. code-block:: yaml - :caption: project_name/spread.yaml - :emphasize-lines: 5-9 - - project: project_name - - path: /project_name - - suites: - tests/spread/: - summary: example test - systems: - - ubuntu-24.04-64 - -The ``suites`` section is how you tell Spread about the various Spread tests in -your project along with the systems you want Spread to use. -In this example, Spread looks for tests in the ``project_name/tests/spread`` directory and -runs them on Ubuntu 24.04. -If you create a new ``task.yaml`` file in a different directory, -remember to add a corresponding suite for it in ``spread.yaml``. - -Set up the Multipass backend ----------------------------- - -Each job in Spread has a backend, or a way to obtain a machine for running your Spread -tests. Spread can run on various backends, like -`Google `__, -`QEMU `__, or, as this -guide sets up, Multipass. - -Copy the following ``backends`` section of ``spread.yaml`` between the ``path`` and -``suites`` sections: - -.. code-block:: yaml - :caption: project_name/spread.yaml - :emphasize-lines: 5-40 - - project: project_name - - path: /project_name - - backends: - multipass: - type: adhoc - allocate: | - multipass_image=24.04 - instance_name="example-multipass-vm" - - # Launch Multipass VM - multipass launch --cpus 2 --disk 10G --memory 2G --name "${instance_name}" "${multipass_image}" - - # Enable PasswordAuthentication for root over SSH. - multipass exec "$instance_name" -- \ - sudo sh -c "echo root:${SPREAD_PASSWORD} | sudo chpasswd" - multipass exec "$instance_name" -- \ - sudo sh -c \ - "if [ -d /etc/ssh/sshd_config.d/ ] - then - echo 'PasswordAuthentication yes' > /etc/ssh/sshd_config.d/10-spread.conf - echo 'PermitRootLogin yes' >> /etc/ssh/sshd_config.d/10-spread.conf - else - sed -i /etc/ssh/sshd_config -E -e 's/^#?PasswordAuthentication.*/PasswordAuthentication yes/' -e 's/^#?PermitRootLogin.*/PermitRootLogin yes/' - fi" - multipass exec "$instance_name" -- \ - sudo systemctl restart ssh - - # Get the IP from the instance - ip=$(multipass info --format csv "$instance_name" | tail -1 | cut -d\, -f3) - ADDRESS "$ip" - - discard: | - instance_name="example-multipass-vm" - multipass delete --purge "${instance_name}" - - systems: - - ubuntu-24.04-64: - workers: 1 - - suites: - tests/spread/: - summary: example test - systems: - - ubuntu-24.04-64 - -The ``backends`` section contains the following pieces: - -* The backend is designated as ``type: adhoc`` as you must explicitly - script the procedure to allocate and discard the Multipass VM. -* The ``allocate`` section defines the image and name of the VM, launches the - VM, and sets up the proper SSH permissions Spread then logs in to the VM with - root permissions and inserts the Spread test. The last two lines tell Spread the - IP address of the Multipass VM and set the environment variable ``ADDRESS``. -* The ``discard`` section deletes the Multipass VM once the Spread test - has finished running. -* The ``systems`` key notes which systems the backend uses. Note that this key - must match the ``systems`` used by at least one test under ``suites``. - -Create a Spread task --------------------- - -Put your Spread files alongside your project's existing tests. -The rest of this guide assumes they're in a top-level -``tests/spread`` directory. - -Each Spread test requires a dedicated ``task.yaml`` file that contains -all the commands you want to test. A single ``task.yaml`` can help you -validate an entire assumed workflow, for instance, -an end-to-end tutorial. - -An example ``task.yaml`` file is shown below: - -.. code-block:: yaml - :caption: task.yaml - - summary: Example Spread test - - kill-timeout: 5m - - prepare: | - echo "Use this section to install any prerequisites" - - execute: | - echo "This is the first command that Spread will run" - - echo "This is the second command that Spread will run" - -The ``summary`` section contains a brief description of the documentation you're testing, -the ``prepare`` section contains any initial setup your test needs, -and the ``execute`` section contains your documentation's commands. -The ``kill-timeout`` option has a default of 10 minutes and doesn't need to be -included if you expect your test to complete in that time frame. - -.. note:: - - For a real-world example, see ``task.yaml`` for - `the Rockcraft Go tutorial. `_ - -Include the tested commands in documentation --------------------------------------------- - -By using the ``literalinclude`` directive in Sphinx, you can insert the -exact commands from ``task.yaml`` in your documentation file. - -For example, consider the following ``task.yaml`` file: - -.. code-block:: yaml - :caption: task.yaml - - summary: Clone and build the Starter Pack - - kill-timeout: 5m - - execute: | - # [docs:clone-starter-pack] - git clone https://github.com/canonical/sphinx-docs-starter-pack.git - # [docs:clone-starter-pack-end] - - # [docs:build-documentation] - cd sphinx-docs-starter-pack/docs - make run - # [docs:build-documentation-end] - -Include the commands from ``task.yaml`` in your documentation with: - -.. tab-set:: - - .. tab-item:: reStructuredText - :sync: rest-commands - - .. code-block:: rst - :caption: Example ``literalinclude`` blocks - - Clone the Starter Pack: - - .. literalinclude:: relative-path-to/task.yaml - :language: bash - :start-after: [docs:clone-starter-pack] - :end-before: [docs:clone-starter-pack-end] - :dedent: 2 - - Enter the ``docs`` folder and build the project: - - .. literalinclude:: relative-path-to/task.yaml - :language: bash - :start-after: [docs:build-documentation] - :end-before: [docs:build-documentation-end] - :dedent: 2 - - .. tab-item:: MyST - :sync: myst-commands - - .. code-block:: md - :caption: Example ``literalinclude`` blocks - - Clone the Starter Pack: - - ```{literalinclude} relative-path-to/task.yaml - :language: bash - :start-after: [docs:clone-starter-pack] - :end-before: [docs:clone-starter-pack-end] - :dedent: 2 - ``` - - Enter the `docs` folder and build the project: - - ```{literalinclude} relative-path-to/task.yaml - :language: bash - :start-after: [docs:build-documentation] - :end-before: [docs:build-documentation-end] - :dedent: 2 - ``` - -By using the options ``:start-after:`` and ``:end-before:``, the documentation file -sources and includes all commands appearing in ``task.yaml`` between the -specified lines. - -Run tests locally ------------------ - -List all available Spread tests in the code repository: - -.. code-block:: bash - - spread --list - -The terminal should respond with all the tests defined in ``spread.yaml``. -For example: - -.. terminal:: - :dir: project_name - - spread --list - - multipass:ubuntu-24.04-64:tests/spread/example_documentation_test - -Run all Spread tests locally with ``spread``. You can also run a single -Spread test by specifying: - -.. code-block:: bash - - spread -vv -debug multipass:ubuntu-24.04-64:tests/spread/example_documentation_test - -Depending on the complexity of your test, Spread can take several minutes to complete. -The ``-vv -debug`` flags provide useful debugging information as the test runs. - -Check the results ------------------ - -During runtime, the terminal outputs various messages about allocating the Multipass VM, -connecting to the VM, sending the Spread test to the VM and executing the test. -If the test is successful, the terminal will output something similar to the following: - -.. terminal:: - :output-only: - - 2025-02-04 16:17:10 Successful tasks: 1 - 2025-02-04 16:17:10 Aborted tasks: 0 - -Another sign of a successful test is whether the Multipass VM was deleted as expected. -Check by running :code:`multipass list`, and if the Spread test was successful -(and you have no other Multipass VMs created at the time), the terminal should -respond with: - -.. terminal:: - :dir: project_name - - multipass list - - No instances found. - -If the Spread test failed, then the ``-debug`` flag will open a shell into the -Multipass VM so that additional debugging can happen. In that case, the terminal -will output something similar to the following: - -.. terminal:: - :output-only: - - 2025-02-04 16:17:10 Starting shell to debug... - 2025-02-04 16:17:10 Sending script for multipass:ubuntu-24.04-64 (multipass:ubuntu-24.04-64:tests/spread/example_documentation_test): - - -.. _ReStructuredText (.rst): https://www.sphinx-doc.org/en/master/usage/restructuredtext -.. _MyST-Markdown: https://myst-parser.readthedocs.io/en/latest diff --git a/docs/how-to/optional-customisation/bridge-project-and-docs-builds.rst b/docs/how-to/optional-customisation/bridge-project-and-docs-builds.rst deleted file mode 100644 index 469c3ea3..00000000 --- a/docs/how-to/optional-customisation/bridge-project-and-docs-builds.rst +++ /dev/null @@ -1,355 +0,0 @@ -.. meta:: - :description: How to bridge the build of Canonical's Starter Pack and a parent project's build. - -:relatedlinks: [pip and dependency groups](https://pip.pypa.io/en/stable/user_guide/#dependency-groups), [uv and dependency groups](https://docs.astral.sh/uv/concepts/projects/dependencies/#dependency-groups), [Poetry and dependency groups](https://python-poetry.org/docs/managing-dependencies#dependency-groups) - - -.. _bridge-project-and-docs-builds: - -Bridge project and documentation builds -======================================= - -.. If more parent projects and build systems are tested, make the introduction general - and add tabs to each of the steps - -The Starter Pack can be used as a standalone docs repository, or embedded inside a -parent project. This guide demonstrates how to bridge the docs build with a Python -project's main build. Once bridged, project contributors can install, build, and check -the docs from the root of the project with the main build system. - -:ref:`explanation-parent-project-build` describes the full benefits of bridging the -build in a larger project. - - -.. _how-to-bridge-project-builds-project-requirements-layout: - -Plan and requirements ---------------------- - -The bridge is built by making up to three changes to the build. - -The bridge **shims the docs build targets in the main build**. Any build system is -capable of adding targets that call other systems. When shimmed, the docs targets like -``html`` and ``clean`` pass through to ``docs/Makefile``, with arguments. - -The bridge also **merges the virtual environments**, removing the need for a separate -docs environment. This change is optional but recommended. To combine environments, your -project must provide **Python 3.11** or higher to the Starter Pack. Any Python -dependency manager will do, and this guide illustrates with three: - -- pip 25.1 and higher -- uv 0.4.27 and higher -- Poetry 1.2.0a2 and higher - -After adding the bridge, it's also possible to **adjust the documentation workflows** to -use your project's main build. The workflows were designed with Make, so they only work -if you use it for your build system. - - -Example project layout ----------------------- - -This guide illustrates the bridge through an example project. In the example project, -the file tree contains: - -.. code-block:: - - Project - │ - ├── ... - ├── docs - │ └── Makefile - ├── .venv - ├── Makefile - └── pyproject.toml - -The example project's root ``Makefile`` has two conventional targets that need -adjustment: - -- ``setup`` for building the virtual environment and syncing dependencies -- ``clean`` for cleaning up the virtual environment and temporary files - - -.. _how-to-bridge-project-builds-set-docs-env-vars: - -Set the build paths -------------------- - -Where your main build sets environment variables, redeclare the docs environment -variables that specify the build paths: - -- ``DOCS_BUILDDIR`` is the destination for the docs. If you have special distribution - needs you can override this, but for most builds this can be left as-is. -- ``DOCS_VENVDIR`` is the virtual environment of the docs. If you're merging the virtual - environments, set this as a relative path from the docs directory to your project's - virtual environment. -- ``VALE_DIR`` is the path to the Vale binary. The full path depends on the - location of your virtual environment, so it's best to copy this as-is. - -In the example project, this looks like: - -.. code-block:: make - :caption: Makefile - - # Env vars for the docs build - export DOCS_BUILDDIR ?= _build - export DOCS_VENVDIR ?= ../.venv - export VALE_DIR ?= $(DOCS_VENVDIR)/lib/python*/site-packages/vale - - -.. _how-to-bridge-project-builds-integrate-docs-setup: - -Integrate the docs setup ------------------------- - -The next step is to incorporate the docs installation target, and optionally the -dependencies, into the main build. - - -Separate virtual environments -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -If you don't plan to merge the virtual environments, override the installation target by -calling all three doc installation targets in a row. - -In the example project, this is written as: - -.. code-block:: make - :caption: Makefile - - # Override the - .PHONY: docs-install - docs-install: - $(MAKE) -C docs install --no-print-directory - $(MAKE) -C docs vale-install --no-print-directory - $(MAKE) -C docs pymarkdownlnt-install --no-print-directory - - -Merged virtual environments -^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -To merge virtual environments, the ``setup`` target must handle both development and -docs packages, and enumerate all docs packages in ``pyproject.toml``. Your project will -also need dependency groups to organize the packages. The result will be one virtual -environment fed by three dependency groups in ``pyproject.toml``: - -- ``dev`` for development builds -- ``docs`` for extra docs packages that your project needs -- ``docs-starter-pack`` for the core docs packages set by the Starter Pack - -First, add the dependency groups. The docs group should depend on the Starter Pack -group: - -.. code-block:: toml - :caption: pyproject.toml - - [dependency-groups] - dev = [ - # Packages for main development and testing - ] - docs = [ - # Packages for extra docs features - {include-group = "docs-starter-pack"}, - ] - docs-starter-pack = [ - # Core docs packages - ] - -If your ``pyproject.toml`` file didn't already have a ``dev`` dependency group, review the -packages listed in the ``dependencies`` key, then move any non-runtime dependencies to -the ``dev`` dependency group. - -If your project needs extra docs features, like the Mermaid or LaTeX Sphinx extensions, -add their packages to the ``docs`` group. - -Copy the contents of ``docs/requirements.txt`` into the ``docs-starter-pack`` group. - -In the main build, override the docs installation target to install the ``docs`` -dependency group, then make the project's ``setup`` target depend on the docs target. In -the example project, it's written like this: - -.. tabs:: - - .. tab:: pip - - .. code-block:: make - :caption: Makefile - :emphasize-lines: 2-3, 7-12 - - .PHONY: setup - setup: docs-install - pip install --group dev - - # ... - - # Override for `install` target in docs project - .PHONY: docs-install - docs-install: - pip install --group docs - $(MAKE) -C docs vale-install --no-print-directory - $(MAKE) -C docs pymarkdownlnt-install --no-print-directory - - .. tab:: uv - - .. code-block:: make - :caption: Makefile - :emphasize-lines: 2-3, 7-12 - - .PHONY: setup - setup: docs-install - uv sync --group dev - - # ... - - # Override for `install` target in docs project - .PHONY: docs-install - docs-install: - uv sync --no-dev --group docs - $(MAKE) -C docs vale-install --no-print-directory - $(MAKE) -C docs pymarkdownlnt-install --no-print-directory - - .. tab:: Poetry - - .. code-block:: make - :caption: Makefile - :emphasize-lines: 2-3, 7-12 - - .PHONY: setup - setup: docs-install - poetry install --only dev - - # ... - - # Override for `install` target in docs project - .PHONY: docs-install - docs-install: - poetry install --only docs - $(MAKE) -C docs vale-install --no-print-directory - $(MAKE) -C docs pymarkdownlnt-install --no-print-directory - -If your docs aren't written in Markdown, remove the command that runs the -``pymarkdownlnt-install`` target. - - -.. _how-to-bridge-project-builds-shim-remaining-targets: - -Shim the remaining targets --------------------------- - -The docs build has many targets, but only a handful of them overlap or collide with most -project builds, so we only need to override two more. The rest can pass straight through -to the docs build. - -In the example project, the main build calls the targets like this: - -.. code-block:: make - :caption: Makefile - - # Override for `clean` target in docs project. We don't want to touch `.venv`, - # so we pass a temp dir instead. - .PHONY: docs-clean - docs-clean: - DOCS_VENVDIR=$(mktemp) $(MAKE) -C docs clean --no-print-directory - - # Override for `help` target - .PHONY: docs-help - docs-help: - @echo "Commands in the documentation subproject:" - $(MAKE) -C docs help --no-print-directory - @echo "Run these commands with 'make docs-' in the project root." - - # Shim for the rest of the targets in docs Makefile - .PHONY: docs-% - docs-%: docs-install - $(MAKE) -C docs $(@:docs-%=%) --no-print-directory - -.. admonition:: Variables and Makefiles - - When calling another Makefile with ``$(MAKE) -C``, also known as a sub-Make call, - variables with default values in the child Makefile won't be overridden. To override - them, you must set them explicitly with `export` or as as command-line arguments. - - For example, within the main build, if you need to customize - ``SPHINX_AUTOBUILD_OPTS``, pass it to the docs build like this: - - .. code-block:: make - :caption: Makefile - - $(MAKE) -C docs run SPHINX_AUTOBUILD_OPTS="$(SPHINX_AUTOBUILD_OPTS)" - -.. _how-to-bridge-project-builds-adjust-rtd-build: - -Adjust the Read the Docs build ------------------------------- - -With the Makefile in a different location than usual, and its being a separate process, -it's simplest to override the Read the Docs build in ``.readthedocs.yaml`` to call the -same build targets that developers use locally. - -If you use an uncommon system, you might need to install it during the workflow's -``create_environment`` job. - -If you merged the virtual environments, make sure to set ``DOCS_VENVDIR=${READTHEDOCS_VIRTUALENV_PATH}`` in all commands. - -Here's what it looks like in the example project: - -.. code-block:: yaml - :caption: .readthedocs.yaml - :emphasize-lines: 8-14 - - build: - os: ubuntu-24.04 - tools: - python: "3.12" - jobs: - post_checkout: - - git fetch --tags --unshallow # Also fetch tags - create_environment: - - python3 -m venv "${READTHEDOCS_VIRTUALENV_PATH}" - install: - - make docs-install DOCS_VENVDIR="${READTHEDOCS_VIRTUALENV_PATH}" - build: - html: - - make docs DOCS_VENVDIR="${READTHEDOCS_VIRTUALENV_PATH}" DOCS_BUILDDIR="$READTHEDOCS_OUTPUT/html/" - - -.. _how-to-bridge-project-builds-adjust-doc-workflows: - -Adjust the doc workflows ------------------------- - -If your project uses the Starter Pack's docs workflows *and* Make, adjust the workflows -to use the bridged targets. - -For the main checks, override the target names and paths through the `workflow inputs -`_: - -.. code-block:: yaml - :caption: .github/workflows/automatic-doc-checks.yml - :emphasize-lines: 5, 7-11 - - jobs: - documentation-checks: - uses: canonical/documentation-workflows/.github/workflows/documentation-checks.yaml@main - with: - working-directory: "." - fetch-depth: 0 - install-target: docs-install - spelling-target: docs-spelling - woke-target: docs-woke - linkcheck-target: docs-linkcheck - pa11y-target: docs-pa11y - -If your docs are written in Markdown, override the path and command inputs in the -Markdown linter workflow: - -.. code-block:: yaml - :caption: .github/workflows/markdown-style-checks.yml - :emphasize-lines: 2-6 - - - name: Create venv - working-directory: "." - run: make docs-install - - name: Lint markdown - working-directory: "." - run: make docs-lint-md diff --git a/docs/how-to/optional-customisation/custom-html-templates.md b/docs/how-to/optional-customisation/custom-html-templates.md deleted file mode 100644 index ec7c8198..00000000 --- a/docs/how-to/optional-customisation/custom-html-templates.md +++ /dev/null @@ -1,156 +0,0 @@ ---- -myst: - html_meta: - description: How to extend or override default HTML templates to customize documentation structure and layout. ---- - -(custom-html-templates)= - -# Use custom HTML templates - -If the default template in the Starter Pack doesn't fully meet your needs -- whether you want a unique layout, a custom header or footer, or a specialized sidebar for certain pages -- you can create and use a custom template for your project. - -This guide shows you how to extend or override the default templates in the Starter Pack to tailor the look and structure of your documentation. - -```{note} -Base template customizations can be made to your documentation. -However, they are not officially supported by the team maintaining the Starter Pack. -Use them at your own discretion. -``` - -## Setup - -First, create the {file}`docs/_templates` directory; all your custom templates will need to be stored in this folder. - -Then uncomment this line in {file}`docs/conf.py` so your project will use local templates (where available): - -```{code-block} py -:caption: conf\.py - -templates_path = ["_templates"] -``` - -In most cases, you will need to copy the default templates from the [canonical-sphinx theme] as a starting point and edit as needed. - - -```{seealso} -Sphinx uses the Jinja templating engine for its HTML templates; see the [Jinja template syntax reference] for more details. -``` - -## Use custom template for all pages - -Sphinx looks for a template called {file}`page.html` as the entry point and main page template for documentation pages. -To customize your project's look and structure, check this file and determine which parts -- such as the header, footer, or sidebars -- need to be edited or overridden. - -Here are some examples. - -### Remove on-page TOC - -To remove the on-page TOC in the right sidebar, make a copy of [page.html] in the {file}`docs/_templates` folder, and remove the applicable lines. -This will apply to all pages. - -```{code-block} html -:caption: page.html -:emphasize-lines: 3-14 -:class: no-copybutton - -{% block right_sidebar %} -
- {% if not furo_hide_toc_orig %} -
- - {{ _("Contents") }} - -
-
-
- {{ toc }} -
-
- {% endif %} - {% if meta and ((meta.discourse and discourse_prefix) or meta.relatedlinks) %} -