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

autosummary does not seem to work with autodoc_pydantic #11

Closed
antvig opened this issue Apr 30, 2021 · 9 comments
Closed

autosummary does not seem to work with autodoc_pydantic #11

antvig opened this issue Apr 30, 2021 · 9 comments
Assignees
Labels
bug Something isn't working

Comments

@antvig
Copy link

antvig commented Apr 30, 2021

Hi

First, my doc and I would like to thank you a lot for this great lib !

I face an issue : I'm using autosummary to have a clean doc but using autodoc_pydantic seem not compatible with autosummary

.. currentmodule:: my_module

API Reference
=============

This page gives an overview of all public :mod:`my_module` objects, functions and methods. 

all classes
+++++++++++

.. autosummary::
   :toctree: temp
   :nosignatures:
   :inherited-members:

   ForecastingConfig

the results is

image

While the results before using autodoc_pydantic was :

image

@mansenfranzen
Copy link
Owner

Hi,

thanks for reporting the issue. This is definitely a bug related to autosummary while also using sphinx-autogen. If you use it without sphinx-autogen and :toctree: temp it works for me (sphinx 3.5.4). What sphinx version do you use?

The real issue is located within the autogen part. This seems rather complicated to fix for now. I will get back to it, soon.

@mansenfranzen mansenfranzen self-assigned this Apr 30, 2021
@mansenfranzen mansenfranzen added the bug Something isn't working label Apr 30, 2021
@mansenfranzen
Copy link
Owner

The issue is related to how autosummary parses the autodocumenters via FakeDirective. It assumes that autodocumenters have no configuration parameters read from the app environment. This is the default case for standard autodocumenters but not for autodoc_pydantic. The issue should be fixed with the new dev version 1.1.2_dev (see #13). However, before I merge those changes including tests, please test it locally on your site. To do so, just install the dev version into your documentation build environment via:

pip install git+git://github.com/mansenfranzen/autodoc_pydantic.git@v1.1.2_dev

@antvig
Copy link
Author

antvig commented May 3, 2021

Hi,

Unfortunatly, it's still not working.

I use sphinx==3.5.4, autosummary files are generated with sphinx-build command.

here is the 2 files generated during sphinx-build with and without autodoc_pydantic test.zip`

@mansenfranzen
Copy link
Owner

Thanks for testing. Do you see any difference in the logging output provided by sphinx-build (warnings or error messages) when using it with autodoc_pydantic?

I assume you have autosummary_generate = True in your conf.py, right? The files you've provided are the stub files generated by sphinx-autogen. They are indeed still different because sphinx-autogen only knows about the default autodocumenters. However, the autosummary table that is generated should now contain your ForecastingConfig entry.

Do you have your project on github? This way I could reproduce the bug directly. It works in my local repository.

@antvig
Copy link
Author

antvig commented May 3, 2021

Unfortunatly, it's related to my professional job so I cannot share the repo.

I'll try in the following days to make a short example to reproduce the bug.

@antvig
Copy link
Author

antvig commented May 3, 2021

issue.zip

to reproduce : sphinx-build "source" "build"

@mansenfranzen
Copy link
Owner

Thanks for the example repository - it finally helped me to track down one of the errors you are experiencing 👍.

autosummary - toc - import bug

More concretely, your example imports the relevant pydantic model into the __init__ module and the autosummary directive references the pydantic model from the __init__ module instead from mymodule.core. The imports in autosummary/autodoc are somewhat non trivial - hence such a bug. It is now fixed. The autosummary toc will now show the MyModel.

interoperability autosummary - custom autodocumenters

However, there is a second issue. Namely, autosummary does not integrate well with custom autodocumenter extensions when generating the stub pages (see this issue). I updated the documentation for autosummary usage and included a warning (please take a look here).

final test

To test the newest version, please use the following:

pip install git+git://github.com/mansenfranzen/autodoc_pydantic.git@v1.1.2-a.1

It would be very helpful if you could test it once again on your site.

@antvig
Copy link
Author

antvig commented May 6, 2021

it works like a charm! 👍
Let me know when the patch is released !

@mansenfranzen
Copy link
Owner

Thanks for testing! Patch is released.

Closing this issue via #13.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants