repomatic.lint_repo.site module

Checks of the site deployment: GitHub Pages and Cloudflare Pages.

The GitHub Pages source and the redirect of its legacy URLs, the Cloudflare credentials, the _redirects files as the Pages engine reads them, the wrangler.toml file, the files over the Pages size limit, whether the Sphinx build stops a dead fragment link before it publishes, and the title octicon of each docs page.

repomatic.lint_repo.site.API_PAGE_TITLE_RE = re.compile('^# `?[\\w.]+`? (?:module|package)$')

The title sphinx-apidoc gives a generated module page.

Such a page keeps a plain title: the sidebar marks the generated entries with SIDEBAR_OCTICONS instead.

repomatic.lint_repo.site.FAIL_ON_WARNINGS_CONFIG = 'click_extra_fail_on_warnings'

The conf.py value listing the warning types that fail a Sphinx build.

click-extra’s Sphinx extension reads it, with the syntax of suppress_warnings: myst covers every subtype, myst.xref_missing only that one. Named here rather than imported, because click-extra’s Sphinx modules import Sphinx.

repomatic.lint_repo.site.FAIL_ON_WARNINGS_EXTENSIONS = frozenset({'click_extra.sphinx', 'click_extra.sphinx.fail_on_warnings'})

The extensions that register FAIL_ON_WARNINGS_CONFIG.

Sphinx ignores a conf.py value that no loaded extension registers.

The warning types that cover a fragment link myst-parser cannot place.

An entry of suppress_warnings or FAIL_ON_WARNINGS_CONFIG names either the whole myst type or its xref_missing subtype.

repomatic.lint_repo.site.MAX_REPORTED_DEAD_URLS = 5

How many abandoned redirect sources a failing _redirects check names.

Enough to recognize which part of the file fell off the end, short of dumping a tail that can run to hundreds of rules into one lint message. The remainder is counted rather than listed, and the fix is the same reorder either way.

repomatic.lint_repo.site.OCTICON_REGISTRY_FILE = 'octicons.toml'

The bundled data file OcticonRegistry reads.

repomatic.lint_repo.site.PAGES_DEPLOYMENT_SOURCE: Final = RepoSettingProbe(label='Pages deployment source check', endpoint='pages', field='build_type', pass_message='GitHub Pages deployment source is set to GitHub Actions.', fail_message="GitHub Pages deployment source is set to 'Deploy from a branch'. Change it to 'GitHub Actions' under https://github.com/{repo}/settings/pages so the docs.yaml workflow can deploy.", passing=frozenset({'workflow'}), failing=frozenset({'legacy'}), unknown='unknown build_type {value!r}', unavailable='Pages not configured or API inaccessible')

The GitHub Pages build_type, read by check_pages_deployment_source().

repomatic.lint_repo.site.SIDEBAR_OCTICONS = frozenset({'code-review', 'codescan-checkmark', 'list-unordered', 'package'})

The octicons the sidebar draws beside the entries that Sphinx generates.

The custom.css toctree rule of the sphinx-docs agent marks the package page, the tests page, genindex and modindex with them. A page title that takes one reads as one of those entries.

repomatic.lint_repo.site.TITLE_OCTICON_RE = re.compile('^# \\{octicon\\}`(?P<icon>[^`;]+)')

An octicon role that opens a page title, without its size and class options.

repomatic.lint_repo.site.check_pages_deployment_source(ctx)[source]

Check that GitHub Pages is deployed through GitHub Actions, not a branch.

The docs.yaml workflow uses actions/upload-pages-artifact and actions/deploy-pages, which require the Pages source to be set to GitHub Actions in the repository settings. Branch-based deployment (legacy) is incompatible.

Note

A 404 means Pages is not configured at all. This is treated as indeterminate (None) rather than a failure, because the repository may not have deployed docs yet.

Return type:

CheckResult

repomatic.lint_repo.site.check_pages_redirect_preserved(ctx)[source]

Check that the old github.io URLs still redirect to the live site.

A repository whose site moved to Cloudflare Pages keeps its <owner>.github.io/<repo>/… URLs answering through a single field: the GitHub Pages custom domain. Set it, and GitHub redirects that whole space with a path-preserving 301, for free, covering paths the site never even had. What it rescues is precisely the set of URLs nobody can rewrite: search indexes, other projects’ readmes, and the [project.urls] metadata frozen into every release already published.

Two ways to lose it, both invisible from inside the repository. Disabling Pages deletes the redirect along with the site, and every historical link starts answering 404 with nothing to show a maintainer why. Leaving the custom domain unset is quieter still: the old host keeps serving a copy of the documentation, which stops being rebuilt the moment the deploy job is gated off, so the two hosts disagree more with every release.

Return type:

CheckResult

Returns:

A CheckResult. passed is None when the repository has no legacy Pages URLs to preserve, or the declared URL is unreadable.

repomatic.lint_repo.site.check_stale_gh_pages_branch(ctx)[source]

Check for a leftover gh-pages branch after switching to GitHub Actions.

When Pages is deployed through GitHub Actions, the gh-pages branch is no longer needed and should be deleted to avoid confusion.

Return type:

CheckResult

Check that the Sphinx build fails on a fragment link that lands nowhere.

myst-parser resolves each `text <#anchor>`_ and `text <page.md#anchor>`_ link against what the build produced. For a link it cannot place, it logs a myst.xref_missing warning and ships the link as written, and Sphinx still exits 0. The Docs workflow runs no anchor check of its own, so only FAIL_ON_WARNINGS_CONFIG stops the dead link before it publishes. A suppress_warnings entry for the type defeats it: click-extra skips a suppressed warning.

Return type:

CheckResult

class repomatic.lint_repo.site.OcticonRegistry(icons, families)[source]

Bases: object

The title octicon of each hand-written docs page.

One registry covers every repository that follows the conventions of the sphinx-docs agent, so an octicon keeps one meaning across their sites. The agent carries the registry as a table, which markdown_table() renders.

Todo

Review the octicon of each page once a sphinx-design release carries executablebooks/sphinx-design#309, which adds 81 icons to the 328 of 0.7.0, like agent, ai-model and flowchart. Adopt a new icon only once the docs dependencies of every site that takes it require that release: 0.7.0 reports an error on an icon it does not know, and renders the role as plain text.

icons: dict[str, tuple[str, ...]]

The page patterns of each octicon, in the order of the file.

A pattern is a page file name or a glob of them, like cli-*.md.

families: dict[str, tuple[str, ...]]

The page patterns that one repository may give the same octicon.

A family documents one feature, so a reader scans its pages as a group rather than tells them apart by icon.

classmethod load()[source]

Read the registry from the bundled OCTICON_REGISTRY_FILE.

Return type:

OcticonRegistry

icon_of(page)[source]

The octicon of the first row that lists page, if a row does.

Return type:

str | None

is_family(icon, pages)[source]

Whether all of pages belong to the family of icon.

Return type:

bool

markdown_table()[source]

The registry as the Markdown table of the sphinx-docs agent.

Each column pads to its widest cell, the way mdformat aligns a table, so a formatter pass over the agent leaves the table as it is.

Return type:

str

repomatic.lint_repo.site.check_title_octicons(ctx)[source]

Check the title octicon of each docs page against OcticonRegistry.

Furo shows the title octicon of a page in the sidebar, where a reader finds the page by it. The icon helps only while it names one kind of page across the sites, and one page per site. A generated module page keeps a plain title. A page with no # title, like an index.md that includes the readme, has no title to check.

Return type:

Iterator[CheckResult]

repomatic.lint_repo.site.check_cloudflare_secrets(ctx)[source]

Report whether the Cloudflare Pages deploy has the credential it needs.

One secret, and no identifier beside it: the account is derived from the token at run time, since an account-owned token holding Cloudflare Pages: Edit and nothing else still enumerates the account it belongs to, measured on 2026-08-16 against a cfat_ token with exactly that scope. The token is the whole of the authentication surface.

Return type:

CheckResult

repomatic.lint_repo.site.check_cloudflare_r2_secrets(ctx)[source]

Report whether the offload can upload to the declared R2 bucket.

Without the key pair the deploy still publishes, but it drops every file over the Pages limit: the very files the bucket was declared to serve. The pair is limited to that bucket, which Cloudflare allows on the S3 API only, so CLOUDFLARE_API_TOKEN cannot stand in for it.

Return type:

CheckResult

repomatic.lint_repo.site.check_pages_redirects(ctx)[source]

Audit every committed _redirects file the way the Pages engine reads it.

The engine’s budget accounting is undocumented and its failures are silent: wrangler pages deploy prints nothing when the parser drops a rule or abandons the file, and a dead redirect looks exactly like a URL nobody visits. One site carried 18 dead rules for years this way. The replica in repomatic.cloudflare.redirects reports here what production would do.

Return type:

Iterator[CheckResult]

repomatic.lint_repo.site.check_wrangler_config(ctx)[source]

Check the committed wrangler.toml against the declared Cloudflare state.

The file only matters to local wrangler commands on a Direct Upload project, but it can still contradict the repository’s declared state in two places Cloudflare will not reconcile for anyone: the project name the CI deploy targets, and the compatibility date the live project honours server-side. One value sat three years behind the live one this way, because nothing read it.

Return type:

Iterator[CheckResult]

repomatic.lint_repo.site.check_oversized_site_files(ctx)[source]

Warn about tracked files the Cloudflare Pages deploy cannot upload.

Direct Upload rejects any file over the Pages limit. The deploy drops such a file unless an R2 bucket takes it, and a dropped file leaves a dead link. No setting names the site’s sources, so the check reads every tracked file: a large file outside the site is a false alarm, which is why this warns and never fails.

Return type:

CheckResult