-
Notifications
You must be signed in to change notification settings - Fork 106
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
Convert sphinx syntax to Markdown #1
Comments
I have this feature implemented in a fork of master at the moment! I'm using this package (and the extra features I've implemented) to compile the documentation my team has within our repository :) It supports I see that you are going through some heavy refactoring of develop at the moment. Will you you be implementing the cross-referencing features for the default preprocessor? |
@jacsmith21 Awesome! You are welcome to create a PR on the master branch, but I definitely want to make sure this lands in develop as well. In develop, I still have to think about a good way of being able to use multiple preprocessors. The Sphinx preprocessor could then be separate from the standard preprocessor and both could be used at the same time. Also in develop, the cross-references will be detected but not actually linked by the preprocessor. Currently the Preprocessor is supposed to generate another special markup for cross-references that can easily be regex-matched by the Indexer. However, I think I will use a nodal document structure in the future to avoid possible clashes with multiple preprocessor recognizing that special cross-reference markup as markup for their own purpose. I won't do any work on cross-references in the current master anymore. |
@NiklasRosenstein Ok perfect I'm excited to merge everything in! I'll put up a PR in a few days once I do some more testing with my codebase. Once you figure out the structure of the new preprocessor, I can adapt my implementation and push some changes to develop. Using multiple formats at the same time would be interesting. We would just have to detect the format of each section and use the appropriate preprocessor. And ok that all makes sense. I'll make the appropriate enhancements to the restructuredText preprocessor when everything is in place! Let me know if there is anything I can help out with in the develop branch, I really like this project :) |
@jacsmith21 In case you are interested, I just applied your implementation to the develop branch in c373b79. This is also just a note to myself of what's still to do. It is not rock-solid yet. The Pydoc-Markdown preprocessor inserts
If the order is
The Sphinx Preprocessor running as second would then see the four One way to work around this is to have a separate Cross-reference parser that runs after Sphinx, but it would work in more scenarios if the preprocessor would just match over multiple Text nodes. |
Yes, the type in the parentheses is intended to be converted into a cross-reference as well. :) |
That will be amazing. So sphinx defines types like this:
Will the |
Yes, that would also be the responsibility of the Sphinx preprocessor. I reckon the |
Yeah, that would make sense. They should each have a consistent output! |
Hi! So what is the current situation on this issue? :) I use PydocMd to build Markdown API reference pages from docstrings (and serve them in a Vuepress site). So it seems to me this feature request (Sphinx syntax -> Markdown) is part of something more general, i.e. can (and should?) PydocMd support conversion from other docstring styles? I'm not entirely sure how the processing pipeline is organized yet, but I believe building "adapters" would, in theory, be possible as other docstring styles (Numpy, Google, reStructuredText) have a lot in common and with the PydocMd format. For example, consider the following docstrings:
def foo(a, b):
"""Foo a and b.
This is a function that computes a foo combination of two integers.
Parameters
-----------
a : int
The integer A.
b : int
The integer B.
Returns
-------
foo : int
Foo combination of ``a`` and ``b``.
""""
def foo(a, b):
"""Foo a and b.
This is a function that computes a foo combination of two integers.
Args:
a (int): The integer A.
b (int): The integer B.
Returns:
int: Foo combination of ``a`` and ``b``.
""""
def foo(a, b):
"""Foo a and b.
This is a function that computes a foo combination of two integers.
:param a: The integer A.
:type a: int
:param b: The integer B.
:type b: int
:return foo: Foo combination of ``a`` and ``b``.
:rtype int All of these would map to this PydocMd version: def foo(a, b):
"""Foo a and b.
This is a function that computes a foo combination of two integers.
# Arguments
a (int): The integer A.
b (int): The integer B.
# Returns
foo (int): Foo combination of `a` and `b`.
"""" In theory that seems possible, but it does look like a lot of work just to make PydocMd a bit more "plug-and-play". There are also probably a lot of edge cases to consider, such as incompatibilities between docstring styles or between a style and the PydocMd format. Anyway, just wanted to add my two cents here. Thanks for the great work on this tool. :) |
Guys, please check out my PR #84 I moved code around a bit and added two new Preprocessors
Looks like |
Hey guys, sorry that I've been mute on this repo in the past months. I'm planning to work more on Pydoc-markdown again. @florimondmanca I like your suggestion, and @vemel thanks for your PR! What |
@NiklasRosenstein Sorry, it is basic preprocessor :) https://github.com/NiklasRosenstein/pydoc-markdown/blob/master/pydocmd/preprocessor.py#L112 - |
Gotcha! It was added in this PR by @paradoxxxzero. Honestly I did not review this PR well enough as I had not noticed that it was not initializing No worries, references will be resolved at render time in Pydoc-markdown 3.x and does not need to be implemented in the preprocessor (it only needs to mark sections of text as a reference). |
Sooo, my suggestion:
|
Hey @vemel, Splitting the I'll keep focusing on 3.x though so it'd be awesome if we could have additions like the Numpy preprocessor on the develop branch 😀 (I'll port your latest additions to 3.x soon and you could take them as a reference for how to implement the Numpy preprocessor?) Thanks for your support! |
@NiklasRosenstein sounds awesome! BTW, feel free to include lazy type annotations support to 3.x #86 should be easy to add and I checked that it is working on a relatively big project with no issues. |
Any progress on this? Handling ":param:" is pretty important. Right now, I don't see any way of preventing parameter lists from flowing into an unreadable paragraph short of adding bullet points. |
Hey @tmbdev you should be able to use the Just closing this issue btw. because, as far as I can see, the original issue was addressed (The Please feel free to comment here if you are having issues to use the RstPreprocessor |
Hey @tmbdev , here's an example
|
It would be nice if Sphinx (reStructure Text) syntax could be converted sot that
:meth:
func_name``would be displayed as code. It must not necessarily link to the function, but it would be nice to have. Also, the:param name: text...
and`:raise ExceptionName: text..` etc. should be handled.Also, some use this kind of syntax:
The text was updated successfully, but these errors were encountered: