readthedocs / sphinx-autoapi

A new approach to API documentation in Sphinx.
https://sphinx-autoapi.readthedocs.io/
MIT License
415 stars 126 forks source link

Autoapi only considers the first line for docstrings starting with a directive #458

Open eymeric-giraux opened 1 week ago

eymeric-giraux commented 1 week ago

So,

.. note:: This is a test is processed correctly in docstrings.

but

.. note::

  This is a test

is not working.

Something else.

.. note::

  This is a test

is working.

sachahu1 commented 1 day ago

@eymeric-giraux I couldn't reproduce your problem. It seems to work fine on my side.

Maybe the following will help:

  1. Indentation matters so having the text indented within the note is important.
    
    """an incorrect note

.. note:: A Note """

```python
"""an correct note

.. note::
   A Note
"""

image

  1. In docstrings you can usually use the Note or Notes "Sections" instead of using rst directly: Numpy docstring format uses Notes: https://numpydoc.readthedocs.io/en/latest/format.html#notes Google docstring format uses Note: https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html

Hope that helps!

eymeric-giraux commented 1 day ago

Thanks @sachahu1 for taking the time... no, this is not related to notes in particular. The problem is there with any directive and has been reproduced by some other people too. I have checked indentation which is fine. In fact, copy pasting the same snippet to an actual rst file is working...

In your example, there is some text a correct note before the .. note:: ... you need to remove it in order to reproduce the issue. In fact, a workaround for this issue is adding an invisible character before the directive, so that the docstring does not start with it...

sachahu1 commented 20 hours ago

@eymeric-giraux I've tried removing the additional text a correct note and it seems to still be working fine on my side, maybe I'm doing something wrong?

def valid_note():
  """
  .. note::
     A Note
  """
  pass

image

Do you mean to have your docstring as:

def valid_note():
  """.. note::
     A Note
  """
  pass

In which case I don't think this is a valid docstring.

eymeric-giraux commented 18 hours ago

no, it seems that it is working fine on your side... I am using sphinx-autoapi 3.0.0 though, the latest one is 3.1.2. I could try updating to the latest version I guess.

sachahu1 commented 8 hours ago

I've tried downgrading to 3.0.0 but it still works on my side... Not sure what's causing the problem on your side, might be worth having a look through your conf.py.

eymeric-giraux commented 35 minutes ago

Ok, now you really have been going the extra mile... thank you so much! From that point, I guess I have to look on my side what might be the issue. I will be updating the outcome here if I can figure it out.