numpydoc icon indicating copy to clipboard operation
numpydoc copied to clipboard

"Unknown section" error because of something in a Literal block

Open KendrickLamarck opened this issue 2 years ago • 1 comments

I have the following docstring:

Returns the quadric with matrix ::

     I |
    ---+-----
       | 0 1
       | 1 0

Returns
-------
Quadric

Building this, I get the warning Unknown section I | in the docstring of.... The html looks like this:

Screenshot 2022-06-23 at 15 14 38

So clearly something is wrong there too.

I've found two workarounds: Either add a character to the end of the first line of the block, as in

 I |.
---+-----
   | 0 1
   | 1 0

or remove the leading space from the first line, as in

I  |
---+-----
   | 0 1
   | 1 0

Tested with sphinx 5.0.2, numpydoc 1.4.0.

KendrickLamarck avatar Jun 23 '22 13:06 KendrickLamarck

I recently ran into the same issue. I had something like this:

    Examples
    --------

    [...]

    The transfer function is::

        2s^2 + 3s + 4
        -------------
        5s^2 + 6s + 1

I got the same error reported above because of the dashed line used in the transfer function. It seems this might be fixable by only considering dashed lines that begin with four spaces as markup for a section heading, but I don't know if this would be easy to implement.

(I worked around my problem by writing the transfer function inline--I didn't really need to have it separated in a literal block.)

WarrenWeckesser avatar Aug 25 '22 00:08 WarrenWeckesser