Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Codeowners for this repository.
# Guidance and syntax is covered in
# https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners
#
#
# Important: The last match takes precedence.

# Development reviewers
Expand Down
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
- [ ] Have you updated `CHANGELOG.md` with relevant non-documentation file changes?
- [ ] Have you updated the documentation for this change?

-----
______________________________________________________________________
24 changes: 24 additions & 0 deletions .github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: PreCommit

on:
pull_request:
push:
branches: [main]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
PreCommit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/setup-python@v6
with:
python-version: 3.x
- uses: pre-commit/action@v3.0.1
- uses: pre-commit-ci/lite-action@v1.1.0
if: always()
with:
msg: "pre-commit: apply automatic fixes"
34 changes: 34 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Recommended workflow:
# - `git add --verbose --patch` to stage changes
# - `git commit` to commit them
# - rinse and repeat, if pre-commit wants / applied changes
#
# To limit impact to just the `docs` subfolder, uncomment the below
# files: ^docs/

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-added-large-files

- repo: https://github.com/executablebooks/mdformat
rev: 0.7.22
hooks:
- id: mdformat
Copy link
Copy Markdown
Collaborator

@medubelko medubelko Sep 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll toss my two cents here, minding the TA and contributor experience. I'm hoping the questions I raise here are helpful to those voices. Maybe others can speak to context behind this work that I'm missing. Please let me know if so. :)

I think we ought to be very deliberate with the purpose and impact of pre-commit in our pack. Have we considered the separation between make lint and pre-commit? Both add friction to the authoring workflow through different strategies. What does it mean if a linter is in one but not the other?

mdformat, like prettier, is highly opinionated. TAs are also opinionated, and it takes us time to come to an agreement on things. For example, I have a principled stance for why hyphens are better list markers than asterisks, but to force all authors to change course on that overnight will take many by surprise, and become an immediate pain point. make lint, by contrast, doesn't get in the way of my work until the CI stage. By introducing pre-commit, we'll be directly insinuating another set of checks, this time forceful ones, into our contributors' daily workflows.

Regardless of what these hooks do, I think we're going to encounter challenges with visibility. Pre-commit has what I consider a major flaw: it doesn't actually communicate well that my commit -- my main unit of work -- has failed. It dumps many lines to the console, potentially a lot of lines if its checks find many problems, then exits. It's then not always clear what I should do next. Do I commit again, in the case of autoformatters (which I have to know ahead of time are in my repo)? Do I go and manually fix the files, hoping that I didn't miss anything? To me this feels like a regression from the concerted effort we put into switching to Vale as a writing aide, where we made its focus be on warning the author, giving them a chance to make a decision, not block them for trivial things. Maybe we could call git status after it runs? But that feels like a band-aid.

As a last but minor point, for repos where the docs are nested in a product, it won't always be obvious how to combine pre-commit configs. We'll need to provide guidance for that.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll toss my two cents here

Thanks for the feedback! I'll try and cluster it, and my answers, in distinct themes, as maybe I should not have mixed things up as much:

mdformat

mdformat, like prettier, is highly opinionated. TAs are also opinionated, and it takes us time to come to an agreement on things.

But whether pre-commit is in use or not, shouldn't affect this?

For example, I have a principled stance for why hyphens are better list markers than asterisks, but to force all authors to change course on that overnight will take many by surprise

The advantage of this is that it can be transparent to them, and if there's agreement on the direction, is there value in not doing it "overnight"?

mdformat is just something that worked for me, so I brought it here under that umbrella. Maybe I should've just brought the whitespace bits to start with ;)

pre-commit

Have we considered the separation between make lint and pre-commit? Both add friction to the authoring workflow through different strategies. What does it mean if a linter is in one but not the other?

As much as possible, I think we should move towards pre-commit. It's a standard approach, less brittle than the Makefile we have. That said, the line may need to be drawn between what can be done on source and on the generated HTML.

make lint, by contrast, doesn't get in the way of my work until the CI stage.

I personally consider that a bug, rather than feature :). You still get the choice, though - you don't have to pre-commit install locally, and leave CI to do its thing.

More, make lint doesn't actually apply the auto fixes (whether local or at CI time), which e.g. might mean I get to come back to failed CI just to clear some whitespace issues…

By introducing pre-commit, we'll be directly insinuating another set of checks, this time forceful ones, into our contributors' daily workflows.

For me it's just one less thing to think about. The tooling takes care of formatting for me.

Regardless of what these hooks do, I think we're going to encounter challenges with visibility. Pre-commit has what I consider a major flaw: it doesn't actually communicate well that my commit -- my main unit of work -- has failed. It dumps many lines to the console, potentially a lot of lines if its checks find many problems, then exits.

Does make lint do better? Maybe I don't get what you mean, but I would rather not commit things that need to be fixed.

It's then not always clear what I should do next. Do I commit again, in the case of autoformatters (which I have to know ahead of time are in my repo)? Do I go and manually fix the files, hoping that I didn't miss anything?

No, it actually applies all the fixes it can - you just need to review and commit them.

As a last but minor point, for repos where the docs are nested in a product, it won't always be obvious how to combine pre-commit configs. We'll need to provide guidance for that.

If a project already has pre-commit, they'll know what to do. If they don't, that's another win in my book - introducing them to it.

vale

To me this feels like a regression from the concerted effort we put into switching to Vale as a writing aide

I don't have the context here, but I also think we should separate tools like vale and just trivial formatting things.

we made its focus be on warning the author, giving them a chance to make a decision, not block them for trivial things.

If it only runs in CI, I won't see the warning anyway, unless it's blocking? And if it is blocking, then how is using pre-commit different?

additional_dependencies:
- mdformat-black
- mdformat-beautysh
- mdformat-gfm
- mdformat-myst
- setuptools # Necessary until beautysh fix their stuff, see: https://github.com/hukkin/mdformat/issues/442

- repo: https://github.com/jackdewinter/pymarkdown
rev: v0.9.32
hooks:
- id: pymarkdown
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it work fine with mdformat? not sure myself

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They don't seem to clash, and mdformat seems more opinionated (that's what all the changes here are), but as we see below, it also is not without fault.

I will use whatever you all think is right, just want to spread the use of pre-commit :)

args:
- --config=docs/.sphinx/.pymarkdown.json
- fix
109 changes: 55 additions & 54 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,72 +2,73 @@

## Upcoming

* Changes metrics script to a less brittle Python script
- Changes metrics script to a less brittle Python script
- Adds pre-commit configuration for automatic fixes and checks

### Added

* `docs/.sphinx/metrics/build_metrics.py` [#373](https://github.com/canonical/sphinx-docs-starter-pack/pull/373)
- `docs/.sphinx/metrics/build_metrics.py` [#373](https://github.com/canonical/sphinx-docs-starter-pack/pull/373)
- `.pre-commit-config.py`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yaml?


## Changed

* `docs/Makefile` [#373](https://github.com/canonical/sphinx-docs-starter-pack/pull/373)
* `docs/conf.py` [#429](https://github.com/canonical/sphinx-docs-starter-pack/pull/429)
* `docs/.sphinx/update_sp.py` [#425](https://github.com/canonical/sphinx-docs-starter-pack/pull/425)
* `.github/workflows/check-removed-urls.yml` [#437](https://github.com/canonical/sphinx-docs-starter-pack/pull/437)
- `docs/Makefile` [#373](https://github.com/canonical/sphinx-docs-starter-pack/pull/373)
- `docs/conf.py` [#429](https://github.com/canonical/sphinx-docs-starter-pack/pull/429)
- `docs/.sphinx/update_sp.py` [#425](https://github.com/canonical/sphinx-docs-starter-pack/pull/425)
- `.github/workflows/check-removed-urls.yml` [#437](https://github.com/canonical/sphinx-docs-starter-pack/pull/437)

### Removed

* `docs/.sphinx/metrics/build_metrics.py` [#373](https://github.com/canonical/sphinx-docs-starter-pack/pull/373)
- `docs/.sphinx/metrics/build_metrics.py` [#373](https://github.com/canonical/sphinx-docs-starter-pack/pull/373)

## 1.2.0

* Replaces spelling check with Vale.
* Fixes the Markdown linting GitHub action and adds a `make lint-md` check.
* Fixes the download branch name in the update script.
* Adds a check for removed URLs.
- Replaces spelling check with Vale.
- Fixes the Markdown linting GitHub action and adds a `make lint-md` check.
- Fixes the download branch name in the update script.
- Adds a check for removed URLs.

### Added

* `docs/.sphinx/.pymarkdown.json` [#379](https://github.com/canonical/sphinx-docs-starter-pack/pull/379)
* `.github/workflows/check-removed-urls.yml` [#410](https://github.com/canonical/sphinx-docs-starter-pack/pull/410)
- `docs/.sphinx/.pymarkdown.json` [#379](https://github.com/canonical/sphinx-docs-starter-pack/pull/379)
- `.github/workflows/check-removed-urls.yml` [#410](https://github.com/canonical/sphinx-docs-starter-pack/pull/410)

### Changed

* `docs/.sphinx/update_sp.py` [#397](https://github.com/canonical/sphinx-docs-starter-pack/pull/397) [#410](https://github.com/canonical/sphinx-docs-starter-pack/pull/410)
* `.github/workflows/markdown-style-checks.yml` [#379](https://github.com/canonical/sphinx-docs-starter-pack/pull/379)
* `docs/Makefile` [#379](https://github.com/canonical/sphinx-docs-starter-pack/pull/379) [#410](https://github.com/canonical/sphinx-docs-starter-pack/pull/410)
* `docs/requirements.txt` [#410](https://github.com/canonical/sphinx-docs-starter-pack/pull/410)
* `docs/.sphinx/get_vale_conf.py` [#410](https://github.com/canonical/sphinx-docs-starter-pack/pull/410)
- `docs/.sphinx/update_sp.py` [#397](https://github.com/canonical/sphinx-docs-starter-pack/pull/397) [#410](https://github.com/canonical/sphinx-docs-starter-pack/pull/410)
- `.github/workflows/markdown-style-checks.yml` [#379](https://github.com/canonical/sphinx-docs-starter-pack/pull/379)
- `docs/Makefile` [#379](https://github.com/canonical/sphinx-docs-starter-pack/pull/379) [#410](https://github.com/canonical/sphinx-docs-starter-pack/pull/410)
- `docs/requirements.txt` [#410](https://github.com/canonical/sphinx-docs-starter-pack/pull/410)
- `docs/.sphinx/get_vale_conf.py` [#410](https://github.com/canonical/sphinx-docs-starter-pack/pull/410)

### Removed

* `docs/.sphinx/.markdownlint.json` [#379](https://github.com/canonical/sphinx-docs-starter-pack/pull/379)
* `docs/.sphinx/.wordlist.txt` [#410](https://github.com/canonical/sphinx-docs-starter-pack/pull/410)
* `docs/.sphinx/spellingcheck.yaml` [#410](https://github.com/canonical/sphinx-docs-starter-pack/pull/410)

- `docs/.sphinx/.markdownlint.json` [#379](https://github.com/canonical/sphinx-docs-starter-pack/pull/379)
- `docs/.sphinx/.wordlist.txt` [#410](https://github.com/canonical/sphinx-docs-starter-pack/pull/410)
- `docs/.sphinx/spellingcheck.yaml` [#410](https://github.com/canonical/sphinx-docs-starter-pack/pull/410)

## 1.1.0

* Adds sitemap support.
* Simplifies vale binary download & install.
* Leaves vale install output in STDOUT to reveal potential problems.
* Improves update logic.
* Update Makefile logic
- Adds sitemap support.
- Simplifies vale binary download & install.
- Leaves vale install output in STDOUT to reveal potential problems.
- Improves update logic.
- Update Makefile logic

### Changed

* `docs/conf.py` [#389](https://github.com/canonical/sphinx-docs-starter-pack/pull/389)
* `docs/requirements.txt`(https://github.com/canonical/sphinx-docs-starter-pack/pull/389)
- `docs/conf.py` [#389](https://github.com/canonical/sphinx-docs-starter-pack/pull/389)
- `docs/requirements.txt`(https://github.com/canonical/sphinx-docs-starter-pack/pull/389)

## 1.0.1

Fixes an issue with Vale implementation, and adds words to main wordlist.

### Changed

* `docs/Makefile` [852c19b](https://github.com/canonical/sphinx-docs-starter-pack/commit/852c19bf162e4697d7f36b49e8bc36ad71302216)
* `docs/.sphinx/.wordlist.txt` [#367](https://github.com/canonical/sphinx-docs-starter-pack/pull/367)
* `docs/.sphinx/get_vale_conf.py` [#358](https://github.com/canonical/sphinx-docs-starter-pack/pull/358)
- `docs/Makefile` [852c19b](https://github.com/canonical/sphinx-docs-starter-pack/commit/852c19bf162e4697d7f36b49e8bc36ad71302216)
- `docs/.sphinx/.wordlist.txt` [#367](https://github.com/canonical/sphinx-docs-starter-pack/pull/367)
- `docs/.sphinx/get_vale_conf.py` [#358](https://github.com/canonical/sphinx-docs-starter-pack/pull/358)

## 1.0.0

Expand All @@ -76,24 +77,24 @@ starter pack based documentation sets.

### Added

* `CHANGELOG.md` [#357](https://github.com/canonical/sphinx-docs-starter-pack/pull/357)
* `.github/pull_request_template.md` [#357](https://github.com/canonical/sphinx-docs-starter-pack/pull/357)
* `docs/.sphinx/version` [#357](https://github.com/canonical/sphinx-docs-starter-pack/pull/357)
* `docs/.sphinx/update_sp.py` [#357](https://github.com/canonical/sphinx-docs-starter-pack/pull/357)
- `CHANGELOG.md` [#357](https://github.com/canonical/sphinx-docs-starter-pack/pull/357)
- `.github/pull_request_template.md` [#357](https://github.com/canonical/sphinx-docs-starter-pack/pull/357)
- `docs/.sphinx/version` [#357](https://github.com/canonical/sphinx-docs-starter-pack/pull/357)
- `docs/.sphinx/update_sp.py` [#357](https://github.com/canonical/sphinx-docs-starter-pack/pull/357)

### Changed

* `.readthedocs.yaml` [#357](https://github.com/canonical/sphinx-docs-starter-pack/pull/357)
* `.github/workflows/sphinx-python-dependency-build-checks.yml` [#357](https://github.com/canonical/sphinx-docs-starter-pack/pull/357)
* `docs/.sphinx/.markdownlint.json` [#357](https://github.com/canonical/sphinx-docs-starter-pack/pull/357)
* `docs/Makefile` [#357](https://github.com/canonical/sphinx-docs-starter-pack/pull/357)
* `docs/conf.py` [#357](https://github.com/canonical/sphinx-docs-starter-pack/pull/357)
* `docs/requirements.txt` [#357](https://github.com/canonical/sphinx-docs-starter-pack/pull/357)
- `.readthedocs.yaml` [#357](https://github.com/canonical/sphinx-docs-starter-pack/pull/357)
- `.github/workflows/sphinx-python-dependency-build-checks.yml` [#357](https://github.com/canonical/sphinx-docs-starter-pack/pull/357)
- `docs/.sphinx/.markdownlint.json` [#357](https://github.com/canonical/sphinx-docs-starter-pack/pull/357)
- `docs/Makefile` [#357](https://github.com/canonical/sphinx-docs-starter-pack/pull/357)
- `docs/conf.py` [#357](https://github.com/canonical/sphinx-docs-starter-pack/pull/357)
- `docs/requirements.txt` [#357](https://github.com/canonical/sphinx-docs-starter-pack/pull/357)

### Removed

* `.wokeignore` [#363](https://github.com/canonical/sphinx-docs-starter-pack/pull/363)
* `docs/.sphinx/_static/project_specific.css` [#357](https://github.com/canonical/sphinx-docs-starter-pack/pull/357)
- `.wokeignore` [#363](https://github.com/canonical/sphinx-docs-starter-pack/pull/363)
- `docs/.sphinx/_static/project_specific.css` [#357](https://github.com/canonical/sphinx-docs-starter-pack/pull/357)

## pre-version

Expand All @@ -102,26 +103,26 @@ updates.

### Added

* All files
- All files

## VERSION

{Summary of features}

### Added

* {File} {[Commit number](https://www.github.com) or [PR](https://www.github.com)}
* {File} {[Commit number](https://www.github.com) or [PR](https://www.github.com)}
* {File} {[Commit number](https://www.github.com) or [PR](https://www.github.com)}
- \{File} {[Commit number](https://www.github.com) or [PR](https://www.github.com)}
- \{File} {[Commit number](https://www.github.com) or [PR](https://www.github.com)}
- \{File} {[Commit number](https://www.github.com) or [PR](https://www.github.com)}

### Changed

* {File} {[Commit number](https://www.github.com) or [PR](https://www.github.com)}
* {File} {[Commit number](https://www.github.com) or [PR](https://www.github.com)}
* {File} {[Commit number](https://www.github.com) or [PR](https://www.github.com)}
- \{File} {[Commit number](https://www.github.com) or [PR](https://www.github.com)}
- \{File} {[Commit number](https://www.github.com) or [PR](https://www.github.com)}
- \{File} {[Commit number](https://www.github.com) or [PR](https://www.github.com)}

### Removed

* {File} {[Commit number](https://www.github.com) or [PR](https://www.github.com)}
* {File} {[Commit number](https://www.github.com) or [PR](https://www.github.com)}
* {File} {[Commit number](https://www.github.com) or [PR](https://www.github.com)}
- \{File} {[Commit number](https://www.github.com) or [PR](https://www.github.com)}
- \{File} {[Commit number](https://www.github.com) or [PR](https://www.github.com)}
- \{File} {[Commit number](https://www.github.com) or [PR](https://www.github.com)}
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -691,4 +691,4 @@ 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.
Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA.
18 changes: 12 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

The Documentation starter pack includes:

* 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
- 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

See the full documentation: https://canonical-starter-pack.readthedocs-hosted.com/

Expand All @@ -29,6 +29,12 @@ This directory contains files used for documentation build checks via GitHub's C

The file `test-starter-pack.yml` tests the functionality of the starter pack project.

### `.pre-commit-config.yaml`

This file has configuration for [pre-commit](pre-commit) checks for automatic fixes and checks, local or in CI.

It can apply the automatic fixes directly through [the GitHub App](pre-commit-ci-lite) - configure it to enable access to repositories you want it on.

## Contributing

We welcome contributions to this project! If you have suggestions, bug fixes, or improvements, please open an issue or submit a pull request.
Expand All @@ -37,5 +43,5 @@ Please read and sign our [Contributor Licence Agreement (CLA)] before submitting

<!--Links-->

[Sphinx]: https://www.sphinx-doc.org/
[Contributor Licence Agreement (CLA)]: https://ubuntu.com/legal/contributors
[contributor licence agreement (cla)]: https://ubuntu.com/legal/contributors
[sphinx]: https://www.sphinx-doc.org/
16 changes: 8 additions & 8 deletions docs/.sphinx/get_vale_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@
def clone_repo_and_copy_paths(file_source_dest, overwrite=False):
"""
Clone the repository to a temporary directory and copy required files

Args:
file_source_dest: dictionary of file paths to copy from the repository,
and their destination paths
overwrite: boolean flag to overwrite existing files in the destination

Returns:
bool: True if all files were copied successfully, False otherwise
"""
Expand All @@ -52,8 +52,8 @@ def clone_repo_and_copy_paths(file_source_dest, overwrite=False):

try:
result = subprocess.run(
clone_cmd,
capture_output=True,
clone_cmd,
capture_output=True,
text=True,
check=True
)
Expand All @@ -73,7 +73,7 @@ def clone_repo_and_copy_paths(file_source_dest, overwrite=False):
continue

if not copy_files_to_path(source_path, dest, overwrite):
is_copy_success = False
is_copy_success = False
logging.error("Failed to copy %s to %s", source_path, dest)

# Clean up temporary directory
Expand All @@ -85,12 +85,12 @@ def clone_repo_and_copy_paths(file_source_dest, overwrite=False):
def copy_files_to_path(source_path, dest_path, overwrite=False):
"""
Copy a file or directory from source to destination

Args:
source_path: Path to the source file or directory
dest_path: Path to the destination
overwrite: Boolean flag to overwrite existing files in the destination

Returns:
bool: True if copy was successful, False otherwise
"""
Expand Down Expand Up @@ -138,7 +138,7 @@ def main():
# Parse command line arguments, default to overwrite_enabled = True
overwrite_enabled = not parse_arguments().no_overwrite

# Download into /tmp through git clone
# Download into /tmp through git clone
if not clone_repo_and_copy_paths(vale_files_dict, overwrite=overwrite_enabled):
logging.error("Failed to download files from repository")
return 1
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
# TODO: To enable listing contributors on individual pages, set to True
"display_contributors": False,

# Required for feedback button
# Required for feedback button
'github_issues': 'enabled',
}

Expand Down
2 changes: 1 addition & 1 deletion docs/how-to/build.rst
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ 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.
Expand Down
Loading
Loading