Replies: 1 comment 10 replies
-
Interesting idea, thanks for sharing your thoughts! The code that handles cross-references is located in autorefs (as well as in mkdocstrings itself). However I don't think I'd want to support Sphinx-style cross-references there: both autorefs and mkdocstrings expect Markdown, supporting Sphinx stuff is a non-goal. I'd instead recommend to try writing a Python-Markdown extension that runs a pre-processor on the markup (docstrings) to transform such Sphinx-style references into Markdown inline references. From: :py:class:`SomeClassName` ...to: [`SomeClassName`][] The difficulty here is that by default Sphinx-style references allow relative names while our scoped and relative references are Insiders features, so even with such an extension running, the context provided by the initial references could be insufficient, and you'd have to at least make them absolute in your sources. From: :py:class:`SomeClassName` ...to: :py:class:`package.module.SomeClassName` You'd also have to handle the various features of such directives (I think they allow starting the ref with Happy to try and elaborate if this recommendation isn't enough for you to try and starting hacking on a solution 🙂 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I’m seriously considering mkdocstrings to replace our sphinx-based docs, as we are merging a mkdocs site with a sphinx site, and even if we can use a material theme equivalent for sphinx, they aren’t really integrated together and it shows.
A couple of blockers for us exist, and some of it originates from the griffe backend.
One of the most obvious one is the way links and crossrefs are handled. When using sphinx, you end up using roles with domains like
:py:class:`SomeClassName`
quite often. On a considerable codebase, last year counted at 391000 lines of Python code, changing these references everywhere to adapt to this unique tool would only be a lot of churn, plus making it impossible to go back, or be coherent with the style (sphinx style, but not the expected sphinx syntax as markdown links are used).So, my goal with my exploration this weekend was to familiarize myself a bit with the griffe codebase, in the hope of finding a place where this handling of the sphinx-style (reST) cross references. But I didn’t yet see an appropriate place where the contents of docstrings apply changes to the text (that isn’t for describing paramters and types).
Thus, my question is: where should this be done? What functions are involved. What’s the design that would appropriate for this.
Beta Was this translation helpful? Give feedback.
All reactions