-
|
Hello! I have come to my third and final migration from Sphinx to MkDocs, which I expected to be the simplest of the three. I was, however, quite incorrect. This is shaping up to be the most complicated. The existing documentation makes liberal use of the Sphinx I'm not seeing anything obvious as an equivalent to this available for MkDocs, at least not through
The inelegant, and less-than-ideal answer is to include the content in the Markdown with some kind of identifier that can be used with CSS, and style it manually to make it look like the class documentation. I would prefer to avoid that for a long list of reasons. Thank you for your time! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
|
Hi @kattni!
# scripts/inject_mkdocstrings_data.py
import griffe
import mkdocs_gen_files
python_handler = mkdocs_gen_files.config.plugins["mkdocstrings"].get_handler("python")
with griffe.temporary_visited_package(
"your_package_name".
{
"__init__.py": "# some code in init module",
"your_module.py": "# other modules, etc.",
}
) as package:
python_handler._modules_collection.set_member("your_package_name", package)Tell gen-files to execute it: # mkdocs.yml
plugins:
- gen-files:
scripts:
- scripts/inject_mkdocstrings_data.pyNow in a Markdown page you should be able to inject any object from your package: ::: your_package_name.SomeClassMight be possible to use a hook instead of gen-files, not sure. An alternative would be to write a stubs-only package somewhere in your repo, add its parent directory to mkdocstrings-python's |
Beta Was this translation helpful? Give feedback.
Hi @kattni!