-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
sphinx autodoc for python doesn't show anything :( #2511
Comments
+1 I bumped into the same problem. |
Has anyone managed to solve this? I'm running into the same issue. Everything is building correctly except the API page, on which only the first function on the alphabetically first submodule is visible. Nothing in this thread has helped. I also tried moving all sphinx-apidoc output into an api directory (as some have suggested), this only adds the API structure (i.e., the submodule names, etc.), but still only the single function is visible. In all cases, everything builds correctly locally (e.g., |
In my case, the cause of sphinx autodoc not working is ReadtheDocs doesn't support Python 3.5 (refs #1990). My project uses |
@c-bata RTD supports Python 3.5 now, so you should be able to build your docs. Can you confirm that was your real issue? |
@DominiqueMakowski I think your issue is not related with a bug on RTD but how you are mocking pygame. I tried to build your own repo in a local venv and I got this:
So, I did a quick search on google and I found this other project https://github.com/ntasfi/PyGame-Learning-Environment that uses pygame and autodoc and I checked its I think should research over there. pygame seems to be a non easy library to mock :) On the other hand, it seems the |
@humitos Thanks to support python3.5, my documentation was properly built by sphinx-autodoc :) |
Well first thank you a LOT guys for your help and for digging into my project 😄 So based on @humitos advices I looked into the the other project I added some of their pygame-related lines into my conf.py (line 23, 24 and 27). Now the build fails (which is a good thing I guess 😆 ). Looking at the log, it seems that the problem lies within a particular object (the pygame's surface (a screen window) created at the initialization of the module) that can't be mocked. But still, I've no idea how to bypass this error, as the "screen" object is necessary for the other components to be initialized... 😞 Anyway thanks again! Here's the compilation log's ending: ...
File "/home/docs/checkouts/readthedocs.org/user_builds/neuropsydia/checkouts/latest/neuropsydia/screen.py", line 7, in <module>
screen = pygame.display.set_mode((0,0), pygame.SRCALPHA | pygame.FULLSCREEN | pygame.DOUBLEBUF | pygame.HWSURFACE)
TypeError: unsupported operand type(s) for |: 'Mock' and 'Mock'
Exception occurred:
File "/home/docs/checkouts/readthedocs.org/user_builds/neuropsydia/checkouts/latest/neuropsydia/screen.py", line 7, in <module>
screen = pygame.display.set_mode((0,0), pygame.SRCALPHA | pygame.FULLSCREEN | pygame.DOUBLEBUF | pygame.HWSURFACE)
TypeError: unsupported operand type(s) for |: 'Mock' and 'Mock'
The full traceback has been saved in /tmp/sphinx-err-3my7x3za.log, if you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error message can be provided next time.
A bug report can be filed in the tracker at <https://github.com/sphinx-doc/sphinx/issues>. Thanks! |
@DominiqueMakowski the problem is because the Just a very simple example:
Let me know if you were be able to make it :) |
@humitos I don't really understand, should I create a class in my conf.py, or in my module? Or define the or method within another existing class? thanks! |
@DominiqueMakowski you have to create that class in your But, in your case, I think you could workaround the |
Seeing the same behavior. Only a single module is built. Working with the pygame module, as well. Just hacked up a solution... commenting out all instances of This of course is not a solution for working with webhooks... 😢 ============== So another solution is to create a requirements.txt file to base of project with the contents:
On readthedocs visit Admin>Advanced Settings and select In conf.py add
Now it runs okay. There is no need to comment out Caveat: Running pygame's while-event loop still does not work. That is okay if the program usually runs in
A solution for the test code is to add it into a function that may be called from the shell. Such as |
I've tried to follow your steps as best as I could. I created a requirements.txt file in which I put all the dependencies. Then, I ticked the "install inside a virtualenv" box in the readthedocs settings and provided the requirements.txt file. I added the following lines in the conf.py: import pygame
from pygame.locals import *
sys.modules['pygame'] = mock.Mock()
sys.modules['pygame.constants'] = mock.Mock() But it doesn't work 😢 I looked at the error and it seems related to a wrong numpy version... |
Hi Dominique. Here is the built documentation: http://trumpocalypse.readthedocs.io/en/latest/. It mostly has the exact steps which were used. Also, if it is of any use, here are the current software versions inside the virtualenv: pip_freeze.txt. |
@DominiqueMakowski this is the error that I see in your build
So, you have to pin numpy to that specific version since that's the one required for Or... you can just remove the pinned versions for numpy and scipy. |
@DominiqueMakowski I'm closing this one, please feel free to reopen if you consider necessary. |
Hey,
I have this python package that I'd like to automatically document using Sphinx. I've inserted docstrings in every functions and classes.
I made an account on ReadTheDocs, and did the setup accordingly (i.e., a docs/ dir with a conf.py file). Then, basically, I've tried almost everything: every combination of autodoc::, autofunction::, autoclass::; I tried using the same conf.py file as other packages which documented API (with specific changes made according to my case, of course); but it just doesn't work, the API page remains inexorably empty...
I just can't figure out what I'm doing wrong... 😢
Here's the link of the docs/ dir
Details
Expected Result
Autodoc the module based on the docstrings inserted in every functions
Actual Result
The API page remains empty
The text was updated successfully, but these errors were encountered: