Skip to content

Commit

Permalink
Raise error instead of warning when order of plugin is defined wrongly,
Browse files Browse the repository at this point in the history
closes #25
  • Loading branch information
timvink committed May 26, 2021
1 parent c53f264 commit 7278d26
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
3 changes: 2 additions & 1 deletion mkdocs_enumerate_headings_plugin/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from collections import OrderedDict
from mkdocs.config import config_options
from mkdocs.plugins import BasePlugin
from mkdocs.exceptions import ConfigurationError
from mkdocs_enumerate_headings_plugin.html_page import HTMLPage
from bs4 import BeautifulSoup

Expand Down Expand Up @@ -46,7 +47,7 @@ def on_config(self, config, **kwargs):
def check_position(plugin, plugins):
if plugin in plugins:
if plugins.index("enumerate-headings") < plugins.index(plugin):
logger.warning(
raise ConfigurationError(
"[enumerate-headings-plugin] enumerate-headings should be defined after the %s plugin in your mkdocs.yml file"
% plugin
)
Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures/projects/material/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ theme:
# Plugins
plugins:
- search
- enumerate-headings
- awesome-pages:
filename: .pages
collapse_single_pages: false
strict: false
strict: false
- enumerate-headings
8 changes: 1 addition & 7 deletions tests/test_builds.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,13 +253,7 @@ def test_compatibility_awesomepages_plugin2(tmp_path, caplog):
"tests/fixtures/projects/awesome_pages/mkdocs_enum_first.yml", tmp_path
)
result = build_docs_setup(tmp_proj)
assert result.exit_code == 0, "'mkdocs build' command failed"

# Make sure warning is raised
assert (
"[enumerate-headings-plugin] enumerate-headings should be defined after"
in result.output
)
assert result.exit_code == 1, "'mkdocs build' command failed"


def test_compatibility_material(tmp_path):
Expand Down

0 comments on commit 7278d26

Please sign in to comment.