spyder-ide / docrepr

Generate rich representations for docstrings
BSD 3-Clause "New" or "Revised" License
26 stars 12 forks source link

Only top level headings are rendered richly #57

Open joelostblom opened 2 years ago

joelostblom commented 2 years ago

I am trying to us docrepr to render docstrings in JupyterLab, but it seems like only top level headings in the docstring are rendered, not other headings, code, etc. This is with the following versions:

# Name                    Version                   Build  Channel
docrepr                   0.2.0              pyh050c7b8_0    conda-forge
jupyterlab                3.3.4              pyhd8ed1ab_0    conda-forge
jupyterlab_pygments       0.2.2              pyhd8ed1ab_0    conda-forge

image

CAM-Gerlach commented 2 years ago

Hmm, I cannot seem to reproduce the issue on docrepr's end, either on the given function (which is included in docrepr's test suite), or in my own tests of the stated problem (nested heading levels).

Multiple tests, both unit tests and visual regression tests in our suite that test docrepr with the same function as above, np.sin—though to note, it does not include the extra sections that were added by the JupyterLab plugin that wraps docrepr, and all of them pass across all three major OSes. You can see the visual regression test output on, e.g. Linux here.

Furthermore, I created an example function with a docstring containing multiple heading levels, and tested it on Windows on both a brand new environment with Python 3.10, Sphinx 5.3.0 and IPython 8.4.0, and the older Python 3.9, Sphinx 4.5.0 and IPython 7.30.1, and neither could reproduce the issue. Here's the minimal example:

from IPython.core.oinspect import Inspector
import docrepr.sphinxify
def test_fn():
    """
    Test test

    Heading L1
    ==========

    Some text

    Heading L2
    ----------

    Some more text
    """
    pass

oinfo = Inspector().info(test_fn)
path = docrepr.sphinxify.rich_repr(oinfo)
print(path)

The output was:

image

Can you reproduce the issue running the above, or another minimal reproducible example using docrepr (rather than JupyterLab)?

Otherwise, unless @martinRenou or the other Quanstack folks have any immediate insights here from the information provided, you might be better off reporting this issue to JupyterLab instead, since they will be able to isolate what's happening on their end, and determine if they can fix it or something needs to be changed on docrepr's side—I wasn't really involved with the work on the JupyterLab side, that was all @martinRenou & co; I just help maintain docrepr.

Thanks!

martinRenou commented 2 years ago

Thanks for the ping, I'll try to find time to look into it.