sphinx-autodoc2 icon indicating copy to clipboard operation
sphinx-autodoc2 copied to clipboard

0.4.2 MystRenderer renders default values incorrectly

Open johanseland opened this issue 2 years ago • 0 comments

I am using sphinx2-autodoc2 to generate documentation for a Python class like this:


class Foo:
"""This is class foo"""

  bar = 42
  """The bar of foo"""

When running this through Sphinx-autodoc2 it creates Foo.md with the following relevant parts:

````{py:attribute} bar
:canonical: Foo.bar
:value: >
   1

```{autodoc2-docstring} Foo.bar
```
````

Notice the ">" and extra linebreak!

This renders rather ugly: image

What is wanted is more akin to:

image

This is caused by the following from myst_.py: https://github.com/sphinx-extensions2/sphinx-autodoc2/blob/13933a5b25a780e03f227414d432420706962212/src/autodoc2/render/myst_.py#L348-L362

I'm not sure what the intent of the comment: # use > to ensure its understood as a string is supposed to mean.

The rst-renderer is not up to such shenigans:

https://github.com/sphinx-extensions2/sphinx-autodoc2/blob/13933a5b25a780e03f227414d432420706962212/src/autodoc2/render/rst_.py#L314-L326

I can make a PR with a proposed fix, are you still accepting those?

johanseland avatar Jul 18 '23 10:07 johanseland