-
Notifications
You must be signed in to change notification settings - Fork 207
SG misses classes that aren't imported #205
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
Comments
API gallery generator should be based on function call not on the import. But we have still to debug it as not all functions are always recognized. Some early issues of this are #70 and #113 and we have not found the time to get to solve them. |
I think that's a fair point - agreed that it's a pretty suboptimal solution to have more comments in the rendered HTML. Maybe better to see what other solutions will come about for catching function calls etc, and then I'll try to figure out ways to solve this problem in the future. I'll close the issue unless any other folks wanna weigh in |
I agree in principle. However in the MNE case we have a lot of classes that get returned by functions and then get used extensively, but are rarely created or imported manually by the user. So for SG to get this right, it would need to do something like parse the docstring (assuming it's e.g. NumPy-formatted) to try to get the return object type. This sounds quite hard to get right...
Right now the code in the example file is used to generate the API pages (by way of the backrefs). The proposal is to also allow some comments to do it, too. I don't see these as being so different, really...? Maybe a compromise would be to parse the non-code for statements in the that contain Sphinx references, like:
Then it's clean RST format, and should/could link nicely? |
I guess a challenge there could be that someone might reference other classes etc that are worth linking but not necessarily worth including in the gallery below. Not sure how common this would be, but if it weren't that common it might be a good compromise. Alternatively I guess there could be a |
I imagine we can work around this. Parse for Python refs, and see if the current module being documented (e.g., |
Oh wait I misinterpreted what you said. I think that would be rare enough not to worry about. -1 on adding a new directive, let's assume YAGNI. We could at least offer the option to disable this behavior entirely. |
Cool - the new directive is an extreme solution I agree |
@Titan-C any comment on this starting here? This is a feature we still miss. |
I agree w/ @Eric89GXL - Matplotlib would also have a huge benefit from improvements along these lines (e.g. SG isn't detecting any of the methods called on |
Uh oh!
There was an error while loading. Please reload this page.
UPDATED:
Right now it seems like methods of classes will only be linked with backrefs if the class is imported somehow (e.g.,
import matplotlib.pyplot as plt; ax = plt.Axes()
would I think properly link to any methods inax
such asax.scatter
).However, sometimes there are objects which have examples in the docs, but are not explicitly imported in those examples. E.g.,
fig, ax = plt.subplots
).How should we handle these cases?
@Eric89GXL has proposed something like this:
The text was updated successfully, but these errors were encountered: