-
-
Notifications
You must be signed in to change notification settings - Fork 42
sphinx.ext.automodsumm broken with Sphinx 1.3 #148
Conversation
On Python 2.7 I get this different error:
Is this a recently introduced bug in Sphinx (https://github.com/sphinx-doc/sphinx/blame/548a6dc22e4a3edff76413b6bdeedcf2b8c3f30c/sphinx/setup_command.py#L171) or some weird installation issue on my machine? |
I've seen the latter issue, and it's totally just a bug in Sphinx--nothing astropy-helpers can do about. I know it's been fixed more recently. I just have Sphinx pinned to 1.2.3 for Python 2.7, I think. I'm trying to figure out what could cause the first one though. What does your sphinx conf have for the |
I have the git master version of astropy, which has
So you can't reproduce this issue with Python 3 and it's something specific to my setup? |
I think that, to date, the docs build still hasn't been guaranteed to work fully on Python 3. I'm not 100% sure what the last word on that was though. I always use Python 2 to build the docs. |
Just looking at the code though, the only way I can see to get the exception you're getting is if somewhere |
@cdeil Well in any case it's not just you--I was able to reproduce this on Python 3. It's bizarre though. |
I see: http://sphinx-doc.org/config.html#confval-source_suffix
I guess it automatically converts it to a list. |
However, fixing that issue reveals several more. So I think it's safe to say Sphinx 1.3 isn't support yet. |
(regarding Python 3 support, I think it should actually work, and if not, it was pretty close last time I tried. I guess the question is whether to add a Travis build for it in astropy core to avoid regressions, but then it's an additional build :-/) |
Yes, I think Python 3 should mostly work, but maybe has a few little issues. On Sphinx 1.3 I think it will mostly work too, but there are some minor incompatibilities in the automodsumm extension, and possibly others, that need to be chased down... (hopefully by people who actually understand them which is not me, though I was able to fix a few of them...) |
I've been using |
I agree, with Sphinx 1.2.3 there are no errors/warnings :) |
Good to know--then I guess this really is mostly just a Sphinx version issue. Astropy is still using 1.2.3 so best to stick with that until the other issues are sorted out. |
I'll try to post the fixes I have so far at some point. I just haven't yet because I was trying to get everything fixed (since none of the fixes I had by themselves were of much help to get the thing running). |
Well, the following patch at least gets the damn thing to run without crashing: diff --git a/astropy_helpers/sphinx/ext/automodsumm.py b/astropy_helpers/sphinx/ext/automodsumm.py
index 9a43680..88f2462 100644
--- a/astropy_helpers/sphinx/ext/automodsumm.py
+++ b/astropy_helpers/sphinx/ext/automodsumm.py
@@ -220,10 +220,12 @@ class Automoddiagram(InheritanceDiagram):
#<---------------------automodsumm generation stuff--------------------------->
def process_automodsumm_generation(app):
env = app.builder.env
- ext = app.config.source_suffix
- filestosearch = [x + ext for x in env.found_docs
- if os.path.isfile(env.doc2path(x))]\
+ filestosearch = []
+ for docname in env.found_docs:
+ filename = env.doc2path(docname)
+ if os.path.isfile(filename):
+ filestosearch.append(docname + os.path.splitext(filename)[1])
liness = []
for sfn in filestosearch:
@@ -238,10 +240,11 @@ def process_automodsumm_generation(app):
f.write('\n')
for sfn, lines in zip(filestosearch, liness):
+ suffix = os.path.splitext(sfn)[1]
if len(lines) > 0:
generate_automodsumm_docs(lines, sfn, builder=app.builder,
warn=app.warn, info=app.info,
- suffix=app.config.source_suffix,
+ suffix=suffix,
base_path=app.srcdir)
#_automodsummrex = re.compile(r'^(\s*)\.\. automodsumm::\s*([A-Za-z0-9_.]+)\s*' but then it outputs "WARNING: document isn't included in any toctree" for all the generated API pages. Interestingly, all, or at least most, of the API references seem to work--the links go to the corresponding API pages. But they're rendered in black instead of blue, as though the reference wasn't resolved. |
I think this might have something to do with automodapi not working correctly, though I haven't figured out where it goes wrong. |
Digging a little further, with the fixes I made above (and a couple other minor ones) it doesn't seem there's any difference in what is output by automodsumm or automodapi, but there does seem there may be a problem with how Sphinx is interpreting the resulting directives--possibly changes in how the |
Now I'm tracking another issue--maybe related?--that automodapi seems to get run twice, though the first time it's run on files with the filename extension in the docname (ex. "wcs/index.rst"), and then later a second time with just "wcs/index" without the extension as the docname... Update: I see; that's just because automodsumm calls automodapi directly, but automodapi is also connected to the Sphinx "source-read" event, so it gets called twice on each document. I don't know if that matters or not. |
Aha! This change seems to be at the heart of the toctree generation for API items. The |
I added a comment about this in sphinx-doc/sphinx#1061. |
Okay, I think I've found a workaround for this. It's hacky but gets the job done. |
… from working with objects that are imported into the module being documented, rather than being defined directly in that module. See astropy#148 (comment)
I've converted this to a PR with some related fixes attached. This should get the docs build pretty much working with Sphinx 1.3 (I'm not sure if everything works perfectly but it at least runs and doesn't seem to have any warnings). Maybe after the tests for this run I'll attach a new build configuration to the .travis.yml to test against Sphinx 1.3. |
Thanks @embray for fixing this so quickly! If it works with Sphinx 1.3 on your machine or travis-ci it's probably not necessary, but let me know if you want me to try this branch on my machine. |
One issue it still has is that links to API references are still showing up in black instead of blue. I wonder if that's just something that needs to be tweaked in the stylesheet for the theme. |
@embray – Any chance to get this in soon? |
Hm, well Travis-CI lost its damn mind on that last build, so I'll restart it. It looks like this change might have broken things with Sphinx 1.2.x now though. I'll have to go back and re-tinker. |
@astrofrog Any idea what this is about:
? I think you set this up. The travis builds are losing their mind over it. |
@cdeil I think this is nearly fixed, but I need to find out why the CI builds are going belly up. |
…his fix was needed. This is more of a followup to astropy#130 to catch some more cases where simply calling getattr() on some objects can result in a non-AttributeError exception.
…f full filenames (with extensions). Also fixes related to the fact that the source_suffix option can be a list in Sphinx 1.3 (actually, we avoid using that option altogether here).
… from working with objects that are imported into the module being documented, rather than being defined directly in that module. See astropy#148 (comment)
…ch, and fixes the issue with Sphinx 1.3 and syntax issues using Python 2.
b71004b
to
7ee7e54
Compare
Rebased to force a rebuild, now that #152 is in; hopefully now the build should pass on all platforms. |
sphinx.ext.automodsumm broken with Sphinx 1.3
sphinx.ext.automodsumm broken with Sphinx 1.3
… from working with objects that are imported into the module being documented, rather than being defined directly in that module. See astropy/astropy-helpers#148 (comment)
…-fixes sphinx.ext.automodsumm broken with Sphinx 1.3
… from working with objects that are imported into the module being documented, rather than being defined directly in that module. See astropy/astropy-helpers#148 (comment)
…-fixes sphinx.ext.automodsumm broken with Sphinx 1.3
After updating to Sphinx 1.3 the Sphinx build for Astropy and all affiliated packages doesn't work any more!?
cc @eteq @astrofrog