Open consideRatio opened 1 year ago
Thanks for opening your first issue here! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.
If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).
Welcome to the EBP community! :tada:
Heya, I'd say this is a duplicate of https://github.com/executablebooks/MyST-Parser/issues/228
Basically its made non-trivial by sphinx hard coding rST into the autodoc logic: https://github.com/sphinx-doc/sphinx/issues/8018
Basically we either need to either "motivate" the sphinx maintainers to change (or allow a change) to their internal autodoc code. Or find the the "least invasive" (most maintainable) way to override it
Definitely like to see it happen though
@chrisjsewell thanks for helping link things together!
I considered if rst2myst could be applied to MyST without making changes if its actually ending up parsing myst content. If that would be the case, it could be called on anything autodoc emits. I don't think that is possible though, and would at best lead to only few inconsistencies.
Currently, running rst2myst on myst content would lead to something like this.
-1. Make sure you have successfully completed {ref}`contributing/setup`.
+1. Make sure you have successfully completed \{ref}\`contributing/setup\`.
So whatever resolution we come up with, we must avoid ending up with a mix of myst and rST I think. Well, unless the rST is really MYST, wrapped in an eval-rst directive, which makes it really 100% MyST still.
Due to that, I'm thinking you are correct to say that whats needed is a removal of the rST assumptions used in sphinx.ext.autodoc.
sphinx.ext.autodoc doesn't do parsing itself, but constructs rST text involving raw docstrings. This will create a mix of rST and MyST if MyST docstrings are used. Whenever a mix of rST and MyST is created, we can't reasonably disentangle things, so the crux is to avoid that from happening.
To avoid creating a mix of MyST and rST, we can:
@consideRatio want to give this a go https://sphinx-autodoc2.readthedocs.io/en/latest/quickstart.html#using-markdown-myst-docstrings 😄
When converting rST projects to use MyST, directives from sphinx.ext.autodoc's such as
automodule
can cause issues.The sphinx extension sphinx.ext.autodoc provides directives (
automodule
,autoclass
, ...) that emits rST like.. py:module:: kubespawner.utils
and provides the directives with raw docstrings from the referenced Python code.Background
Here is an example of how you would use sphinx.ext.autodoc from a MyST document correctly.