author | Aurelien Campeas <aurelien.campeas@logilab.fr> |
Fri, 25 May 2012 17:18:00 +0200 | |
changeset 8429 | cad2d8e03b33 |
parent 7815 | 2a164a9cf81c |
child 8801 | 86c1a5afbe4e |
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 |
""" |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
5 |
from __future__ import with_statement |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
6 |
|
6880
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
7 |
import os.path as osp |
5470
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
8 |
import sys, os, getopt, re |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
9 |
|
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
10 |
def clean_comment(match): |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
11 |
comment = match.group() |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
12 |
comment = strip_stars(comment) |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
13 |
return comment |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
14 |
|
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
15 |
# Rest utilities |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
16 |
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
|
17 |
size = len(title) |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
18 |
if level == 0: |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
19 |
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
|
20 |
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
|
21 |
|
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
22 |
def get_doc_comments(text): |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
23 |
""" |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
24 |
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
|
25 |
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
|
26 |
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
|
27 |
guess function & arguments. |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
28 |
|
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'))[0][0][:40] |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
30 |
'/**\n * This is the module documentation.' |
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][0][7:50] |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
32 |
'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
|
33 |
>>> 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
|
34 |
'function the_first_function(arg1, arg2) ' |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
35 |
>>> 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
|
36 |
'/** 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
|
37 |
|
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
38 |
""" |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
39 |
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
|
40 |
text, re.DOTALL|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 |
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
|
43 |
|
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 |
def strip_stars(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 leading stars from a doc comment. |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
48 |
|
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
49 |
>>> strip_stars('/** This is a comment. */') |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
50 |
'This is a comment.' |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
51 |
>>> 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
|
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 |
>>> 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
|
54 |
'This is a\n multiline comment.' |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
55 |
|
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 |
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
|
58 |
|
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
59 |
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
|
60 |
""" |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
61 |
Main command-line invocation. |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
62 |
""" |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
63 |
try: |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
64 |
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
|
65 |
'jspath=', 'output=', 'help']) |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
66 |
opts = dict(opts) |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
67 |
except getopt.GetoptError: |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
68 |
usage() |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
69 |
sys.exit(2) |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
70 |
|
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
71 |
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
|
72 |
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
|
73 |
rst_dir = 'apidocs' |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
74 |
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
|
75 |
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
|
76 |
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
|
77 |
|
6880
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
78 |
index = set() |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
79 |
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
|
80 |
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
|
81 |
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
|
82 |
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
|
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 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
|
85 |
continue |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
86 |
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
|
87 |
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
|
88 |
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
|
89 |
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
|
90 |
# add to index |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
91 |
index.add(filename) |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
92 |
# save rst file |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
93 |
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
|
94 |
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
|
95 |
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
|
96 |
stream.write(''' |
5470
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
97 |
.. toctree:: |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
98 |
:maxdepth: 1 |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
99 |
|
6880
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
100 |
''') |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
101 |
# 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
|
102 |
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
|
103 |
try: |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
104 |
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
|
105 |
except Exception: |
6880
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
106 |
raise Exception( |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
107 |
'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
|
108 |
'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
|
109 |
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
|
110 |
# 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
|
111 |
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
|
112 |
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
|
113 |
stream.close() |
5470
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
114 |
|
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
115 |
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
|
116 |
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
|
117 |
filecontent = open(js_filepath, 'U').read() |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
118 |
comments = get_doc_comments(filecontent) |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
119 |
rst = rest_title(js_file, 0) |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
120 |
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
|
121 |
rst += '\n\n'.join(comments) |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
122 |
return rst |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
123 |
|
6880
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
124 |
INDEX_IN_ORDER = [ |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
125 |
'cubicweb', |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
126 |
'cubicweb.python', |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
127 |
'cubicweb.htmlhelpers', |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
128 |
'cubicweb.ajax', |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
129 |
|
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
130 |
'cubicweb.ajax.box', |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
131 |
'cubicweb.facets', |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
132 |
'cubicweb.widgets', |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
133 |
'cubicweb.image', |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
134 |
'cubicweb.flot', |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
135 |
'cubicweb.calendar', |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
136 |
'cubicweb.preferences', |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
137 |
'cubicweb.edition', |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
138 |
'cubicweb.reledit', |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
139 |
'cubicweb.iprogress', |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
140 |
'cubicweb.rhythm', |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
141 |
'cubicweb.gmap', |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
142 |
'cubicweb.timeline-ext', |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
143 |
] |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
144 |
|
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
145 |
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
|
146 |
'jquery.js', |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
147 |
'jquery.treeview.js', |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
148 |
'jquery.json.js', |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
149 |
'jquery.tablesorter.js', |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
150 |
'jquery.timePicker.js', |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
151 |
'jquery.flot.js', |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
152 |
'jquery.corner.js', |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
153 |
'jquery.ui.js', |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
154 |
'excanvas.js', |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
155 |
'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
|
156 |
|
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
157 |
'cubicweb.fckcwconfig.js', |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
158 |
'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
|
159 |
'cubicweb.goa.js', |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
160 |
'cubicweb.compat.js', |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
161 |
'cubicweb.timeline-bundle.js', |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
162 |
]) |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5470
diff
changeset
|
163 |
|
5470
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
164 |
if __name__ == '__main__': |
fb004819cab4
[book] add generated js documentation to cw book
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff
changeset
|
165 |
parse_js_files() |