Skip to content
Merged
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
18 changes: 14 additions & 4 deletions mkdocs/structure/nav.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,22 @@ def _data_to_navigation(data, files: Files, config: MkDocsConfig):
f"A reference to '{file.src_path}' is included in the 'nav' "
"configuration, but this file is excluded from the built site.",
)
if file.page is not None:
if not isinstance(file.page, Page):
page = file.page
if page is not None:
if isinstance(page, Page):
if type(page) is not Page: # Strict subclass
return page
warnings.warn(
"A plugin has set File.page to an instance of Page and it got overwritten. "
"The behavior of this will change in MkDocs 1.6.",
DeprecationWarning,
)
else:
warnings.warn( # type: ignore[unreachable]
"File.page should not be set to any type other than Page", DeprecationWarning
"A plugin has set File.page to a type other than Page. "
"This will be an error in MkDocs 1.6.",
DeprecationWarning,
)
return file.page
return Page(title, file, config)
return Link(title, path)

Expand Down