-
Notifications
You must be signed in to change notification settings - Fork 51
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
Better error message when Sphinx extension fails at end of build due to renamed output path #728
Comments
Hello @jgarbers, Thanks for the report, I must admit I'm not really familiar with this part of the code. @adiroiban would you be kind enough to look into fixing this issue? @jgarbers Can you provide a minimal reproducer? What does your patch looks like? Thanks a lot, |
Thanks @tristanlatr ! I'll try to do a minimal reproducer later today. My workaround patch just checks for the existence of the output path before trying to rename it, but as far as I can tell the output path will never exist, so this is just a band-aid in lieu of an actual understanding of the problem. I do have a number of warnings being generated during the pydoctor build process -- lots of docstring formatting errors to fix! -- so that aligns with your observations of failing with I sure appreciate your prompt response - thanks! |
I see that the code is poorly documented... my bad. I see that this was done as part of #330 If I remember correctly this was an egg and chicken problem. You want to build the narrative Sphinx docs to reference pydoctor ... but pydoctor is not built yet... So this is why the extension will try to build pydoctor first in "inventory-only" mode. That is the pydoctor sphinx-inventory is generated, so that sphinx build can refernce API pages... and after that, pydoctor is called again, this time to generate pydoctor HTML files and at this point it has the main sphinx inventory for the narrative pages. Can you do a clean build of pydoctor or sphinx without this extension ? AFAIK, the extension works... this is what it's used for https://pydoctor.readthedocs.io/en/latest/ |
Thanks for jumping in, @adiroiban ! I'm a bit confused about what you're asking, though.
I'm trying to use the extension in my own project, not to build pydoctor or sphinx itself. If I disable the extension, sphinx-build runs successfully on my project with no errors or warnings -- but of course I have no API documentation! Not sure if this answer helps to address your question. Can you clarify what the directory with the ".sphinx_files" suffix is for? Thanks again! |
Another data point: after eliminating all warnings and errors from the pydoctor build (by cleaning up all of my bad docstrings), the problem I originally reported no longer occurs. The "api.sphinx_files" directory now appears in the build. It contains the HTML rendering of the "index.rst" file I included per the "hack" suggested in the extension documentation to have a link from my Sphinx TOC into the pydoctor-generated HTML. I have no idea how or why the errors and warnings could have provoked the original problem, but all seems to be well now. Please don't hesitate to close this issue unless you think it's worth any further investigation. Again thanks all for the code and help! |
I guess that pydoctor build was failing ... so no files were generated...so the sphinx extension didn't had a valid set of pydoctor files to work with. My request was to run I am closing this |
A better error message for this situation would be good. |
I think this statement is simply wrong: until #609 is not fixed, pydoctor simply cannot reference sphinx narrative documentation. So the chicken and egg problem must around something else. (EDIT: It's probably around the creation of the sphinx toctree, the rst file
This should be considered as a bug. Pydoctor almost never crashes, it just report a non-zero exit code too often. So the real problem is that the sphinx extension only works for clean pydoctor builds, which is not normal... |
@jgarbers, Were you using Shpinx's option |
@jgarbers, if you have time to provide reproducer for this issue, it would really appreciated. Thanks. |
After some investigation, it seems that it's more complicated than this. I can have a failing pydoctor run (with invalid links and bad epytext) and still build the sphinx documentation properly. So I really need your reproducer @jgarbers... |
@adiroiban your help would be very appreciated trouble shooting this bug. |
I don't know how to help here. I think that is best to reproduce this over GitHub action. Or put the code into a public repo and try to reproduce. the pydoctor sphinx integration was done on the "quick and dirty" side and only for systems like Read The Docs, where you can't call pydoctor as a separate job. |
@jgarbers any chances you can share a reproducer? |
Hello, @tristanlatr , and sorry for the delay in responding. Not sure how far down I can boil the problem, but I'll see what I can do Monday morning. Been a while since I was dealing with this so it may take a bit to get the context back. Fingers crossed! |
I've just started using pydoctor.sphinx_ext.build_apidocs in my documentation project, replacing Sphinx's autodoc. After adding the extension and pydoctor_args to my conf.py, sphinx-build fails with this error:
Handler <function on_build_finished at 0x1090307c0> for event 'build-finished' threw an exception (exception: [Errno 2] No such file or directory: '/Users/jgarbers3/lab/ev/docs/build/html/api' -> '/Users/jgarbers3/lab/ev/docs/build/html/api.sphinx_files')
My sphinx-build output path is set to "docs/build", and the extension configuration specifies "--html-output={outdir}/api/".
Reviewing the source for the extension, I think I have an idea of why this is failing. At the end of on_builder_inited, the extension renames the output path (here, "docs/build/html/api") to include a .pydoctor_temp suffix. Then, in on_build_finished, the code tries to rename the original output path ("docs/build/html/api") to include a .sphinx_files suffix. However, that path does not exist, since it was renamed to "docs/build/html/api.pydoctor_temp" at the end of the build init event handler, and the exception shown above triggers.
I've patched the extension to work around the error, and as a newcomer to pydoctor it seems likely that I've missed something. But I don't see any other references to what a .sphinx_files directory might be for, so I'm wondering if that rename step might have been left in inadvertently.
I'm using Python 3.11.3, Sphinx 7.0.1 and the pydoctor extension 23.4.1.
Thanks in advance for any guidance anyone can offer!
The text was updated successfully, but these errors were encountered: