-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
DOC: Fixes absent line numbers on link to classes decorated with set_module #28918
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
DOC: Fixes absent line numbers on link to classes decorated with set_module #28918
Conversation
@melissawm and @ngoldbaum Would you mind reviewing a follow up from #28645? |
doc/source/conf.py
Outdated
fn = relpath(fn, start=dirname(numpy.__file__)) | ||
# This can be removed when removing the decorator set_module. Fix issue #28629 | ||
if hasattr(obj, '_module_source'): | ||
obj = copy(obj) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a no-op:
>>> import copy
>>> class A: ...
...
>>> copy.copy(A) is A
True
and it's the same story with copy.deepcopy
:
>>> copy.deepcopy(A) is A
True
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for pointing that, just got to realize that copy is a little bit subtle.
The intention of the copy was to not introducing any side effect, even while running on the documentation.
Now, the whole thing about changing __module__
is about its side effect and, as discussed previously it was needed downstream.
Since this code is running while generating the docs, do you think we could just recover the original __module__
without further problems?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this code is running while generating the docs, do you think we could just recover the original
__module__
without further problems?
I guess that depends on whether the docs currently (also) use the patched __module__
somewhere, and if so, where/when that happens. Put differently; it shouldn't be a problem if it doesn't also change the documented module paths.
But I'm not very familiar with this doc generation code, so it's probably best if another maintainer could chime in here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As long as the docs build fine and there aren't any other regressions introduced it should be fine. You could try looking at a diff of the docs build before and after applying the change to see what changes.
It looks like there are some new warnings in the docs build - those need to be fixed too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. I will take a look at this and give the feedback here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jorenham and @ngoldbaum.
This is ready for review.
de6f864
to
6ed0ece
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the poly1d
docs now indeed include line numbers in the source code link:
The line numbers are offset because this branch isn't up-to-date with main. Replacing the url and branch with this one, shows that the line numbers are indeed correct: https://github.com/aureliobarbosa/numpy/blob/fix_classes_with_incorrect_line_numbers/numpy/lib/_polynomial_impl.py#L1087-L1457
Thanks @aureliobarbosa! Sorry for taking a little while to get back to this. |
Thanks @ngoldbaum |
PR #28645 was intended to fix issue #28629, which indicated that wrong links were appearing on documentation for classes decorated with set_module. A minor problem appeared on that fix, since line numbers were not assigned to the link on those decorated classes.
This PR fixes this problem by storing the original value of property
__module__
of decorated classes (instead of capturing the property__file__
of the original module).In my opinion the current approach is simpler.