NiklasRosenstein / pydoc-markdown

Create Python API documentation in Markdown format.
http://niklasrosenstein.github.io/pydoc-markdown/
Other
458 stars 102 forks source link

Sphinx type and rtype entry are not processed #157

Closed benjello closed 3 years ago

benjello commented 3 years ago

Thank you for this neat piece of software.

Is there a way to tell the sphinx processor to deal with :type : and :rtype : entries like those presents in here ?

NiklasRosenstein commented 3 years ago

Hey @benjello ,

The right place to handle these entries would be in SphinxProcesssor. How would you have that parameter be rendered as Markdown?

m-birke commented 3 years ago

Hi Niklas,

I just stumbled across this too. I would propose to do it similar to sphinx.

Sphinx docstring style is the following: :param [ParamName]: [ParamDescription](, defaults to [DefaultParamVal]) :type [ParamName]: [ParamType](, optional)

... becomes to

(the ", defaults to ... " is just appended as it is, so this needs no care)

In Markdown you could do just the same, like:

:return: [ReturnDescription] :rtype: [ReturnType]

becomes to

Returns: [ReturnDescription] Return type: [ReturnType]

Like this or just

Returns ([ReturnType]): description...

like

Returns (dict): description...

would be great in my opinion :)

source: https://dev.to/zenulabidin/sphinx-docstring-best-practices-2fca

NiklasRosenstein commented 3 years ago

Hey @suitre77 , I like what you're proposing:

Returns ([ReturnType]): description...

This will just need some work in the SphinxProcessor to understand content from multiple lines and summarize it into a single line. Not sure when I'll get to it, but it's high up on my list.

NiklasRosenstein commented 3 years ago

Heym @suitre77, I made it so that the following docstring:

  :param foo: A foo value
  :type foo: str
  :type bar: int
  :param bar: A bar value
  :returns: Some eggs from foo and bar
  :rtype: str

is rendered as

Arguments:

  • foo (str): A foo value
  • bar (int): A bar value

    Returns:

    str: Some eggs from foo and bar

NiklasRosenstein commented 3 years ago

v3.12.0

m-birke commented 3 years ago

appreciating, thanks :)