-
I wasn’t quite sure if this should be implemented in mkdocstrings, autorefs, or griffe. I have a project that uses a simple convention for referencing other classes/functions/attributes: Example:
Is there a way for me to hook a function to replace: `ClassName.fn` with [fn][long_prefix.ClassName.fn]
or
`ClassName` with [ClassName][long_prefix.ClassName] Before mkdocs/autorefs converts it into a link? For now I’ll run a pre-processing script on the throw-away branch before running mkdocs serve/gh-deploy. I think this allows a simpler and flexible solution to others desire for automatic links (See Also section), and/or relative link handling… without having to adding a bunch of markdown to the source-code. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 10 replies
-
You could pre-process docstrings with a Griffe extension. See the docs: https://mkdocstrings.github.io/griffe/extensions/. |
Beta Was this translation helpful? Give feedback.
-
I opened a small issue/pr in the griffe branch to handle |
Beta Was this translation helpful? Give feedback.
You could pre-process docstrings with a Griffe extension. See the docs: https://mkdocstrings.github.io/griffe/extensions/.
Running a regex-replace on the docstring could do the trick, though it would be your responsibility to find out the complete path of the object. That seems doable given you'll know the parents of the object being pre-processed.