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
1 change: 1 addition & 0 deletions docs/about/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ The current members of the MkDocs-NG team.
### Fixed

* Fix anchor link validation so `mkdocs build -v --strict` still fails when missing anchors are reported as warnings. #30
* Fix `validation.links.not_found` is always reported as INFO for excluded pages. #32

### Maintenance

Expand Down
5 changes: 4 additions & 1 deletion mkdocs/structure/pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

from mkdocs import utils
from mkdocs.structure import StructureItem
from mkdocs.structure.files import InclusionLevel
from mkdocs.structure.toc import get_toc
from mkdocs.utils import (
_removesuffix,
Expand Down Expand Up @@ -533,10 +534,12 @@ def path_to_url(self, url: str) -> str:
if target_file.inclusion.is_excluded():
if self.file.inclusion.is_excluded():
warning_level = logging.DEBUG
else:
elif target_file.inclusion is InclusionLevel.DRAFT:
warning_level = min(
logging.INFO, self.config.validation.links.not_found
)
else:
warning_level = self.config.validation.links.not_found
warning = (
f"Doc file '{self.file.src_uri}' contains a link to "
f"'{target_uri}' which is excluded from the built site."
Expand Down
23 changes: 23 additions & 0 deletions mkdocs/tests/build_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,29 @@ def test_draft_pages_with_invalid_links(self, site_dir, docs_dir):

self.assertPathNotExists(site_dir, ".zoo.html")

@tempdir(
files={
"index.md": "[asdf](./asdf.md)",
"asdf.md": "excluded content",
}
)
@tempdir()
def test_excluded_page_link_uses_not_found_validation_level(
self, site_dir, docs_dir
):
cfg = load_config(
docs_dir=docs_dir,
site_dir=site_dir,
validation=dict(links=dict(not_found="warn")),
exclude_docs="/asdf.md",
)

expected_logs = """
WARNING:Doc file 'index.md' contains a link to 'asdf.md' which is excluded from the built site.
"""
with self._assert_build_logs(expected_logs):
build.build(cfg)

@tempdir(
files={
"foo/README.md": "page1 content",
Expand Down
Loading