-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Brainstorming on MyST docstrings via sphinx.ext.autodoc #6
Comments
Thanks for opening your first issue here! Engagement like this is essential for open source projects! 🤗 |
Heya, I'd say this is a duplicate of executablebooks/MyST-Parser#228 |
Basically its made non-trivial by sphinx hard coding rST into the autodoc logic: sphinx-doc/sphinx#8018 |
Basically we either need to either "motivate" the sphinx maintainers to change (or allow a change) to their internal autodoc code. |
Definitely like to see it happen though |
@chrisjsewell thanks for helping link things together! Applying rst2myst on myst or a mix of myst/rst isn't goodI 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. |
Current understanding of the challengesphinx.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:
|
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.
The automodule directive will emit rST directives and raw docstrings that also ends up parsed as rST.
Two issues
Here is an example using the
automodule
directly as a MyST directive, and it leads to two issues:Issue 1 - sphinx.ext.autodoc emits rST formatted directives
sphinx.ext.autodoc will emit rST formatted directives even though invoked from a MyST document like:
Issue 2 - sphinx.ext.autodoc has made us write docstrings with rST
A project who has used sphinx.ext.autodoc has needed to write the docstrings in rST rather than MyST historically due to always being parsed with rST.
If we are to support MyST docstrings, I think of one initial key goal, and a stretch goal:
I see the key goal as a very valuable goal resolving my its own, and the stretch goal as valuable but also likely more complicated to implement and use sustainably.
Ideas to address this
I'm not sure if and how to address these issues. I've opened this issue to brainstorm if we can find reasonable resolutions to these issues - especially if we can find a way to support 100% MyST based docstrings via sphinx.ext.autodoc. A solution that is too complicated and hard to maintain isn't worth developing in my mind.
Support directly in sphinx.ext.autodoc?
Maybe sphinx.ext.autodoc could add support for this directly?
Support by wrapping or patching sphinx.ext.autodoc in another sphinx extension?
Maybe a sphinx extension could be created (myst-autodoc), which would patch or influence sphinx.ext.autodoc somehow. Maybe by wrapping/redefining the provided directives and running rst2myst on the old definition, or maybe patching some functions in sphinx.ext.autodoc?
Your ideas?
I opened this issue hoping to overview the situation and find actionable paths towards resolving this in a good way that is sutainable to maintain and use.
The text was updated successfully, but these errors were encountered: