-
Notifications
You must be signed in to change notification settings - Fork 197
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
Support use of autodoc with myst #163
Comments
Hey @asmeurer well in principle it would be the same as any other directive:
These directives are a bit tricky though because (again as with every directive) myst should parse the content as Markdown NOT rST. The complications are then:
def func(arg1):
"""
:param arg1: description
:type arg1: type description
:return: return description
:rtype: the return type description
""" I think it would be nice to add the syntax for (2), such that you could write docstrings in Markdown.
Could you elaborate on this |
I'm +1 on both of those ideas - I opened up #164 to track the |
I don't actually care about parameter lists, although I might want support for napoleon headers at some point. But I think you've misunderstood the bug report. This is what I get from
Compared to what I get with recommonmark and eval_rst: https://quansight.github.io/ndindex/api.html#ndindex (the docstrings are currently using rst markup, but that doesn't seem to be an issue yet here)
Like the one example doesn't show that you can put stuff after the By the way, this issue is currently a major blocker for me, since I have API docs that require autodoc, but also a Markdown document that can only be processed with myst. Is it possible to make one file be processed with recommonmark or even just regular Sphinx as a workaround? |
you can always write these pages in rST...hopefully your autodoc pages don't require too much other formatting so it wouldn't be a big deal? |
Ah so if you just have an .rst file that works?
If autodoc worked in myst and I had to reformat my docstrings in Markdown, that would (currently) be fine, as I'm not using any napoleon/numpydoc specific stuff. But the issue for me is that it isn't working at all. |
Yes to clarify, if your file ends in |
Right, just tested that and it is working. So this is no longer a hard blocker for my project. |
The simple example in the table doesn't But then it does point you towards the actual section on directives, which starts with this table:
If you read through, it then explains later: How would you suggest improving this? Because TBH I don't see how this could be clearer, or why it requires any knowledge of how MyST works? |
That's exactly my point. The one thing differs from the other. And it doesn't really state what "content" represents, so I assumed it should be
I suppose it would also help if the table showed the actual rendering of each of the examples.
What are "directive", ""option", "value", "arguments", or "content"? If you are an expert at RST you might know this, but anyone else won't. |
Ah - I think @asmeurer that we do have an assumption that readers already have a decent understanding of rST and Sphinx (our assumption is that MyST users would only be fairly well-versed in rST before considering MyST). Perhaps the |
addressed some of this in #165, would love comments there 👍 |
I'd be really interested in seeing option 2 implemented (markdown docs). |
I saw this solution using the autodoc-process-docstring hook. It gives access to the docs prior to running autodoc, and the solution uses m2r to rewrite markdown to reST for sphinx to process. I was hoping to do the same using MyST for a consistent markdown flavor across pages and docs. However, I don't see a reST writer in MyST, docutils, or sphinx. Am I missing something, or is this a dead end? |
thanks for the link btw @sbliven I think that (eventually) we will be able to do something along the lines of (2), maybe using them hooks. But re-writing to rST would not be an ideal route IMO, since it kinda goes against the "aim" of this package; to translate directly from Markdown to AST |
@chrisjsewell Should that be an autodoc feature request? A hook that replaces the AST generation step? |
Yep quite possibly. You may know better than me, since I haven't had time to look into this in too much detail. But it appears that autodoc is quite strongly coupled to rST, and so anything to loosen this coupling would be welcome |
I asked on the sphinx repo, and it seems like writing docstrings in MyST will to take a large amount of refactoring in autodoc. |
I think the shortest path here is to support something like |
Yeah, |
There's also the question of writing the docstrings themselves in markdown. |
Yep opened a separate issue for that 👍 : #228 |
OK. I did point this issue to a few people for the general support of autodoc, so you may want to add a note about that to the top of the issue here. |
Done 👍 |
@chrisjsewell RE:
Are there plans to support field lists? I'm happy to file a placeholder issue if none exists already (I looked and haven't found one yet). |
#153. However, this is not how auto doc would be natively supported. |
@chrisjsewell I'm actually interested in it from another direction: I want to revisit the Go domain and just target MyST as an intermediate representation. I'm toying around with the right way to represent function / method signatures and field lists seems like a good choice. |
Ok cool, do you want to leave a note on #153, about your exact use case and maybe some example pieces of text. |
Note there is also now https://myst-parser.readthedocs.io/en/latest/using/syntax-optional.html#definition-lists which could be considered |
Docstrings are Google style (rst formatting). Why? - MyST is much more powerful than recommonmark (e.g. table support) - m2r is unmaintained, and the several forks aren't well organized yet. Plus, autodoc support feels like a hack. - MyST doesn't support autodoc either (executablebooks/MyST-Parser#163)
Docstrings are Google style (rst formatting). Why? - MyST is much more powerful than recommonmark (e.g. table support) - m2r is unmaintained, and the several forks aren't well organized yet. Plus, autodoc support feels like a hack. - MyST doesn't support autodoc either (executablebooks/MyST-Parser#163)
Edit:
The implementation of
eval-rst
has now been closed (see this documentation section)However, a new issue has also been opened, specifically for using Markdown in docstrings: #228
I can't figure out how to use autodoc with myst.
With recommonmark, I have something like
or
Based on on the myst docs. I can't figure out what to use to make it work in myst.
(by the way, the example at https://myst-parser.readthedocs.io/en/latest/using/syntax.html#extended-block-tokens, doesn't seem to agree with the example at https://myst-parser.readthedocs.io/en/latest/using/syntax.html#syntax-directives).
After many attempts at the syntax, I finally got something that at least produced some output. But all it seems to do is inline raw rst instead of rendering it.
The text was updated successfully, but these errors were encountered: