Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode Skip to content
Repomatic has been maintained for 4+ years, and is free to use. You can help if you 🤝 purchase business support or 🫶 sponsor the project.
Repomatic
Light Logo Dark Logo
  • Installation
  • CLI
  • Man pages
  • Configuration
  • Dependency management
  • Tool runner
  • Reusable workflows
  • Test matrix
  • Nuitka compilation
  • Security
  • Benchmark

Agent tooling

  • Agent skills
  • Subagents
    • grunt-qa
    • qa-engineer
    • sphinx-docs
  • Claude Code plugin

Contributing

  • Contributing
  • Commit messages
  • Packaging
  • Code of conduct

Developing repomatic

  • Upstream development
  • Automated operation contracts
  • Upstream

API reference

  • repomatic package
    • repomatic.cli package
      • repomatic.cli.ci module
      • repomatic.cli.deps module
      • repomatic.cli.github module
      • repomatic.cli.main module
      • repomatic.cli.release module
      • repomatic.cli.repo module
      • repomatic.cli.site module
      • repomatic.cli.tools module
    • repomatic.cloudflare package
      • repomatic.cloudflare.api module
      • repomatic.cloudflare.pages module
      • repomatic.cloudflare.r2 module
      • repomatic.cloudflare.redirects module
    • repomatic.data package
      • repomatic.data.awesome_template package
    • repomatic.deps package
      • repomatic.deps.audit module
      • repomatic.deps.cooldown module
      • repomatic.deps.graph module
      • repomatic.deps.lockfile module
      • repomatic.deps.pins module
      • repomatic.deps.policy module
      • repomatic.deps.provenance module
      • repomatic.deps.report module
      • repomatic.deps.requirements module
      • repomatic.deps.shippable module
      • repomatic.deps.sources module
      • repomatic.deps.sync module
      • repomatic.deps.uv module
    • repomatic.github package
      • repomatic.github.caches module
      • repomatic.github.ci_status module
      • repomatic.github.dev_release module
      • repomatic.github.event module
      • repomatic.github.gh module
      • repomatic.github.issue module
      • repomatic.github.job_timings module
      • repomatic.github.labels module
      • repomatic.github.outputs module
      • repomatic.github.pr module
      • repomatic.github.pr_body module
      • repomatic.github.release_sync module
      • repomatic.github.releases module
      • repomatic.github.runs module
      • repomatic.github.sponsor module
      • repomatic.github.status module
      • repomatic.github.threads module
      • repomatic.github.token module
      • repomatic.github.unsubscribe module
      • repomatic.github.urls module
      • repomatic.github.workflow_files module
      • repomatic.github.workflow_sync module
    • repomatic.init package
      • repomatic.init.local_edits module
      • repomatic.init.removed_assets module
      • repomatic.init.run module
      • repomatic.init.tool_config module
      • repomatic.init.upgrade module
    • repomatic.lint_repo package
      • repomatic.lint_repo.context module
      • repomatic.lint_repo.pins module
      • repomatic.lint_repo.repo module
      • repomatic.lint_repo.roster module
      • repomatic.lint_repo.settings module
      • repomatic.lint_repo.site module
      • repomatic.lint_repo.tool_config module
      • repomatic.lint_repo.workflows module
    • repomatic.matrix package
      • repomatic.matrix.axes module
      • repomatic.matrix.model module
      • repomatic.matrix.runner_sync module
      • repomatic.matrix.runners module
    • repomatic.metadata package
      • repomatic.metadata.core module
      • repomatic.metadata.env module
      • repomatic.metadata.git module
      • repomatic.metadata.matrix module
      • repomatic.metadata.output module
      • repomatic.metadata.project module
    • repomatic.metrics package
      • repomatic.metrics.chart module
      • repomatic.metrics.forge module
      • repomatic.metrics.store module
    • repomatic.release package
      • repomatic.release.attestation module
      • repomatic.release.binaries_page module
      • repomatic.release.binary module
      • repomatic.release.manpages module
      • repomatic.release.prepare_release module
      • repomatic.release.protocol module
      • repomatic.release.self_pin module
      • repomatic.release.verify module
      • repomatic.release.virustotal module
    • repomatic.templates package
    • repomatic.tooling package
      • repomatic.tooling.binaries module
      • repomatic.tooling.checksums module
      • repomatic.tooling.nuitka module
      • repomatic.tooling.registry module
      • repomatic.tooling.runner module
    • repomatic.awesome_toc module
    • repomatic.broken_links module
    • repomatic.bundle module
    • repomatic.cache module
    • repomatic.changelog module
    • repomatic.checks module
    • repomatic.claude_plugin module
    • repomatic.components module
    • repomatic.config module
    • repomatic.docs module
    • repomatic.file_inventory module
    • repomatic.file_ops module
    • repomatic.frontmatter module
    • repomatic.git_ops module
    • repomatic.gitignore module
    • repomatic.hashing module
    • repomatic.http module
    • repomatic.humanize module
    • repomatic.images module
    • repomatic.lint_changelog module
    • repomatic.mailmap module
    • repomatic.markdown module
    • repomatic.npm module
    • repomatic.pypi module
    • repomatic.pyproject module
    • repomatic.setup_guide module
    • repomatic.skills module
    • repomatic.tabular module
    • repomatic.templating module
    • repomatic.upstream module
    • repomatic.versions module
  • tests package
    • tests.conftest module
    • tests.test_attestation module
    • tests.test_awesome_template module
    • tests.test_awesome_toc module
    • tests.test_binaries module
    • tests.test_binaries_page module
    • tests.test_binary module
    • tests.test_broken_links module
    • tests.test_cache module
    • tests.test_changelog module
    • tests.test_checks module
    • tests.test_checksums module
    • tests.test_ci_status module
    • tests.test_claude_assets module
    • tests.test_cli module
    • tests.test_cloudflare module
    • tests.test_cloudflare_r2 module
    • tests.test_config module
    • tests.test_coverage_floor module
    • tests.test_dep_graph module
    • tests.test_dep_policy module
    • tests.test_dep_report module
    • tests.test_dep_sources module
    • tests.test_dev_release module
    • tests.test_docs module
    • tests.test_docstrings module
    • tests.test_event module
    • tests.test_file_ops module
    • tests.test_forge module
    • tests.test_frontmatter module
    • tests.test_gh module
    • tests.test_git_ops module
    • tests.test_github_caches module
    • tests.test_gitignore module
    • tests.test_hashing module
    • tests.test_help module
    • tests.test_http module
    • tests.test_humanize module
    • tests.test_images module
    • tests.test_imports module
    • tests.test_init_project module
    • tests.test_issue module
    • tests.test_job_timings module
    • tests.test_labels module
    • tests.test_lint_changelog module
    • tests.test_lint_repo module
    • tests.test_mailmap module
    • tests.test_manpages module
    • tests.test_markdown module
    • tests.test_matrix module
    • tests.test_metadata module
    • tests.test_metadata_git module
    • tests.test_metrics module
    • tests.test_npm module
    • tests.test_nuitka module
    • tests.test_outputs module
    • tests.test_pages_redirects module
    • tests.test_platform_keys module
    • tests.test_plugin module
    • tests.test_plugin_update_detection module
    • tests.test_pr module
    • tests.test_pr_body module
    • tests.test_prepare_release module
    • tests.test_protocol module
    • tests.test_provenance module
    • tests.test_pypi module
    • tests.test_pyproject module
    • tests.test_readme module
    • tests.test_release_sync module
    • tests.test_release_workflow_steps module
    • tests.test_releases module
    • tests.test_runner_catalog module
    • tests.test_runner_sync module
    • tests.test_runs module
    • tests.test_self_pin module
    • tests.test_setup_guide module
    • tests.test_skills module
    • tests.test_sphinx_crossrefs module
    • tests.test_sponsor module
    • tests.test_status module
    • tests.test_suite_hygiene module
    • tests.test_sync_ops module
    • tests.test_tabular module
    • tests.test_templating module
    • tests.test_threads module
    • tests.test_todolist module
    • tests.test_token module
    • tests.test_tool_runner module
    • tests.test_unsubscribe module
    • tests.test_upstream module
    • tests.test_urls module
    • tests.test_uv module
    • tests.test_verify module
    • tests.test_version_sync module
    • tests.test_versions module
    • tests.test_virustotal module
    • tests.test_vulnerable_deps module
    • tests.test_workflow_files module
    • tests.test_workflow_sync module
    • tests.test_workflows module
  • Index
  • Module Index

Release and hosting

  • Binaries
  • Cloudflare Pages

Project

  • Changelog
  • Changelog archive
  • History
  • Todo list
  • License
  • GitHub repository
  • Funding
Back to top
View this page
Edit this page

repomatic.broken_links module¶

Broken links detection and reporting.

Combines Lychee and Sphinx linkcheck results into a single “Broken links” GitHub issue. Sphinx linkcheck parsing detects broken auto-generated links (intersphinx, autodoc, type annotations) that Lychee cannot see because they only exist in the rendered HTML output.

run_lychee() runs the Lychee crawl itself, through the tool runner, and reads back the report and the exit code. No workflow step has to relay either.

Each checker reports one LinkVerdict. Only a run that completed can clear the issue: a checker that did not finish says nothing about the links, so it never closes an open issue.

Issue lifecycle management is delegated to issue.

repomatic.broken_links.ISSUE_TITLE = 'Broken links'¶

Issue title used for the combined broken links report.

repomatic.broken_links.DOCUMENTATION_LABEL = '📚 documentation'¶

Label of the broken links issue, outside awesome lists.

repomatic.broken_links.FIX_LINK_LABEL = '🩹 fix link'¶

Label of the broken links issue in an awesome-* repository.

repomatic.broken_links.LYCHEE_BROKEN_LINKS_EXIT = 2¶

The one lychee exit code that reports on the links rather than on the run.

Lychee exits 0 on success, 1 on an unexpected failure, 2 when it found broken links, and 3 on a config error. Only 2 is a verdict about the links; 1 and 3 say the run itself did not complete, so neither “broken links found” nor “no broken links” can be claimed from them.

repomatic.broken_links.LYCHEE_REPORT_FORMAT: Final[tuple[str, ...]] = ('--format', 'markdown')¶

Flags that make lychee write the markdown report the issue body embeds.

repomatic.broken_links.LYCHEE_INSTALL_FAILURE_EXIT = 1¶

Exit code a lychee that could not be installed counts as.

The one lychee itself returns on an unexpected failure: like a crash, a missing tool checks no link, so the issue is left as it is.

repomatic.broken_links.SPHINX_DEFAULT_OUTPUT = PosixPath('docs/_linkcheck/output.json')¶

Default Sphinx linkcheck output path produced by the docs.yaml workflow.

repomatic.broken_links.NO_BROKEN_LINKS = 'No broken links found.'¶

The section body of a checker that completed and found nothing broken.

class repomatic.broken_links.LinkVerdict(*values)[source]¶

Bases: StrEnum

What one checker’s run says about the links it covers.

BROKEN = 'broken'¶

The run completed and found broken links.

CLEAN = 'clean'¶

The run completed and found no broken link.

UNKNOWN = 'unknown'¶

The run did not complete, or left no report: nothing can be claimed.

class repomatic.broken_links.LycheeRun(exit_code, report=None)[source]¶

Bases: object

What one lychee crawl of the documentation files returned.

exit_code: int¶

Exit code of lychee. See LYCHEE_BROKEN_LINKS_EXIT.

report: str | None = None¶

The markdown report lychee wrote, None when it wrote none.

repomatic.broken_links.run_lychee()[source]¶

Crawl the documentation files with lychee, and keep its report.

Runs the invocation of a bare repomatic run lychee: the default arguments of the registry, over the doc_files inventory. The markdown report goes to a scratch file this function reads back, so no workflow step has to agree on a path with it.

A lychee that cannot be installed checked no link, so it counts as a run that did not complete: LYCHEE_INSTALL_FAILURE_EXIT.

Return type:

LycheeRun | None

Returns:

The run, or None when the repository holds no documentation file: lychee has nothing to check, and its section is left out.

class repomatic.broken_links.LinkcheckResult(filename, lineno, status, uri, info)[source]¶

Bases: object

A single result entry from Sphinx linkcheck output.json.

Each line in the JSON-lines file corresponds to one checked URI.

filename: str¶

Source file the link was found in, relative to the docs root.

lineno: int¶

Line of the link in that file.

status: str¶

Linkcheck status, like working, broken or timeout.

uri: str¶

The checked URI.

info: str¶

What linkcheck says about the result, like the HTTP error.

repomatic.broken_links.parse_output_json(output_json)[source]¶

Parse the Sphinx linkcheck output.json file.

The file uses JSON-lines format: one JSON object per line. Blank lines are skipped.

Parameters:

output_json (Path) – Path to the output.json file.

Return type:

list[LinkcheckResult]

Returns:

List of parsed linkcheck results.

repomatic.broken_links.filter_broken(results)[source]¶

Filter results to only broken and timed-out links.

Parameters:

results (Iterable[LinkcheckResult]) – Iterable of linkcheck results.

Return type:

list[LinkcheckResult]

Returns:

List of results with status of "broken" or "timeout".

repomatic.broken_links.generate_markdown_report(broken, source_url=None)[source]¶

Generate a Markdown report of broken links grouped by source file.

The report starts with H2 file headings, suitable for embedding as a section in the combined broken links issue body.

Parameters:
  • broken (list[LinkcheckResult]) – List of broken linkcheck results.

  • source_url (str | None) – Base URL for linking filenames and line numbers. When provided, file headers become clickable links and line numbers deep-link to the specific line.

Return type:

str

Returns:

Markdown-formatted report string.

repomatic.broken_links.get_label(repo_name)[source]¶

Return the label the broken links issue carries in a repository.

Parameters:

repo_name (str) – The repository name.

Return type:

str

Returns:

FIX_LINK_LABEL for awesome-* repos, else DOCUMENTATION_LABEL.

repomatic.broken_links.lychee_section(run)[source]¶

Render the Lychee section of the issue body, with its verdict.

Only LYCHEE_BROKEN_LINKS_EXIT reports on the links themselves, and only with a report to show: a broken-links verdict with nothing to show would file an issue whose body claims the links are fine. Every other non-zero code reports that the run failed.

Parameters:

run (LycheeRun) – The lychee crawl.

Return type:

tuple[str, LinkVerdict]

Returns:

The section markdown, and what it says about the links.

repomatic.broken_links.sphinx_section(output_json, source_url=None)[source]¶

Render the Sphinx linkcheck section of the issue body, with its verdict.

Parameters:
  • output_json (Path) – Path to Sphinx linkcheck output.json.

  • source_url (str | None) – Base URL for linking filenames and line numbers.

Return type:

tuple[str, LinkVerdict]

Returns:

The section markdown, and what it says about the links.

repomatic.broken_links.manage_combined_broken_links_issue(repo_name=None, lychee=None, sphinx_output_json=None, sphinx_source_url=None)[source]¶

Manage the combined broken links issue lifecycle.

Combines results from Lychee and Sphinx linkcheck into a single “Broken links” issue. Each tool’s results appear under its own heading. Tools that were not run are omitted from the report.

The issue is filed or updated when any checker found broken links, and closed when every checker that ran completed clean. When no checker found broken links but one did not complete, the issue is left as it is: the links that run covers might still be broken. When no checker ran at all, the issue is left as it is too, with a warning: nothing was checked.

When running in GitHub Actions, most parameters are auto-detected from Metadata and well-known file paths:

  • repo_name defaults to Metadata.repo_name.

  • sphinx_output_json defaults to SPHINX_DEFAULT_OUTPUT when the file exists.

  • sphinx_source_url is composed from Metadata.repo_url and Metadata.sha.

Parameters:
  • repo_name (str | None) – Repository name, for label selection.

  • lychee (LycheeRun | None) – The lychee crawl from run_lychee(), None if lychee did not run.

  • sphinx_output_json (Path | None) – Path to Sphinx linkcheck output.json.

  • sphinx_source_url (str | None) – Base URL for linking filenames and line numbers in the Sphinx report.

Return type:

LinkVerdict | None

Returns:

The combined verdict, or None when no checker ran.

Raises:

ValueError – If repo_name cannot be determined.

Next
repomatic.bundle module
Previous
repomatic.awesome_toc module
Copyright © Kevin Deldycke and contributors
Made with Furo
Last updated on 2026-11-16
On this page
  • repomatic.broken_links module
    • ISSUE_TITLE
    • DOCUMENTATION_LABEL
    • FIX_LINK_LABEL
    • LYCHEE_BROKEN_LINKS_EXIT
    • LYCHEE_REPORT_FORMAT
    • LYCHEE_INSTALL_FAILURE_EXIT
    • SPHINX_DEFAULT_OUTPUT
    • NO_BROKEN_LINKS
    • LinkVerdict
      • LinkVerdict.BROKEN
      • LinkVerdict.CLEAN
      • LinkVerdict.UNKNOWN
    • LycheeRun
      • LycheeRun.exit_code
      • LycheeRun.report
    • run_lychee()
    • LinkcheckResult
      • LinkcheckResult.filename
      • LinkcheckResult.lineno
      • LinkcheckResult.status
      • LinkcheckResult.uri
      • LinkcheckResult.info
    • parse_output_json()
    • filter_broken()
    • generate_markdown_report()
    • get_label()
    • lychee_section()
    • sphinx_section()
    • manage_combined_broken_links_issue()