-
-
Notifications
You must be signed in to change notification settings - Fork 481
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
Annoying warnings when building the HTML reference manual #8244
Comments
Attachment: refbuild.log HTML reference manual docbuild warnings for 4.3.3.alpha0. Not a patch. |
comment:1
Should we follow #6419 for the nested classes? We could use that approach for
|
comment:2
I've looked at these a bit, but I have no idea how to fix them. Oh, except for
This is because
and so splitting at commas doesn't work. To do this right, we either need to write a good parser (which deals with nested lists, tuples, etc.), or perhaps change the whole way we deal with argspecs for Cython functions; for example, just read off the entire string of all the arguments and pass that to the appropriate function, instead of trying to break it into arguments, default values, etc. This is a pretty rare problem and it looks annoying to deal with, so I haven't felt like putting any time into it. mhansen and craigcitro: any comments or ideas? |
comment:3
Ticket #8243 is a duplicate of this one. |
comment:4
Well, Cython itself has to parse such a thing, but I don't know how easy it is go get the data we need out of Cython. Maybe Robert might have an idea? |
comment:5
I'm not very familiar with ASTs (or ast), but with import ast
import inspect
import sage.misc.sageinspect as sms
class SageVisitor(ast.NodeVisitor):
def visit_Name(self, node):
what = node.id
if what == 'None':
return None
elif what == 'True':
return True
elif what == 'False':
return False
return node.id
def visit_Num(self, node):
return node.n
def visit_Str(self, node):
return node.s
def visit_List(self, node):
t = []
for n in node.elts:
t.append(self.visit(n))
return t
def visit_Tuple(self, node):
t = []
for n in node.elts:
t.append(self.visit(n))
return tuple(t)
def visit_Dict(self, node):
d = {}
for k, v in zip(node.keys, node.values):
d[self.visit(k)] = self.visit(v)
return d
def getargspec_via_ast(source):
if not isinstance(source, basestring):
source = sms.sage_getsource(source)
ast_args = ast.parse(source.lstrip()).body[0].args
args = []
defaults = []
for a in ast_args.args:
args.append(SageVisitor().visit(a))
for d in ast_args.defaults:
defaults.append(SageVisitor().visit(d))
return inspect.ArgSpec(args, ast_args.vararg, ast_args.kwarg,
tuple(defaults) if defaults else None) I get sage: inspect.getargspec(factor) == getargspec_via_ast(factor)
True
sage: getargspec_via_ast(sage.plot.plot3d.base.Graphics3d.export_jmol)
ArgSpec(args=['self', 'filename', 'force_reload', 'zoom', 'spin', 'background', 'stereo', 'mesh', 'dots', 'perspective_depth', 'orientation'], varargs=None, keywords='ignored_kwds', defaults=('jmol_shape.jmol', False, 100, False, (1, 1, 1), False, False, False, True, (-764, -346, -545, 76.390000000000001))) Maybe we can use this as a last resort? I think we'd first need to remove Cython-specific constructs. |
comment:6
It seems that nearly all of the warnings are from Cython files and that we really need a more robust analogue of For the The other warnings seem to be reST formatting problems, but I'm not sure about
|
comment:7
Can autodoc handle nested classes? |
comment:8
Replying to @qed777:
Or for now, a way to suppress all of the error message. I'm not sure about the |
comment:9
The following seems to remove the "arg is not a Python function" warnings: --- autodoc.py.origg 2010-02-18 15:51:38.000000000 -0800
+++ autodoc.py 2010-02-18 17:03:58.000000000 -0800
@@ -1005,7 +1005,16 @@ class MethodDocumenter(ClassLevelDocumen
else:
return None
else:
- argspec = inspect.getargspec(self.object)
+ # The check above misses ordinary Python methods in Cython
+ # files.
+ try:
+ argspec = inspect.getargspec(self.object)
+ except TypeError:
+ if (inspect.ismethod(self.object) and
+ self.env.config.autodoc_builtin_argspec):
+ argspec = self.env.config.autodoc_builtin_argspec(self.object.im_func)
+ else:
+ return None
if argspec[0] and argspec[0][0] in ('cls', 'self'):
del argspec[0][0]
return inspect.formatargspec(*argspec) Should we copy |
Handle |
comment:10
Attachment: trac_8244-slot_wrapper_argspec.patch.gz The attached patch should remove the warnings that end in
|
comment:11
With the patches, I get about 10 non-reST warnings. I think we can skip
in |
comment:12
This is great progress. By the way, I know how to fix the warnings for
to
Similarly for
This is an interesting idea since we're patching it so much. Then it would be under Sage revision control. We would just need to keep an eye on it whenever we upgrade Sphinx. I'm posting a patch which adds it. Actually, it doesn't add the whole thing, since I got an error when I tried that. Instead, it does
and then it defines |
comment:13
My patch also skips |
Attachment: trac_8244-conf-autodoc.patch.gz apply on top of other patch |
comment:14
Here's one more patch: this fixes one last warning message about sage.misc.process_dollars. |
Attachment: trac_8244-sagedoc.patch.gz apply on top of other patches |
Reviewer: Mitesh Patel |
comment:15
Thanks! Thanks also for making the extension patch. To the extent it counts, my review is positive. I'll rebase #7448. To the release manager: Please apply
|
Author: John Palmieri, Mitesh Patel |
Changed reviewer from Mitesh Patel to Mitesh Patel, John Palmieri |
Replaces "conf_autodoc" patch. |
comment:18
Attachment: trac_8244-conf-autodoc.2.patch.gz I've attached a replacement for the "conf-autodoc" patch that adds all of A self-contained What do you think? |
comment:19
Replying to @qed777:
Looks good to me. Still a positive review. |
comment:20
Merged in this order: |
Merged: sage-4.3.4.alpha0 |
Let's fix or suppress these, so that it's easier to identify new problems.
See the attachment.
CC: @sagetrac-mvngu @jhpalmieri @mwhansen @craigcitro @robertwb
Component: documentation
Author: John Palmieri, Mitesh Patel
Reviewer: Mitesh Patel, John Palmieri
Merged: sage-4.3.4.alpha0
Issue created by migration from https://trac.sagemath.org/ticket/8244
The text was updated successfully, but these errors were encountered: