-
-
Notifications
You must be signed in to change notification settings - Fork 161
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
ENH: Xref param type #197
ENH: Xref param type #197
Conversation
@has2k1 can you try my branch and make sure it looks okay on the repo(s) you've tested your branch on? In MNE it took about 100 lines of custom defs to get it working (and a lot of sloppy docstring unifying) without warnings in @jnothman if you are feeling brave, you are welcome to try it for |
Thanks @larsoner.... I think this is something to try outside of the sprint. We've got lots of old issues to resolve this week. |
@larsoner is this still WIP? |
I have some caveats above but it seems to work well for MNE when I use it. The remaining sticking point is that I had to manually provide a bunch of link names, which was annoying. But if that's not a blocker for people then yes it's ready for review/merge. There is a merge conflict so I'll rebase. |
e9e5ba7
to
77cb495
Compare
Perhaps this should wait until @jnothman or someone who knows a bit more about the Also @FHaase I noticed you tried #150 a few months back in pandas-dev/pandas#24098, feel free to try this if you want. |
Sorry it's been a while since I've tried to consider this. What do you mean here? |
Here is an example: in MNE there are objects such as
On this PR, in parameter lists the following would link just fine:
But this will not:
despite the fact that the Instead, the solution I've been using is an alias list numpydoc_xref_aliases, that e.g. converts any You can imagine that building this list would probably be worse for scikit-learn and larger libs than it was for MNE. There is also an ignore list numpydoc_xref_ignore that is necessary if you want to avoid warnings about missing links. I think it would perhaps be better if we didn't warn about these, but this list is much less annoying to construct than many of the the seemingly unnecessary entries in the alias list. |
Part of the problem (maybe all of it?) might have to do with not making use of the Similarly, when documenting e.g.
because the
But they all probably should. Instead, the explicit link I point to above must be supplied:
|
Right, yes, I can imagine that resolution would be very difficult at numpydoc munging time. It's possible @thomasjpfan has ideas about referencing things with respect to the current module. Remind me: What's the problem with always just using the default role (or a specified role) for words not on a blacklist? |
I think the original idea was to avoid warnings about missing/bad links. (I didn't write this bit of code.) It might indeed be simpler to just wrap in backticks, maybe with some default role (maybe configurable). |
77cb495
to
d66246f
Compare
In MNE we still need about 80 lines of class definitions, but I noticed that these are actually the same sorts of definitions that are necessary if you manually put the refs in the docstring, so I think it's probably okay at this point. I think this one is finally ready for review/merge from my end. |
dbcba9b
to
e62ee28
Compare
@larsoner, thank you for picking this up. I will also tryout your updates on my packages. I have been using this feature for the plotnine API documentation for over a year now. |
@larsoner this needs a rebase now |
Tokens of the type description that are determined to be "link-worthy" are enclosed in a new role called `xref_param_type`. This role when when processed adds a `pending_xref` node to the DOM. If these types cross-references are not resolved when the build ends, sphinx does not complain. This forgives errors made when deciding whether tokens are "link-worthy". And provided text from the type description is not lost in the processing, the only unwanted outcome is a type link (due to coincidence) when none was desired.
e62ee28
to
4c9698e
Compare
Rebased and Travis is happy. |
@jnothman are you okay with merging this? |
@jnothman feel free to look at my sklearn branch where I added a commit to get things moving. This is the result for PCA: I can open a WIP PR to sklearn using this branch if you want to see a full build, but figured I'd check with you before doing so since I know sklearn gets tons of PRs. You can also check out my branch and build locally. |
I have updated the demo page to use this PR. +1 on merging. |
As long as it's easy to opt out I'm happy to see this available. I sort of wish it had more reuse of the Sphinx role functionality but that can be a nuisance to customise anyway. Sorry I'm not available to review in detail right now |
For sklearn and packages with a good default role it might be good to allow specifying the role prefix. Right now it's |
Takes over and closes #150 with:
fix rendering bugsRendering bugs were a sphinx issue BUG: numpydoc + autosumarry broken sphinx-doc/sphinx#5959