Message11136

Author onealj
Recipients onealj, stefan.richthofer
Date 2017-02-27.11:21:54
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1488194514.77.0.434612347424.issue2545@psf.upfronthosting.co.za>
In-reply-to
Content
help(module)
calls pydoc.help(module)
calls pydoc.doc(module, 'Help on %s:')
calls pydoc.render_doc(module, title='Help on %s:', forceload=0)
calls pydoc.text.document(module, modulename)

Which will only add the docstring if the object is a module. Since inspect identifies modules implemented in Java as classes instead of modules, the module section is not created for Java classes.

inspect.ismodule(urllib) == True #a pure python module
inspect.ismodule(_imp) == False #a java implemented module/class
inspect.isclass(_imp) == True

https://hg.python.org/jython/file/tip/Lib/pydoc.py#l321

A quick hack of writing a module section when the object is either a module or a class fixed the missing docstring for Java docs, but likely has negative consequences for Python classes (both old and new style).

diff -r 0d2b840f6df8 Lib/pydoc.py
--- a/Lib/pydoc.py      Mon Feb 27 01:22:01 2017 +0100
+++ b/Lib/pydoc.py      Mon Feb 27 03:13:18 2017 -0800
@@ -329,7 +331,7 @@
         if inspect.ismemberdescriptor(object): return self.docdata(*args)
         try:
             if inspect.ismodule(object): return self.docmodule(*args)
-            if inspect.isclass(object): return self.docclass(*args)
+            if inspect.isclass(object): return self.docmodule(*args)
             if inspect.isroutine(object): return self.docroutine(*args)
         except AttributeError:
             pass

I'm leaning towards fixing inspect.ismodule and inspect.isclass to identify Java static (all static fields, private constructor, shouldn't have instances) classes as modules. Thoughts?
History
Date User Action Args
2017-02-27 11:21:54onealjsetmessageid: <1488194514.77.0.434612347424.issue2545@psf.upfronthosting.co.za>
2017-02-27 11:21:54onealjsetrecipients: + onealj, stefan.richthofer
2017-02-27 11:21:54onealjlinkissue2545 messages
2017-02-27 11:21:54onealjcreate