Skip to content

Read linkcheck_ignore from a project's _config.yml #6

Description

@mmcky

Split out of #2, where it was raised as a comment rather than as one of the two numbered requests. #2 shipped ignore-patterns as an explicit input; this is the follow-up idea of having the action discover the list instead.

The problem

Every QuantEcon lecture repo already maintains an exclusion list in lectures/_config.yml under sphinx.config.linkcheck_ignore, for Sphinx's own link checker. For lecture-python-programming that list holds ten accumulated false positives — fred.stlouisfed.org, keras.io, data.oecd.org, reddit.com, openai.com, chatgpt.com, an ieeexplore.ieee.org DOI, a sciencedirect.com article and a pinned matplotlib source link.

This action scans built HTML rather than running through Sphinx, so it never sees that configuration. With ignore-patterns as it shipped in #3, a repo that wants both checkers quiet has to maintain the same list twice, and the two will drift.

The proposal

Add an input pointing at the project's config file — say ignore-patterns-file: 'lectures/_config.yml' — from which the action reads sphinx.config.linkcheck_ignore and appends those patterns to whatever ignore-patterns already specifies. The patterns are regular expressions on both sides, so they carry over directly.

One list per repo instead of two, and every existing lecture repo inherits its own exclusions with a single workflow edit.

Trade-offs to weigh before building it

Consideration Detail
New dependency Reading YAML means adding PyYAML to requirements.txt. The action currently needs only requests and beautifulsoup4
Second configuration surface Two places a URL can be exempted, so "why is this link not being checked?" gets harder to answer. Mitigated by logging which patterns came from where
Both routes need a workflow edit anyway The argument that this saves work is weaker than it first appears — a repo has to add the input either way. The saving is on maintenance, not adoption
Jupyter Book 2 The lecture repos are migrating from _config.yml to myst.yml, which has no linkcheck_ignore equivalent. Anything built against the Sphinx key has a limited shelf life, and post-migration the action-level list becomes the only place to record these

That last row is the one I would decide on first. If the migration lands soon, this feature is obsolete on arrival and the effort is better spent making ignore-patterns pleasant to maintain — for example a shared list referenced from several workflows.

Semantics note

Sphinx applies linkcheck_ignore with re.match, anchored at the start of the URI. This action uses re.search, which matches anywhere. Patterns imported from a Sphinx list would therefore match slightly more here than they do under Sphinx, which is worth either normalising or documenting.

Prior art

QuantEcon/lecture-python-programming#518 tried a workflow-side workaround — rewriting matching hrefs to # in the built HTML before the checker ran. It was closed on 2026-04-14 as not the approach we want, and rightly so: mangling the build artifact to satisfy the checker also masks genuine breakage in those same files. Recording it here so it does not get re-proposed.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions