-
-
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
Sphinx nested class rendering. #7448
Comments
comment:2
See #6664. We need to figure out how to resolve the issues there. |
comment:3
Mistaking inner classes for aliased attributes seems likely to be a Sphinx bug that we should report upstream, e.g., to sphinx-dev. Is there a minimal example we can submit that reproduces the problem? |
comment:4
Replying to @qed777:
I've made some experiments. Actually it seems that the problem is a bad interaction between sphinx and the particular metaclass |
Patch to experiment the interaction Sphinx/NestedMetaclass |
comment:5
Attachment: trac_7448-nested_class_sphinx_exper-fh.patch.gz
More info on this: to workaround python's nested class pickle bug we put any class which contain a nested class into
Then everything works fine. Any idea to solve this ? |
comment:6
Things are progressing with the help of Mike Hansen on irc: The submitted patch to autodoc.py partially solve the problem. Now each nested class is documented twice ! I'm trying to remove one. |
Author: Florent Hivert |
comment:7
This should solve the problem:
to
and |
This comment has been minimized.
This comment has been minimized.
comment:9
Two remarks:
Florent, off to bed :-) |
comment:11
Replying to @hivert:
Here's a new spkg: (I haven't tested the patch here, just implemented it and built the spkg. Please check the file autodoc.py to make sure I patched it right.) |
comment:12
To test this, do we need to add sage.misc.nested_class and/or sage.misc.nested_class_test to the reference manual? |
comment:13
Hi John, Replying to @jhpalmieri:
Thank for this. Is this normal that the file
contains the modifications, whereas
doesn't ? It seems that the answer is yes and that the former replace the later during build. Everthing seems to be ok.
No you don't ! Moreover, sage.misc.nested_class has already been added since #8250 merged in sage-4.3.3.alpha1. If you want to see the result pick a random file with nested class. They are plenty of them in categories, see eg
which has many thing implemented in nested classes. Note that now that we do see nested classes, we find out that they are plenty of room for improvement in those docs. It will be the purpose of an (or more probably several) other ticket. |
comment:14
Summary of discussion with Florent over the phone:
Florent will post an improved patch, but not right away. So if there is an emergency to get this into 4.4, I give a positive review on that particular patch to get in as is. |
comment:15
Replying to @hivert:
Yes, it's normal: in a typical spkg, the "src" directory is supposed to contain the original unmodified source, and then it gets patched by running spkg-install. I noticed that the nested classes in categories/coxeter_groups seem to be rendered correctly, so I guess that's good evidence that it's working. |
comment:16
So that if I want to update the spkg, I only need to update the file in
Cool ! |
comment:17
Replying to @hivert:
You should update You might also update SPKG.txt, which includes the change log. I put your name down for the new patch to autodoc.py, for example. You also need to decide if you need to bump the patch level up: just keep the directory as it is, sphinx-0.6.3.p5, or rename it to sphinx-0.6.3.p6. I think if you're just tinkering with this patch, keep it as "p5". Finally, going to the directory containing sphinx-0.6.3.p5, you run "sage -pkg sphinx-0.6.3.p5" to create the spkg file. |
Attachment: trac_7448-nested_class_sphinx-fh.patch.gz |
comment:21
An off-topic note about
I think we can suppress these by using |
comment:23
After some discussion I've found a better logic for raising warning. I'm working again on it. |
Attachment: autodoc.py.gz Attachment: autodoc.py.2.patch.gz |
comment:24
Attachment: trac_7448-nested_class_sphinx-fh.3.patch.gz Hi there ! I just uploaded what should be the final version of this patch:
at the beginning of |
Changed keywords from Sphinx categories. to Sphinx, nested classes |
Rebased for queue in comment. Apply only this patch. |
comment:26
Attachment: trac_7448-nested_class_sphinx-fh.4.patch.gz V4 is rebased for the following queue:
With #8244, we don't need to update the Questions:
diff --git a/doc/common/sage_autodoc.py b/doc/common/sage_autodoc.py
--- a/doc/common/sage_autodoc.py
+++ b/doc/common/sage_autodoc.py
@@ -848,7 +848,9 @@ class ClassDocumenter(ModuleLevelDocumen
# as data/attribute
if ret:
if hasattr(self.object, '__name__'):
- self.doc_as_attr = (self.objpath[-1] != self.object.__name__)
+ name = self.object.__name__
+ self.doc_as_attr = (self.objpath != name.split('.') and
+ self.check_module())
else:
self.doc_as_attr = True
return ret and make it easier to upgrade to newer Sphinx versions. Note: We have made changes to |
comment:27
Replying to @qed777:
Thanks for this !
What do you mean by refresh here ?
No objection ! Actually I think this has nothing to do with sphinx and it should be tested during the import. I put it here because if a class is detected as unpicklable, there is a very good chance it ends up typeset incorrectly by sphinx.
Sure ! Please do ! I won't have much time working on this so I'll appreciate someone take over those if the architecture is changed. |
comment:28
Replying to @hivert:
Just that I suggest any further changes be updates to that patch, via
Since it doesn't seem to belong in the docbuild system, can we put this check elsewhere, e.g., in the unit/doc-testing system? And restrict this ticket to nested class rendering?
I tried doing this and didn't have instant success. But as you suggest, it might be better to do this elsewhere. I may be overreacting. Thoughts? |
Only fix rendering of nested classes. |
comment:29
Attachment: trac_7448-nested_class_sphinx-fh.5.patch.gz Replying to @qed777:
I've attached V5, which should "just" fix Sphinx's rendering of nested classes. To the extent it counts, my review is positive. Could someone please review V5 for this ticket? I've opened #8452 for the nested class pickling check and will make a patch for that. |
Reviewer: Mitesh Patel |
This comment has been minimized.
This comment has been minimized.
comment:31
Replying to @qed777:
Hi Mitesh, Thanks for taking care of this ! I'm Ok with the change you made to my patches so that I suppose I'm allowed to put a positive review on this ticket. |
Merged: sage-4.3.4.alpha1 |
comment:32
Merged just trac_7448-nested_class_sphinx-fh.5.patch |
This patch fixes rendering of nested class in Sage.
The particular metaclass
NestedMetaclass
we have to use to work around the nested class pickling bug of python get in the way of Sphinx because it change the__name__
of the nested class.We have to make Sphinx aware of those particular classes and to update its configuration.
I also took the chance to raise a warning if someone forgot to set the metaclass leading to a unpicklable class. Several bug have been found that way. I'll add a ticket for this. Addendum: See #8452 for this.
CC: @mwhansen @nthiery @jhpalmieri
Component: documentation
Keywords: Sphinx, nested classes
Author: Florent Hivert
Reviewer: Mitesh Patel
Merged: sage-4.3.4.alpha1
Issue created by migration from https://trac.sagemath.org/ticket/7448
The text was updated successfully, but these errors were encountered: