Repository navigation
Closed
Description
Describe the bug
Explicitly listing members, but their documentation is not being shown (and code which I'm executing using markdown-exec is not being shown).
Expected behavior
Expect the members to show up in the documentation.
System (please complete the following information):
"mkdocstrings-python @ git+https://github.com/pawamoy-insiders/mkdocstrings-python.git@1.5.0.1.2.0"
- Python: 3.11.3
- OS: Reproduced this for my documentation on Ubuntu, as well as MacOS.
Additional context
Here's my mkdocstrings settings from my mkdocs.yml:
- mkdocstrings:
enabled: !ENV [ENABLE_MKDOCSTRINGS, true]
custom_templates: templates
default_handler: python
handlers:
python:
options:
show_source: true
show_root_heading: true
show_root_full_path: false
show_symbol_type_heading: true
show_symbol_type_toc: true
Here's a log when I serve the documentation:
nox > python -m pip install --constraint=.nox/docs-serve/tmp/requirements.txt mkdocs
nox > python -m pip install --constraint=.nox/docs-serve/tmp/requirements.txt 'mkdocs-material @ git+https://github.com/probcomp/mkdocs-material-insiders'
nox > python -m pip install --constraint=.nox/docs-serve/tmp/requirements.txt 'mkdocstrings-python @ git+https://github.com/pawamoy-insiders/mkdocstrings-python.git@1.5.0.1.2.0'
nox > mkdocs serve
INFO - DeprecationWarning: warning_filter doesn't do anything since MkDocs 1.2 and will be
removed soon. All messages on the `mkdocs` logger get counted automatically.
File
"/home/femtomc/Research/genjax/.nox/docs-serve/lib/python3.11/site-packages/mkdocstrings/loggers.py",
line 9, in <module>
from mkdocs.utils import warning_filter
File
"/home/femtomc/Research/genjax/.nox/docs-serve/lib/python3.11/site-packages/mkdocs/utils/__init__.py",
line 453, in __getattr__
warnings.warn(
INFO - Building documentation...
INFO - Cleaning site directory
INFO - The following pages exist in the docs directory, but are not included in the "nav"
configuration:
- index.md
- homepage.md
- genjax/diff_jl.md
- genjax/language_aperitifs.md
- genjax/concepts/generative_functions.md
- genjax/library/diff_prog/index.md
- genjax/library/diff_prog/adev.md
- genjax/library/diff_prog/state.md
- genjax/library/generative_functions/distributions/coryx.md
- genjax/library/generative_functions/distributions/gensp.md
- genjax/library/inference/index.md
- genjax/library/inference/is.md
INFO - Doc file 'index.md' contains an absolute link '/genjax/notebooks/index.html', it was
left as is.
INFO - Doc file 'genjax/notebooks.md' contains an absolute link
'/genjax/notebooks/index.html', it was left as is.
INFO - DeprecationWarning: invalid escape sequence '\s'
File
"/home/femtomc/Research/genjax/.nox/docs-serve/lib/python3.11/site-packages/griffe/agents/visitor.py",
line 177, in get_module
top_node = compile(self.code, mode="exec", filename=str(self.filepath),
flags=ast.PyCF_ONLY_AST, optimize=1)
File "/home/femtomc/Research/genjax/src/genjax/_src/core/datatypes/generative.py",
line 1110, in
"""> Given a `key: PRNGKey` and arguments `x: Tuple`, the generative
INFO - DeprecationWarning: invalid escape sequence '\l'
File
"/home/femtomc/Research/genjax/.nox/docs-serve/lib/python3.11/site-packages/griffe/agents/visitor.py",
line 177, in get_module
top_node = compile(self.code, mode="exec", filename=str(self.filepath),
flags=ast.PyCF_ONLY_AST, optimize=1)
File "/home/femtomc/Research/genjax/src/genjax/_src/core/datatypes/generative.py",
line 1227, in
"""> Given a `key: PRNGKey`, a choice map indicating constraints ($u$),
INFO - DeprecationWarning: invalid escape sequence '\l'
File
"/home/femtomc/Research/genjax/.nox/docs-serve/lib/python3.11/site-packages/griffe/agents/visitor.py",
line 177, in get_module
top_node = compile(self.code, mode="exec", filename=str(self.filepath),
flags=ast.PyCF_ONLY_AST, optimize=1)
File "/home/femtomc/Research/genjax/src/genjax/_src/core/datatypes/generative.py",
line 1266, in
"""> Given a `key: PRNGKey`, a complete choice map indicating
WARNING:jax._src.xla_bridge:No GPU/TPU found, falling back to CPU. (Set TF_CPP_MIN_LOG_LEVEL=0 and rerun for more info.)
INFO - Documentation built in 3.77 seconds
Metadata
Metadata
Assignees
Labels
No labels

Activity
[-]Explicitly listed members not shown[/-][+]Explicitly listed members not rendered into documentation[/+]femtomc commentedon Aug 25, 2023
I've found the issue -- in my documentation
*.mdsource, I'm referring to an aliased version of these data structures out of another module.Seemingly, this is causing an issue for resolution for
griffe? And perhaps this is already issue'd elsewhere (I just missed this).femtomc commentedon Aug 25, 2023
The above strikes me as weird...
Seemingly,

griffegets to the source (here's another example):So e.g. it resolves the alias to get the source code -- but
mkdocstringsis having issues. If I explicitly change the documentation to refer to the "inner" module (e.g. in my project, code which I'm hiding under a_srcdirectory) -- it works again.[-]Explicitly listed members not rendered into documentation[/-][+]If class is aliased out of a module, explicitly listed members not rendered into documentation[/+]femtomc commentedon Aug 25, 2023
@pawamoy Btw, I swear this might be from a recent commit -- because I was successfully building and showing members from aliased (out of a module) names yesterday morning 😄
pawamoy commentedon Aug 25, 2023
Hi @femtomc, thanks for the report! I'll investigate with what you gave me and come back to you if I need more info 🙂
femtomc commentedon Aug 25, 2023
Is this perhaps a recent change? https://mkdocstrings.github.io/griffe/reference/griffe/?h=public#griffe.Attribute.is_public
My best guess as to what I missed.
Edit: testing now.
pawamoy commentedon Aug 25, 2023
You're right, that highly possible. Just after our email exchange, I released mkdocstrings-python Insiders 1.5.1.1.3.0, you could try with that version, I think it will fix your issue.
The explanation is: Griffe 0.35 returns members of aliases as aliases themselves. Previously the actual, resolved members were returned. This change was needed to preserve the path (the alias path, not the canonical one) of alias members. And an update was needed in mkdocstrings-python to support that.
femtomc commentedon Aug 25, 2023
Okay will try! One moment, thanks!
femtomc commentedon Aug 25, 2023
@pawamoy Should I set my inner (original) dataclasses
.publicattribute toTrue?Ah, I see -- so my dataclasses should automatically be public if I export them via
__all__. I think I'm doing this correctly, will add more to issue if the above change doesn't fix.pawamoy commentedon Aug 25, 2023
If you refer to what is described in
Attribute.is_public, quoting:...then no, by "object" here we refer to the Griffe object (Module/Class/Function/Attribute), not the actual object that is represented (your dataclass).
The
publicattribute (which by the way is undocumented I realize, will fix) is only meant to "force" an object to be considered public, and is only meant to be used by Griffe extensions, for example to support decorators that mark an object as public.Yes! If you declare
__all__, it is used to know if something is public. When it's not declared, Griffe falls back on additional logic. Note that mkdocstrings-python does not yet only use__all__when it is declared. We plan on adding an option to do just that, i.e. pick up members to render from__all__directly, without guessing the public ones.femtomc commentedon Aug 25, 2023
I think either (a) something might still be wrong or (b) I'm misunderstanding how to document:
Here, in
GenerativeFunction-- I actually define the members and documentation which are showing up inJAXGenerativeFunctionIn the markdown source:
Both are exported via an
__all__together -- although there is one final toplevel module whichfrom .reference_module import *which exports the full public API.pawamoy commentedon Aug 25, 2023
Thanks for the update. Is your repo public? Otherwise I'll run some tests with dummy code 👍
femtomc commentedon Aug 25, 2023
@pawamoy It is not public, but I could invite you if you want to do tests with it locally.
I have to run now to do some errands, but let me know if that will help! Very easy for me to do.
pawamoy commentedon Aug 25, 2023
If that poses no issue to you or your peers/company, then sure, a temporary invitation is perfect 🙂
femtomc commentedon Aug 25, 2023
That's fine! If you want to interact with me about the repo, let's do so via an issue which you start at the repo itself :) thanks!
fix: Regression in children template: fix condition for when members …
pawamoy commentedon Aug 25, 2023
This was a regression in the
children.htmltemplate. The conditions that checked whether members were specified or the object was public were wrongly written. This is fixed in mkdocstrings-python 1.5.2 and Insiders 1.5.2.1.3.0. Sorry for the trouble, and thanks for the report, and for your patience!fix: Regression in children template: fix condition for when members …