author | Julien Cristau <julien.cristau@logilab.fr> |
Tue, 07 Jul 2015 14:12:46 +0200 | |
changeset 10525 | b8fddae83a46 |
parent 10491 | c67bcee93248 |
child 11056 | b7f8d2ee6532 |
permissions | -rwxr-xr-x |
5470
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
1 |
#!/usr/bin/env python |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
2 |
""" |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
3 |
Parser for Javascript comments. |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
4 |
""" |
6880
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
5 |
import os.path as osp |
5470
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
6 |
import sys, os, getopt, re |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
7 |
|
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
8 |
def clean_comment(match): |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
9 |
comment = match.group() |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
10 |
comment = strip_stars(comment) |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
11 |
return comment |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
12 |
|
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
13 |
# Rest utilities |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
14 |
def rest_title(title, level, level_markups=['=', '=', '-', '~', '+', '`']): |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
15 |
size = len(title) |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
16 |
if level == 0: |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
17 |
return '\n'.join((level_markups[level] * size, title, level_markups[0] * size)) + '\n' |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
18 |
return '\n'.join(('\n' + title, level_markups[level] * size)) + '\n' |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
19 |
|
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
20 |
def get_doc_comments(text): |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
21 |
""" |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
22 |
Return a list of all documentation comments in the file text. Each |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
23 |
comment is a pair, with the first element being the comment text and |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
24 |
the second element being the line after it, which may be needed to |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
25 |
guess function & arguments. |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
26 |
|
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
27 |
>>> get_doc_comments(read_file('examples/module.js'))[0][0][:40] |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
28 |
'/**\n * This is the module documentation.' |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
29 |
>>> get_doc_comments(read_file('examples/module.js'))[1][0][7:50] |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
30 |
'This is documentation for the first method.' |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
31 |
>>> get_doc_comments(read_file('examples/module.js'))[1][1] |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
32 |
'function the_first_function(arg1, arg2) ' |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
33 |
>>> get_doc_comments(read_file('examples/module.js'))[2][0] |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
34 |
'/** This is the documentation for the second function. */' |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
35 |
|
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
36 |
""" |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
37 |
return [clean_comment(match) for match in re.finditer('/\*\*.*?\*/', |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
38 |
text, re.DOTALL|re.MULTILINE)] |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
39 |
|
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
40 |
RE_STARS = re.compile('^\s*?\* ?', re.MULTILINE) |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
41 |
|
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
42 |
|
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
43 |
def strip_stars(doc_comment): |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
44 |
""" |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
45 |
Strip leading stars from a doc comment. |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
46 |
|
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
47 |
>>> strip_stars('/** This is a comment. */') |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
48 |
'This is a comment.' |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
49 |
>>> strip_stars('/**\n * This is a\n * multiline comment. */') |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
50 |
'This is a\n multiline comment.' |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
51 |
>>> strip_stars('/** \n\t * This is a\n\t * multiline comment. \n*/') |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
52 |
'This is a\n multiline comment.' |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
53 |
|
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
54 |
""" |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
55 |
return RE_STARS.sub('', doc_comment[3:-2]).strip() |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
56 |
|
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
57 |
def parse_js_files(args=sys.argv): |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
58 |
""" |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
59 |
Main command-line invocation. |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
60 |
""" |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
61 |
try: |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
62 |
opts, args = getopt.gnu_getopt(args[1:], 'p:o:h', [ |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
63 |
'jspath=', 'output=', 'help']) |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
64 |
opts = dict(opts) |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
65 |
except getopt.GetoptError: |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
66 |
usage() |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
67 |
sys.exit(2) |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
68 |
|
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
69 |
rst_dir = opts.get('--output') or opts.get('-o') |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
70 |
if rst_dir is None and len(args) != 1: |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
71 |
rst_dir = 'apidocs' |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
72 |
js_dir = opts.get('--jspath') or opts.get('-p') |
6880
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
73 |
if not osp.exists(osp.join(rst_dir)): |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
74 |
os.makedirs(osp.join(rst_dir)) |
5470
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
75 |
|
6880
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
76 |
index = set() |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
77 |
for js_path, js_dirs, js_files in os.walk(js_dir): |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
78 |
rst_path = re.sub('%s%s*' % (js_dir, osp.sep), '', js_path) |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
79 |
for js_file in js_files: |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
80 |
if not js_file.endswith('.js'): |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
81 |
continue |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
82 |
if js_file in FILES_TO_IGNORE: |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
83 |
continue |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
84 |
if not osp.exists(osp.join(rst_dir, rst_path)): |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
85 |
os.makedirs(osp.join(rst_dir, rst_path)) |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
86 |
rst_content = extract_rest(js_path, js_file) |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
87 |
filename = osp.join(rst_path, js_file[:-3]) |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
88 |
# add to index |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
89 |
index.add(filename) |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
90 |
# save rst file |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
91 |
with open(osp.join(rst_dir, filename) + '.rst', 'wb') as f_rst: |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
92 |
f_rst.write(rst_content) |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
93 |
stream = open(osp.join(rst_dir, 'index.rst'), 'w') |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
94 |
stream.write(''' |
10491
c67bcee93248
[doc] Restructure the documentation
Christophe de Vienne <christophe@unlish.com>
parents:
10232
diff
changeset
|
95 |
Javascript API |
c67bcee93248
[doc] Restructure the documentation
Christophe de Vienne <christophe@unlish.com>
parents:
10232
diff
changeset
|
96 |
============== |
c67bcee93248
[doc] Restructure the documentation
Christophe de Vienne <christophe@unlish.com>
parents:
10232
diff
changeset
|
97 |
|
5470
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
98 |
.. toctree:: |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
99 |
:maxdepth: 1 |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
100 |
|
6880
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
101 |
''') |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
102 |
# first write expected files in order |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
103 |
for fileid in INDEX_IN_ORDER: |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
104 |
try: |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
105 |
index.remove(fileid) |
7815
2a164a9cf81c
[exceptions] stop catching any exception in various places (closes #1942716)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7510
diff
changeset
|
106 |
except Exception: |
6880
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
107 |
raise Exception( |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
108 |
'Bad file id %s referenced in INDEX_IN_ORDER in %s, ' |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
109 |
'fix this please' % (fileid, __file__)) |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
110 |
stream.write(' %s\n' % fileid) |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
111 |
# append remaining, by alphabetical order |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
112 |
for fileid in sorted(index): |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
113 |
stream.write(' %s\n' % fileid) |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
114 |
stream.close() |
5470
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
115 |
|
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
116 |
def extract_rest(js_dir, js_file): |
6880
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
117 |
js_filepath = osp.join(js_dir, js_file) |
5470
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
118 |
filecontent = open(js_filepath, 'U').read() |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
119 |
comments = get_doc_comments(filecontent) |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
120 |
rst = rest_title(js_file, 0) |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
121 |
rst += '.. module:: %s\n\n' % js_file |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
122 |
rst += '\n\n'.join(comments) |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
123 |
return rst |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
124 |
|
6880
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
125 |
INDEX_IN_ORDER = [ |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
126 |
'cubicweb', |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
127 |
'cubicweb.python', |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
128 |
'cubicweb.htmlhelpers', |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
129 |
'cubicweb.ajax', |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
130 |
|
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
131 |
'cubicweb.ajax.box', |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
132 |
'cubicweb.facets', |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
133 |
'cubicweb.widgets', |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
134 |
'cubicweb.image', |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
135 |
'cubicweb.flot', |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
136 |
'cubicweb.calendar', |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
137 |
'cubicweb.preferences', |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
138 |
'cubicweb.edition', |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
139 |
'cubicweb.reledit', |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
140 |
] |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
141 |
|
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
142 |
FILES_TO_IGNORE = set([ |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
143 |
'jquery.js', |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
144 |
'jquery.treeview.js', |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
145 |
'jquery.tablesorter.js', |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
146 |
'jquery.timePicker.js', |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
147 |
'jquery.flot.js', |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
148 |
'jquery.corner.js', |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
149 |
'jquery.ui.js', |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
150 |
'excanvas.js', |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
151 |
'gmap.utility.labeledmarker.js', |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
152 |
|
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
153 |
'cubicweb.fckcwconfig.js', |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
154 |
'cubicweb.fckcwconfig-full.js', |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
155 |
'cubicweb.goa.js', |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
156 |
'cubicweb.compat.js', |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
157 |
]) |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
158 |
|
5470
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
159 |
if __name__ == '__main__': |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
160 |
parse_js_files() |