My docstrings contain links. I want to make these links clickable in IDE, but I want to use the https://github.com/mkdocstrings/python to generate mkdocs api reference.
I want to use this package, because the rest of my documentation is in markdown and thus generated using mkdocs too, and it’s easier to tweak it than to merge mkdocs with e.g. sphinx.
I know there are 3 python docstring formats the mkdocs can process: https://mkdocstrings.github.io/griffe/docstrings/
google, numpy and sphinx. I went through the documentation of individual formats:
- https://sphinx-rtd-tutorial.readthedocs.io/en/latest/docstrings.html#the-sphinx-docstring-format
- https://numpydoc.readthedocs.io/en/latest/format.html
- https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html
but did not find the satisfying answer:
I have tried to put the following links to my docstring:
def foo():
"""
link1
`Example <http://www.example.com>`_
link2
`Example <http://www.example.com>`
link3
<http://www.example.com>
link4
_Example: http://www.example.com
link5
_`Example <http://www.example.com>`_
link 6
http://www.example.com
link7
[example](http://www.example.com)
link8
<a href="http://www.example.com">example</a>
"""
which renders the following result in the doc visualization in PyCharm:
then I used
::: my_package_name
for the api reference, and the following mkdocs.yaml
is:
plugins:
- search
- mkdocstrings:
default_handler: python
handlers:
python:
paths: [src]
options:
allow_inspection: true
show_submodules: true
but the rendered html looked like this:
so there is no single format that would be rendered in the same way in both mkdocstring and the native documentation rendering.
Is there any how how to achieve it, or do I need to write my own mkdocs preprocessor?