Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
eymeric-giraux opened this issue Jun 24, 2024 · 6 comments

Comments

@eymeric-giraux
Copy link

eymeric-giraux commented Jun 24, 2024

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
Copy link

sachahu1 commented Jul 1, 2024

@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
"""
"""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
Copy link
Author

eymeric-giraux commented Jul 2, 2024

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
Copy link

sachahu1 commented Jul 2, 2024

@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
Copy link
Author

eymeric-giraux commented Jul 2, 2024

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
Copy link

sachahu1 commented Jul 2, 2024

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
Copy link
Author

eymeric-giraux commented Jul 3, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants