Hi!

Until today, I thought that introspection via "?" uses sage_getdoc. I
stand corrected. Apparently it just uses _sage_getdoc_unformatted.

While sage_getdoc is supposed to remove the embedding information,
introspection with "?" and _sage_getdoc_unformatted show the embedding
information:

{{{
sage: r = 'File: _tmp_1_spyx_0.pyx (starting at line 6)\nsome doc'
sage: class Foo:
....:     def _sage_doc_(self):
....:         return r
....:
sage: f = Foo()
sage: f?
Type:           instance
Base Class:     __main__.Foo
String Form:    <__main__.Foo instance at 0x4760ef0>
Namespace:      Interactive
File:           /mnt/local/king/SAGE/debug/sage-4.7.2.alpha3-
prerelease/local/lib/python2.6/site-packages/IPython/FakeModule.py
Docstring:
    File: _tmp_1_spyx_0.pyx (starting at line 6)
    some doc

sage: from sage.misc.sageinspect import sage_getdoc,
_sage_getdoc_unformatted
sage: print sage_getdoc(f)
 some doc

sage: print _sage_getdoc_unformatted(f)
File: _tmp_1_spyx_0.pyx (starting at line 6)
some doc
}}}

First two questions:
1) Do we want that the embedding information is not shown by "?", so
that introspection for Cython modules looks more like introspection
for Python?
2) If "yes": Where is introspection by "?" implemented, so that I can
modify it to use sage_getdoc instead of _sage_getdoc_unformatted?

The fact that "?" does not use formatting also has another not so nice
effect: Latex commands are not translated into ASCII art, which
sage_getdoc is capable of:

{{{
sage: r = 'some doc for a cython method\n`x \\geq y`'
sage: class Foo:
....:     def _sage_doc_(self):
....:         return r
....:
sage: f = Foo()
sage: f?
Type:           instance
Base Class:     __main__.Foo
String Form:    <__main__.Foo instance at 0x6d85a8>
Namespace:      Interactive
File:           /mnt/local/king/SAGE/debug/sage-4.7.2.alpha3-
prerelease/local/lib/python2.6/site-packages/IPython/FakeModule.py
Docstring:
    some doc for a cython method
    `x \geq y`

sage: print sage_getdoc(f)
some doc for a cython method x >= y

}}}

So, third question:
3) Do we want that "?" detexifies the doc strings (which again would
mean to replace _sage_getdoc_unformatted by sage_getdoc)?

Best regards,
Simon

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to