Skip to content
Merged
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
4 changes: 4 additions & 0 deletions docs/about/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ The current members of the MkDocs-NG team.

## Version 1.7.1 (Unreleased)

### Fixed

* Fix anchor link validation so `mkdocs build -v --strict` still fails when missing anchors are reported as warnings. #30

### Maintenance

* Remove the unmaintained `mergedeep` dependency by replacing it with an internal deep-merge helper for inherited YAML configuration. #29
Expand Down
2 changes: 1 addition & 1 deletion mkdocs/structure/pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ def render(self, config: MkDocsConfig, files: Files) -> None:
self.present_anchor_ids = (
extract_anchors_ext.present_anchor_ids | raw_html_ext.present_anchor_ids
)
if log.getEffectiveLevel() > logging.DEBUG:
if config.validation.links.anchors > logging.DEBUG:
self.links_to_anchors = relative_path_ext.links_to_anchors

present_anchor_ids: set[str] | None = None
Expand Down
24 changes: 24 additions & 0 deletions mkdocs/tests/build_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import contextlib
import io
import logging
import os.path
import re
import textwrap
Expand Down Expand Up @@ -769,6 +770,29 @@ def test_anchor_warning(self, site_dir, docs_dir):
with self._assert_build_logs(expected_logs):
build.build(cfg)

@tempdir(
files={
"index.md": "[missing anchor](#missing)",
}
)
@tempdir()
def test_anchor_warning_with_debug_logging(self, site_dir, docs_dir):
cfg = load_config(
docs_dir=docs_dir, site_dir=site_dir, validation={"anchors": "warn"}
)

pages_log = logging.getLogger("mkdocs.structure.pages")
original_level = pages_log.level
pages_log.setLevel(logging.DEBUG)
try:
expected_logs = """
WARNING:Doc file 'index.md' contains a link '#missing', but there is no such anchor on this page.
"""
with self._assert_build_logs(expected_logs):
build.build(cfg)
finally:
pages_log.setLevel(original_level)

@tempdir(
files={
"test/foo.md": "[bar](bar.md#heading1)",
Expand Down
Loading