Skip to content

Commit 369864a

Browse files
committed
First cut at generating the __doc__ test for builtin types. So far I am only
generating the docs for str and unicode, and I have only exposed the docs for str.
1 parent 044fa1a commit 369864a

3 files changed

Lines changed: 797 additions & 57 deletions

File tree

Misc/make_pydocs.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
class PyDocGenerator(object):
2+
def __init__(self):
3+
self.out = open("BuiltinDocs.java", "w")
4+
print >> self.out, '//generated by make_pydocs.py\n'
5+
print >> self.out, 'package org.python.core;\n'
6+
print >> self.out, 'public class BuiltinDocs {\n'
7+
objects = [str, unicode]
8+
for obj in objects:
9+
print >> self.out, ' //Docs for %s' % obj
10+
for meth in dir(obj):
11+
self.print_doc(obj, meth)
12+
print >> self.out, '}'
13+
14+
15+
def print_doc(self, obj, meth):
16+
doc = (getattr(obj, meth)).__doc__
17+
if doc == None:
18+
doc = ""
19+
lines = doc.split("\n")
20+
out = '\\n" + \n "'.join(lines)
21+
print >> self.out, (' public final static String %s_%s_doc = '
22+
% (obj.__name__, meth))
23+
print >> self.out, ' "%s";\n' % out
24+
25+
if __name__ == '__main__':
26+
PyDocGenerator()

0 commit comments

Comments
 (0)