New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
jinja2.exceptions.TemplateNotFound: alias.html #451
Comments
Same error here, any new ideas? |
Ok, could work around this error by NOT using indirect imports (hope this is the correct term) Lets have an example
content of
and in the mkdoc md file i referenced the class as
which provoked the error. when changin the class reference to
the error was gone |
Sorry for the delay and thank you for the workaround. I'll eventually get to this as it's clearly a bug. |
Thanks a lot. i'll try to find some time the next days to setup a simplified project-repo to reproduce the error. |
Ok, looks like my claim was wrong. I could NOT reproduce the error via indirect imports. |
hmmm still happening, I arrived here after checking out #404, no solution for now :( |
The original issue reported by @joaompinto seems to happen because This is shown by the logs, in verbose mode: % mkdocs build -v
DEBUG - Loading configuration file: /media/data/dev/kubekind/mkdocs.yml
DEBUG - Loaded theme configuration for 'material' from '/media/data/dev/kubekind/.venv/lib/python3.11/site-packages/material/mkdocs_theme.yml': {'language': 'en', 'direction': None, 'features': [], 'palette': {'primary': None,
'accent': None}, 'font': {'text': 'Roboto', 'code': 'Roboto Mono'}, 'icon': None, 'favicon': 'assets/images/favicon.png', 'include_search_page': False, 'search_index_only': True, 'static_templates': ['404.html']}
DEBUG - Config value 'config_file_path' = '/media/data/dev/kubekind/mkdocs.yml'
DEBUG - Config value 'site_name' = 'My Docs'
DEBUG - Config value 'nav' = None
DEBUG - Config value 'pages' = None
DEBUG - Config value 'site_url' = None
DEBUG - Config value 'site_description' = None
DEBUG - Config value 'site_author' = None
DEBUG - Config value 'theme' = Theme(name='material', dirs=['/media/data/dev/kubekind/.venv/lib/python3.11/site-packages/material', '/media/data/dev/kubekind/.venv/lib/python3.11/site-packages/mkdocs/templates'],
static_templates=['404.html', 'sitemap.xml'], name='material', locale=Locale(language='en', territory=''), language='en', direction=None, features=[], palette={'primary': None, 'accent': None}, font={'text': 'Roboto', 'code':
'Roboto Mono'}, icon=None, favicon='assets/images/favicon.png', include_search_page=False, search_index_only=True)
DEBUG - Config value 'docs_dir' = '/media/data/dev/kubekind/docs'
DEBUG - Config value 'site_dir' = '/media/data/dev/kubekind/site'
DEBUG - Config value 'copyright' = None
DEBUG - Config value 'google_analytics' = None
DEBUG - Config value 'dev_addr' = _IpAddressValue(host='127.0.0.1', port=8000)
DEBUG - Config value 'use_directory_urls' = True
DEBUG - Config value 'repo_url' = None
DEBUG - Config value 'repo_name' = None
DEBUG - Config value 'edit_uri_template' = None
DEBUG - Config value 'edit_uri' = None
DEBUG - Config value 'extra_css' = []
DEBUG - Config value 'extra_javascript' = []
DEBUG - Config value 'extra_templates' = []
DEBUG - Config value 'markdown_extensions' = ['toc', 'tables', 'fenced_code']
DEBUG - Config value 'mdx_configs' = {}
DEBUG - Config value 'strict' = False
DEBUG - Config value 'remote_branch' = 'gh-pages'
DEBUG - Config value 'remote_name' = 'origin'
DEBUG - Config value 'extra' = {}
DEBUG - Config value 'plugins' = {'search': <material.plugins.search.plugin.SearchPlugin object at 0x7f40421c6a10>, 'mkdocstrings': <mkdocstrings.plugin.MkdocstringsPlugin object at 0x7f4042be9350>}
DEBUG - Config value 'hooks' = {}
DEBUG - Config value 'watch' = []
DEBUG - Running 2 `config` events
DEBUG - mkdocstrings: Adding extension to the list
DEBUG - mkdocstrings: Added a subdued autorefs instance <mkdocs_autorefs.plugin.AutorefsPlugin object at 0x7f4041f96550>
DEBUG - mkdocs_autorefs.plugin: Adding AutorefsExtension to the list
DEBUG - Running 1 `pre_build` events
INFO - Cleaning site directory
INFO - Building documentation to directory: /media/data/dev/kubekind/site
DEBUG - Reading markdown pages.
DEBUG - Reading: index.md
DEBUG - Running 1 `page_markdown` events
DEBUG - mkdocstrings: Matched '::: kubekind.Pod'
DEBUG - mkdocstrings: Using handler 'python'
DEBUG - mkdocstrings: Collecting data
DEBUG - griffe: Found kubekind: loading
DEBUG - griffe: Loading path kubekind/__init__.py
DEBUG - griffe: Loading path kubekind/kind.py
DEBUG - griffe: Loading path kubekind/__main__.py
DEBUG - griffe: Skip kubekind/resources/container.py, it is not importable. Missing __init__ module?
DEBUG - griffe: Skip kubekind/resources/pod.py, it is not importable. Missing __init__ module?
DEBUG - griffe: Skip kubekind/storage/volumemount.py, it is not importable. Missing __init__ module?
DEBUG - griffe: Skip kubekind/storage/emptydir.py, it is not importable. Missing __init__ module?
DEBUG - griffe: Alias resolution error for kubekind.Container -> kubekind.resources.container.Container
DEBUG - griffe: Alias resolution error for kubekind.Pod -> kubekind.resources.pod.Pod
DEBUG - griffe: Iteration 1 finished, 0 aliases resolved, still 2 to go
DEBUG - griffe: Alias resolution error for kubekind.Container -> kubekind.resources.container.Container
DEBUG - griffe: Alias resolution error for kubekind.Pod -> kubekind.resources.pod.Pod
DEBUG - griffe: Iteration 2 finished, 0 aliases resolved, still 2 to go
WARNING - mkdocstrings_handlers: 2 aliases were still unresolved after 2 iterations
DEBUG - mkdocstrings: Updating renderer's env
DEBUG - mkdocstrings: Rendering templates
ERROR - mkdocstrings: Template 'alias.html' not found for 'python' handler and theme 'material'.
ERROR - Error reading page 'index.md': alias.html
Traceback (most recent call last):
... Or running Griffe directly: % griffe dump kubekind -o/dev/null -LDEBUG
INFO Loading package kubekind
DEBUG Found kubekind: loading
DEBUG Loading path kubekind/__init__.py
DEBUG Loading path kubekind/kind.py
DEBUG Loading path kubekind/__main__.py
DEBUG Skip kubekind/resources/container.py, it is not importable. Missing __init__ module?
DEBUG Skip kubekind/resources/pod.py, it is not importable. Missing __init__ module?
DEBUG Skip kubekind/storage/volumemount.py, it is not importable. Missing __init__ module?
DEBUG Skip kubekind/storage/emptydir.py, it is not importable. Missing __init__ module?
INFO Finished loading packages So the easy solution is to add the missing @motey @HacKanCuBa can you confirm the issue is caused by missing |
Hmmm interesting, I do not see that
This line caught my attention:
This is from my open-source project, you can build the docs yourself if needed: https://gitlab.com/hackancuba/blake2signer/
|
Can you try again with Griffe installed from master branch? I've fixed several things, did not get the chance to release yet. |
Interestingly, the log changed a bit, but yet it still throws the warning (or the error when I force it to reference directly the offending file).
|
So, what's the issue? You don't want the |
haha no, that's not the issue. if i want to show docs for the object in question, it crashes instead of giving a warning (see the second part of my prev comment). |
I see, thanks for the explanation! (I'll still change the warning to a debug statement) So, Griffe does not try to load external packages when resolving aliases. If you want to force it to load ::: blake3.some.small.object
options:
shot_root_toc_entry: false
<!-- you can then hide it with something like
<style>.doc-object:has(> #blake3.some.small.object) {display: none;}</style>
--> Obviously, blake3 needs to be installed when building the docs. I'm planning on adding a configuration option to tell Griffe to (pre)load additional modules without having to resort to that workaround 🙂 UPDATE: well, I just tried with |
yes, thanks! |
Yeah you're right, I don't understand right now why the warning is not more often displayed though. Anyway, bad news: blake3 (which is compiled) is lying about the parent module of |
hahaha damn. hmmm, well, the Zen says that no special case is special enough :P |
BTW, thanks so much for this! |
You're welcome! You can also open a new issue with just the link to this comment, this way I don't forget about it 🙂 |
I have bad news: I did a quick test w/ latest |
Meh 😕 OK, thanks for reporting back, I'll continue to investigate as well. |
I wonder if this is because @oconnor663 set the parent to module to |
Or we simply hit the design flaw of Griffe where modules and members of the same name cannot coexist, while this is possible in Python itself. |
Well, it's the former. If we patch the module of the If we don't, Griffe thinks that |
If # Hashers
<div style="display: none;" markdown=1>
::: blake3
options:
members: false
show_root_heading: false
show_root_toc_entry: false
</div>
::: blake2signer.hashers
options:
merge_init_into_class: true
filters: ["!^_"]
|
I'm pretty new to the behavior of
class blake42:
pass
from blake42 import blake42
print(repr(blake42.__module__))
I don't think anyone expects |
See also the pure-C port, which uses Python's C API directly. There we set |
Your toy example is correct, however your code/project has one more layer: blake3/ # <- module == blake3
__init__.py # <- imports blake3 class from compiled blake3 below
blake3.cpython-311-x86_64-linux-gnu.so # <- module == blake3.blake3 Generally, it seems that objects do have the full, canonical path to the module they are defined in as value for >>> from griffe import load_git # indirect import
>>> load_git.__module__
'griffe.git'
>>> from griffe.agents.base import BaseVisitor # direct import
>>> BaseVisitor.__module__
'griffe.agents.base' |
Ah interesting. It looks like that's an implementation detail of the Maturin build tool. I've opened a discussion question about best practices here: PyO3/maturin#1365. Please chime in if you have any thoughts about Maturin/PyO3, or if you can clarify exactly how the |
The Maturin maintainer has asked for repro steps here: PyO3/maturin#1365 (comment). Could someone from this thread add a |
This is a correction of 07c389f, which originally set `__module__` to "blake3". For all the details, see: - mkdocstrings/mkdocstrings#451 - PyO3/maturin#1365 The C implementation is unchanged, so `__module__` is still "blake3" there.
Changes since 0.3.2: - Change `blake3.__module__` from "blake3" to "blake3.blake3". This is the correct canonical path, related to some Maturin implementation details. This is intended to help tooling that relies on canonical paths, but most regular callers don't need to worry about this. See mkdocstrings/mkdocstrings#451 for an example of a tool that needs to know this.
Changes since 0.3.2: - Change `blake3.__module__` from "blake3" to "blake3.blake3". This is the correct canonical path, related to some Maturin implementation details. This is intended to help tooling that relies on canonical paths, but most regular callers don't need to worry about this. See mkdocstrings/mkdocstrings#451 for an example of a tool that needs to know this. - Update PyO3 to v0.17.
Just published |
Seems to be working fine! I'll let @HacKanCuBa confirm 🙂 |
Indeed, it does work when I do something like explained here :D 🥳 It still fails if I use |
As I tried to explain before, The idea is that later, you'll be able to use something like this: # mkdocs.yml
plugins:
- mkdocstrings:
handlers:
python:
preload: [blake3] ...so that you don't have to rely on this hidden div hack 🙂 |
Describe the bug
While running mkdocs build I get an exception:
To Reproduce
Steps to reproduce the behavior:
git clone git@github.com:joaompinto/kubekind.git cd kubekind pip install mkdocs mkdocstrings mkdocstrings[python] mkdocs build
Expected behavior
A clear and concise description of what you expected to happen.
Information (please complete the following information):
The text was updated successfully, but these errors were encountered: