-
-
Notifications
You must be signed in to change notification settings - Fork 123
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Description of the bug
When trying to document type aliases, the material/type_alias.html.jinja template raises an exception:
jinja2.exceptions.UndefinedError: 'type_alias' is undefined
(see full stack trace below)
To Reproduce
The bug seems to apply to all type alias definitions.
However, here are instructions to replicate it on one of my repos:
conda create --name delphyne-test python=3.12
conda activate delphyne-test
git clone git@github.com:jonathan-laurent/delphyne.git
cd delphyne
git checkout mkdocstrings-type-alias-bug
pip install -e ".[dev]"
mkdocs build
Full traceback
Full traceback
ERROR - Error reading page 'reference/strategies/traces.md': 'type_alias' is undefined
Traceback (most recent call last):
File "/Users/jonathan/Software/miniconda3/envs/delphyne/bin/mkdocs", line 8, in <module>
sys.exit(cli())
^^^^^
File "/Users/jonathan/Software/miniconda3/envs/delphyne/lib/python3.12/site-packages/click/core.py", line 1161, in __call__
return self.main(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jonathan/Software/miniconda3/envs/delphyne/lib/python3.12/site-packages/click/core.py", line 1082, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "/Users/jonathan/Software/miniconda3/envs/delphyne/lib/python3.12/site-packages/click/core.py", line 1697, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jonathan/Software/miniconda3/envs/delphyne/lib/python3.12/site-packages/click/core.py", line 1443, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jonathan/Software/miniconda3/envs/delphyne/lib/python3.12/site-packages/click/core.py", line 788, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jonathan/Software/miniconda3/envs/delphyne/lib/python3.12/site-packages/mkdocs/__main__.py", line 288, in build_command
build.build(cfg, dirty=not clean)
File "/Users/jonathan/Software/miniconda3/envs/delphyne/lib/python3.12/site-packages/mkdocs/commands/build.py", line 310, in build
_populate_page(file.page, config, files, dirty)
File "/Users/jonathan/Software/miniconda3/envs/delphyne/lib/python3.12/site-packages/mkdocs/commands/build.py", line 167, in _populate_page
page.render(config, files)
File "/Users/jonathan/Software/miniconda3/envs/delphyne/lib/python3.12/site-packages/mkdocs/structure/pages.py", line 285, in render
self.content = md.convert(self.markdown)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jonathan/Software/miniconda3/envs/delphyne/lib/python3.12/site-packages/markdown/core.py", line 357, in convert
root = self.parser.parseDocument(self.lines).getroot()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jonathan/Software/miniconda3/envs/delphyne/lib/python3.12/site-packages/markdown/blockparser.py", line 117, in parseDocument
self.parseChunk(self.root, '\n'.join(lines))
File "/Users/jonathan/Software/miniconda3/envs/delphyne/lib/python3.12/site-packages/markdown/blockparser.py", line 136, in parseChunk
self.parseBlocks(parent, text.split('\n\n'))
File "/Users/jonathan/Software/miniconda3/envs/delphyne/lib/python3.12/site-packages/markdown/blockparser.py", line 158, in parseBlocks
if processor.run(parent, blocks) is not False:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jonathan/Software/miniconda3/envs/delphyne/lib/python3.12/site-packages/mkdocstrings/_internal/extension.py", line 128, in run
html, handler, data = self._process_block(identifier, block, heading_level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jonathan/Software/miniconda3/envs/delphyne/lib/python3.12/site-packages/mkdocstrings/_internal/extension.py", line 207, in _process_block
rendered = render(data, options)
^^^^^^^^^^^^^^^^^^^^^
File "/Users/jonathan/Software/miniconda3/envs/delphyne/lib/python3.12/site-packages/mkdocstrings_handlers/python/_internal/handler.py", line 295, in render
return template.render(
^^^^^^^^^^^^^^^^
File "/Users/jonathan/Software/miniconda3/envs/delphyne/lib/python3.12/site-packages/jinja2/environment.py", line 1295, in render
self.environment.handle_exception()
File "/Users/jonathan/Software/miniconda3/envs/delphyne/lib/python3.12/site-packages/jinja2/environment.py", line 942, in handle_exception
raise rewrite_traceback_stack(source=source)
File "/Users/jonathan/Software/miniconda3/envs/delphyne/lib/python3.12/site-packages/mkdocstrings_handlers/python/templates/material/type_alias.html.jinja", line 1, in top-level template code
{% extends "_base/type_alias.html.jinja" %}
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jonathan/Software/miniconda3/envs/delphyne/lib/python3.12/site-packages/mkdocstrings_handlers/python/templates/material/_base/type_alias.html.jinja", line 12, in top-level template code
{% block logs scoped %}
^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jonathan/Software/miniconda3/envs/delphyne/lib/python3.12/site-packages/mkdocstrings_handlers/python/templates/material/_base/type_alias.html.jinja", line 17, in block 'logs'
{{ log.debug("Rendering " + type_alias.path) }}
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jonathan/Software/miniconda3/envs/delphyne/lib/python3.12/site-packages/jinja2/environment.py", line 490, in getattr
return getattr(obj, attribute)
^^^^^^^^^^^^^^^^^^^^^^^
jinja2.exceptions.UndefinedError: 'type_alias' is undefinedEnvironment information
python -m mkdocstrings._internal.debug # | xclip -selection clipboard- System: macOS-14.5-arm64-arm-64bit
- Python: cpython 3.12.8 (/Users/jonathan/Software/miniconda3/envs/delphyne/bin/python)
- Environment variables:
- Installed packages:
mkdocstringsv0.30.0
mkdocstrings-python version: 1.18.1
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working