Skip to content

check-anchors duplicates mkdocs 1.6 validation.links.anchors on both consuming repos #13

Description

@mairas

check_anchors.py's module docstring says mkdocs build --strict "does not
validate anchors at all". That was true before mkdocs 1.6. It is not true now,
and both consuming repos are on mkdocs 1.6.1.

Setting

validation:
  links:
    anchors: warn

makes mkdocs build --strict fail on a broken fragment. Measured:

  • On halos-org/docs, adding [Broken](index.md#no-such-heading-here) to
    docs/index.md produces exactly one warning and aborts the strict build. No
    other warning appears, so the existing content is clean under it, and
    print_page/ needs no exclusion — mkdocs validates source markdown, not
    generated output.
  • On a two-page, one-locale probe with mkdocs-static-i18n, a fragment in
    docs/fi/second.md pointing at a heading absent from docs/fi/index.md is
    caught the same way. The cross-locale case that motivated check-anchors is
    covered.

The remaining unique coverage of check-anchors is links mkdocs does not parse
from source: root-absolute markdown links, and raw HTML <a href>. Counted
across both repos:

halos-org/docs hatlabs/halpi2
markdown links carrying a fragment 20 530
of those, root-absolute 0 0
raw HTML anchor links 0 0

So today check-anchors catches nothing in either repo that the config line
would not, while costing a dependency and a --exclude 'print_page/*' argument
that exists only because it reads generated output.

It is not strictly redundant — it checks the built site, so it would catch a
theme or plugin emitting a dead fragment, and root-absolute links if either repo
ever writes one. But the docstring's justification is stale and the value is
much smaller than it claims.

Decide one of:

  1. Keep it, correct the docstring, and recommend validation.links.anchors in
    the README as the cheap first line of defence.
  2. Keep it only for the built-site cases mkdocs cannot see, and document that
    narrower purpose.
  3. Drop it, and have consuming repos set the config line instead.

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