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
Cython: embed signatures in docstrings of Sage library code #17847
Comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Upstream: Reported upstream. No feedback yet. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Branch: u/jdemeyer/ticket/17847 |
Changed branch from u/jdemeyer/ticket/17847 to none |
comment:6
The attached branch mostly works, but there are still issues in In particular, I need help with navigating this maze: def _sage_getsourcelines_name_with_dot(object):
r"""
[...]
AUTHOR:
- Simon King (2011-09)
"""
# First, split the name:
if '.' in object.__name__:
splitted_name = object.__name__.split('.')
elif hasattr(object,'__qualname__'):
splitted_name = object.__qualname__.split('.')
else:
splitted_name = object.__name__
path = object.__module__.split('.')+splitted_name[:-1]
name = splitted_name[-1]
try:
M = __import__(path.pop(0))
except ImportError:
try:
B = object.__base__
if B is None:
raise AttributeError
except AttributeError:
raise IOError("could not get source code")
return sage_getsourcelines(B)
# M should just be the top-most module.
# Hence, normally it is just 'sage'
try:
while path:
M = getattr(M, path.pop(0))
except AttributeError:
try:
B = object.__base__
if B is None:
raise AttributeError
except AttributeError:
raise IOError("could not get source code")
return sage_getsourcelines(B)
lines, base_lineno = sage_getsourcelines(M)
[...] |
Branch: u/jdemeyer/ticket/17847 |
New commits:
|
Commit: |
comment:9
Replying to @jdemeyer:
That's for dynamic classes, hence, it is pure Python, and the embedding in docstrings isn't relevant here. Details: In the category framework we have all these nested dynamic classes which get a name that is formed by the name of a class they will be attribute of. Hence: class Modules(Category):
def __init__(...):
...
class Homset(Homset_generic):
def __init__(...) Hence, you have a class
Hence, you will NOT find the source code of the class by searching the name in the source file. But the name does give you a possibility to find the code, namely by first searching for the source of the class It isn't relevant for Cython classes, since there is a metaclass at work (and you can't have metaclass for Cython classes). It could perhaps be in a cython file, though. |
Dependencies: #17851 |
This comment has been minimized.
This comment has been minimized.
comment:13
Replying to @simon-king-jena:
Apparently it is relevant, since I'm getting doctest failures in this function:
|
comment:14
The |
This comment has been minimized.
This comment has been minimized.
Changed upstream from Reported upstream. No feedback yet. to Fixed upstream, but not in a stable release. |
Changed dependencies from #17851 to none |
Author: Jeroen Demeyer |
Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:
|
comment:18
Rebased and included upstream Cython patch, but it still doesn't work due to the issue with |
comment:19
OK, I'll have a look. Do I need to do "sage -ba" to build it, or is that done automatically because of dependency checking? Best regards, |
comment:96
I couldn't find any difference in behaviour between |
comment:97
What is this for?
|
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:99
Replying to @sagetrac-git:
Thanks, I thought that |
comment:100
Replying to @jdemeyer:
I wanted to test that the init method belongs to typ and is not inherited from a super class. But on second thought, it would perhaps be better to work with inheritance: After all, docstrings are inherited, too. |
comment:101
Replying to @simon-king-jena:
The original rationale was this: The init method may contain embedding information for the class. If it is obtained from the super-class, then the embedding information belongs to a different class and is thus misleading. |
comment:102
Replying to @simon-king-jena:
I don't think this should be changed. |
comment:103
For me, this branch is good to go if you add some comment in the sources about this part:
|
comment:104
Replying to @jdemeyer:
I will do so a bit later, as I have an appointment now. |
comment:105
Hmm, this patch doesn't behave so nicely for some of Python's docs:
This causes
|
comment:106
Replying to @jdemeyer:
Yes. That's because of my attempt to remove the signature. After all, what I have is only a heuristics. How could we improve the heuristics? Special-case I'll finish a commit now. Please wait. |
Changed branch from u/jdemeyer/ticket/17847 to u/SimonKing/ticket/17847 |
Changed branch from u/SimonKing/ticket/17847 to u/jdemeyer/ticket/17847 |
Changed branch from u/jdemeyer/ticket/17847 to u/SimonKing/ticket/17847 |
comment:109
Why has the branch that I just pushed be reverted??? New commits:
|
comment:110
Now it should be ready for review. |
Changed branch from u/SimonKing/ticket/17847 to u/jdemeyer/ticket/17847 |
comment:112
Sorry that I didn't fix that doctest. New commits:
|
Changed branch from u/jdemeyer/ticket/17847 to |
Before:
After:
Upstream bug which will be fixed in Cython 0.23:
Upstream: Fixed upstream, but not in a stable release.
CC: @simon-king-jena
Component: cython
Author: Jeroen Demeyer, Simon King
Branch/Commit:
cc9e9f6
Reviewer: Simon King, Jeroen Demeyer
Issue created by migration from https://trac.sagemath.org/ticket/17847
The text was updated successfully, but these errors were encountered: