Skip to content

Commit

Permalink
Add option to raise error if file is not included in navigation
Browse files Browse the repository at this point in the history
Signed-off-by: Evan Flynn <evan.flynn@apex.ai>
  • Loading branch information
evan-flynn-apexai committed May 9, 2023
1 parent d2bafac commit 46a948a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions mkdocs_literate_nav/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class _PluginConfig:
markdown_extensions = mkdocs.config.config_options.MarkdownExtensions()
tab_length = mkdocs.config.config_options.Type(int, default=4)
explicit = mkdocs.config.config_options.Type(bool, default=False)
raise_if_excluded = mkdocs.config.config_options.Type(bool, default=False)


class LiterateNavPlugin(mkdocs.plugins.BasePlugin):
Expand Down Expand Up @@ -64,6 +65,8 @@ def is_file_in_nav_file(f) -> bool:
):
return True
log.warning(f"File excluded from navigation file: {f.src_uri}")
if self.config["raise_if_excluded"]:
raise ValueError(f"File should be added to navigation file: {f.src_uri}")
return False

self._files = [f for f in files if is_file_in_nav_file(f)]
Expand Down

0 comments on commit 46a948a

Please sign in to comment.