oprypin / mkdocs-section-index

MkDocs plugin to allow clickable sections that lead to an index page
https://oprypin.github.io/mkdocs-section-index
MIT License
77 stars 8 forks source link

Material MkDocs crashes if both mkdocs-section-index and mkdocs-static-i18n plugins are used during running mkdocs serve #15

Closed Andygol closed 11 months ago

Andygol commented 1 year ago

Description

When using Material MkDocs theme in combination with both the mkdocs-section-index and mkdocs-static-i18n plugins during running the server using mkdocs serve, Material MkDocs theme crashes and displays an error message.

Steps to Reproduce

  1. Install Material MkDocs theme, mkdocs-section-index plugin, and mkdocs-static-i18n plugin via pip. Here is a list of currently installed pacages:
mkdocs                     1.4.2
mkdocs-ezlinks-plugin      0.1.14
mkdocs-material            9.1.5
mkdocs-material-extensions 1.1.1
mkdocs-section-index       0.3.5
mkdocs-static-i18n         0.56
  1. Create a new MkDocs project and add the following to your mkdocs.yml configuration file:
mkdocs.yml ``` site_name: My Docs nav: - Main: index.md - Second: second.md - Third: - /third/index.md - Sub1: third/sub1.md - Sub2: third/sub2.md - Forth: forth.md extra: alternate: - name: English link: en/ lang: en - name: Français link: fr/ lang: fr theme: name: material palette: scheme: slate features: - navigation.tabs - navigation.tabs.sticky markdown_extensions: - attr_list - toc: permalink: ⚓︎ slugify: !!python/object/apply:pymdownx.slugs.slugify kwds: case: none plugins: - search - ezlinks - section-index - i18n: default_language: en docs_structure: folder languages: en: name: English fr: name: Français nav_translations: en: fr: ```
  1. Create next structure of dirs and files
The scaffold of the site structure ``` . ├── docs │ ├── en │ │ ├── forth.md │ │ ├── index.md │ │ ├── second.md │ │ └── third │ │ ├── index.md │ │ ├── sub1.md │ │ └── sub2.md │ └── fr │ ├── forth.md │ ├── index.md │ ├── second.md │ └── third │ ├── index.md │ ├── sub1.md │ └── sub2.md └── mkdocs.yml 6 directories, 13 files ```
  1. Start the development server by running mkdocs serve
  2. Observe the error message displayed in the terminal
Crash log ```log INFO - Building en documentation Traceback (most recent call last): File "/Users/ahm/Documents/github/mkdocs-test/venv/bin/mkdocs", line 8, in sys.exit(cli()) ^^^^^ File "/Users/ahm/Documents/github/mkdocs-test/venv/lib/python3.11/site-packages/click/core.py", line 1130, in __call__ return self.main(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/ahm/Documents/github/mkdocs-test/venv/lib/python3.11/site-packages/click/core.py", line 1055, in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ File "/Users/ahm/Documents/github/mkdocs-test/venv/lib/python3.11/site-packages/click/core.py", line 1657, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/ahm/Documents/github/mkdocs-test/venv/lib/python3.11/site-packages/click/core.py", line 1404, in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/ahm/Documents/github/mkdocs-test/venv/lib/python3.11/site-packages/click/core.py", line 760, in invoke return __callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/ahm/Documents/github/mkdocs-test/venv/lib/python3.11/site-packages/mkdocs/__main__.py", line 234, in serve_command serve.serve(dev_addr=dev_addr, livereload=livereload, watch=watch, **kwargs) File "/Users/ahm/Documents/github/mkdocs-test/venv/lib/python3.11/site-packages/mkdocs/commands/serve.py", line 116, in serve server.serve() File "/Users/ahm/Documents/github/mkdocs-test/venv/lib/python3.11/site-packages/mkdocs/livereload/__init__.py", line 162, in serve self._build_loop() File "/Users/ahm/Documents/github/mkdocs-test/venv/lib/python3.11/site-packages/mkdocs/livereload/__init__.py", line 184, in _build_loop func() File "/Users/ahm/Documents/github/mkdocs-test/venv/lib/python3.11/site-packages/mkdocs/commands/serve.py", line 76, in builder build(config, live_server=live_server, dirty=dirty) File "/Users/ahm/Documents/github/mkdocs-test/venv/lib/python3.11/site-packages/mkdocs/commands/build.py", line 332, in build config.plugins.run_event('post_build', config=config) File "/Users/ahm/Documents/github/mkdocs-test/venv/lib/python3.11/site-packages/mkdocs/plugins.py", line 522, in run_event result = method(**kwargs) ^^^^^^^^^^^^^^^^ File "/Users/ahm/Documents/github/mkdocs-test/venv/lib/python3.11/site-packages/mkdocs_static_i18n/plugin.py", line 604, in on_post_build files.add_files_from_theme(env, config) File "/Users/ahm/Documents/github/mkdocs-test/venv/lib/python3.11/site-packages/mkdocs/structure/files.py", line 122, in add_files_from_theme for path in env.list_templates(filter_func=filter): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/ahm/Documents/github/mkdocs-test/venv/lib/python3.11/site-packages/jinja2/environment.py", line 914, in list_templates names = self.loader.list_templates() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/ahm/Documents/github/mkdocs-test/venv/lib/python3.11/site-packages/jinja2/loaders.py", line 105, in list_templates raise TypeError("this loader cannot iterate over all templates") TypeError: this loader cannot iterate over all templates ```

Expected Results

The MkDocs site should load successfully, and the mkdocs-section-index and mkdocs-static-i18n plugins should function as expected.

Actual Results

The Material MkDocs theme crashes and displays an error message.

Andygol commented 11 months ago

The issue is no longer reproducible with newer versions of mkdocs-section-index == 0.3.8 and mkdocs-static-i18n == 1.1.0.