|
2 | 2 | import __builtin__ |
3 | 3 |
|
4 | 4 | def print_doc(out, obj, meth): |
5 | | - doc = (getattr(obj, meth)).__doc__ |
6 | | - if doc == None: |
| 5 | + if meth == '__doc__': |
| 6 | + doc = getattr(obj, meth) |
| 7 | + bdname = '%s_doc' % obj.__name__ |
| 8 | + else: |
| 9 | + doc = getattr(obj, meth).__doc__ |
| 10 | + bdname = '%s_%s_doc' % (obj.__name__, meth) |
| 11 | + |
| 12 | + if doc is None: |
7 | 13 | doc = "" |
8 | 14 | lines = doc.split("\n") |
9 | | - outstring = '\\n" + \n "'.join(lines) |
10 | | - print >> out, (' public final static String %s_%s_doc = ' |
11 | | - % (obj.__name__, meth)) |
| 15 | + outstring = '\\n" + \n "'.join(format(line) for line in lines) |
| 16 | + print >> out, (' public final static String %s = ' % bdname) |
12 | 17 | print >> outfile, ' "%s";\n' % outstring |
13 | 18 |
|
| 19 | +format = lambda line: line.replace('\\', '\\\\').replace('"', r'\"') |
14 | 20 | opt = lambda n: getattr(__builtin__, n, None) |
15 | 21 |
|
16 | 22 | def f(): pass |
@@ -58,13 +64,13 @@ class C: |
58 | 64 | ] |
59 | 65 |
|
60 | 66 | outfile = open("BuiltinDocs.java", "w") |
61 | | -print >> outfile, '//generated by make_pydocs.py\n' |
| 67 | +print >> outfile, '// generated by make_pydocs.py\n' |
62 | 68 | print >> outfile, 'package org.python.core;\n' |
63 | 69 | print >> outfile, 'public class BuiltinDocs {\n' |
64 | 70 |
|
65 | 71 |
|
66 | 72 | for obj in types_list: |
67 | | - print >> outfile, ' //Docs for %s' % obj |
| 73 | + print >> outfile, ' // Docs for %s' % obj |
68 | 74 | for meth in dir(obj): |
69 | 75 | print_doc(outfile, obj, meth) |
70 | 76 |
|
|
0 commit comments