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

KeyError 'refdoc' when missing references #26

Closed
Anntoin opened this issue Oct 26, 2018 · 9 comments
Closed

KeyError 'refdoc' when missing references #26

Anntoin opened this issue Oct 26, 2018 · 9 comments
Labels

Comments

@Anntoin
Copy link

Anntoin commented Oct 26, 2018

I'm seeing the same issue as noted in abakan-zz/ablog#75

Seems to be related to this:

def missing_reference(app, env, node, contnode):

    target = node['reftarget']
    return _missing_reference(app, target, node['refdoc'],
contnode, node['refexplicit'])

https://github.com/sunpy/ablog/blob/master/ablog/post.py#L458

If I change node['refdoc'] to something like node.source it works - I'm not sure if this is correct behaviour however.

Haven't been able to reproduce a minimal example yet, it's just happening in my main env, any pointers appriciated. Using sphinx 1.7.6, ablog 0.9.2

@nabobalis
Copy link
Contributor

Could you provide me a link to your environment if its possible? I will try to see if I can replicate it with the code I have but I can't see any issues with the (small) testing we have enabled on the repo. I plan to add some more in a PR.

@nabobalis nabobalis added the Bug label Oct 27, 2018
@Anntoin
Copy link
Author

Anntoin commented Oct 27, 2018

Unfortunately I can't share my env (work), but have done a little more digging.

What I'm seeing is that revise_pending_xrefs isn't being called when I run a build, so refdoc isn't being set on any nodes. In fact it looks like the doctree-resolved event isn't being emitted at all, so process_postlist isn't called which should call revise_pending_xrefs.

As doctree-resolved is a core sphinx event I'm sure there's something funky up with the version of sphinx I'm using, but it'd be good if the extension handled this gracefully too.

Not sure what the best behaviour would be but should revise_pending_xrefs be handled as part of missing_reference (or a different event?) or just fall back if refdoc isn't found, e.g. to node.source.

@Anntoin
Copy link
Author

Anntoin commented Oct 27, 2018

Actually, looks like the problem is due to event ordering. If I change node['refdoc'] to node.source that allows the build to proceed, so afterwards doctree-resolved is emitted and process_postlist is called.

@nabobalis
Copy link
Contributor

So I should just make that change and that should fix whatever this bug is?

@Anntoin
Copy link
Author

Anntoin commented Oct 28, 2018

Just updating https://github.com/sunpy/ablog/blob/master/ablog/post.py#L459 to
return _missing_reference(app, target, node.get('refdoc'), fixes the immediate issue for me. There's more going on with missing_references and postlists that probably needs looking into at some point - but I'll raise an issue if I spot anything.

@nabobalis
Copy link
Contributor

I've made the change in PR #28, but I also changed the other dictionary index just in case. They probably should be changed in other places. But I will do a release 0.9.3 for now to make this change.

@Anntoin
Copy link
Author

Anntoin commented Oct 28, 2018

Awesome, thanks 👍

@nabobalis
Copy link
Contributor

I just pushed the update to PyPi. Conda will take a while to update.

@Anntoin
Copy link
Author

Anntoin commented Oct 29, 2018

Just to confirm, 0.9.3 is working for me. Getting warnings for missing references but builds succeed. Thanks for the quick turn-around

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

No branches or pull requests

2 participants