Show More
@@ -6,7 +6,7 b'' | |||||
6 | # GNU General Public License version 2 or any later version. |
|
6 | # GNU General Public License version 2 or any later version. | |
7 |
|
7 | |||
8 | import imp, os |
|
8 | import imp, os | |
9 |
import util, cmdutil, |
|
9 | import util, cmdutil, error | |
10 | from i18n import _, gettext |
|
10 | from i18n import _, gettext | |
11 |
|
11 | |||
12 | _extensions = {} |
|
12 | _extensions = {} | |
@@ -209,6 +209,38 b' def _disabledpaths(strip_init=False):' | |||||
209 | exts[name] = path |
|
209 | exts[name] = path | |
210 | return exts |
|
210 | return exts | |
211 |
|
211 | |||
|
212 | def _moduledoc(file): | |||
|
213 | '''return the top-level python documentation for the given file | |||
|
214 | ||||
|
215 | Loosely inspired by pydoc.source_synopsis(), but rewritten to | |||
|
216 | handle triple quotes and to return the whole text instead of just | |||
|
217 | the synopsis''' | |||
|
218 | result = [] | |||
|
219 | ||||
|
220 | line = file.readline() | |||
|
221 | while line[:1] == '#' or not line.strip(): | |||
|
222 | line = file.readline() | |||
|
223 | if not line: | |||
|
224 | break | |||
|
225 | ||||
|
226 | start = line[:3] | |||
|
227 | if start == '"""' or start == "'''": | |||
|
228 | line = line[3:] | |||
|
229 | while line: | |||
|
230 | if line.rstrip().endswith(start): | |||
|
231 | line = line.split(start)[0] | |||
|
232 | if line: | |||
|
233 | result.append(line) | |||
|
234 | break | |||
|
235 | elif not line: | |||
|
236 | return None # unmatched delimiter | |||
|
237 | result.append(line) | |||
|
238 | line = file.readline() | |||
|
239 | else: | |||
|
240 | return None | |||
|
241 | ||||
|
242 | return ''.join(result) | |||
|
243 | ||||
212 | def _disabledhelp(path): |
|
244 | def _disabledhelp(path): | |
213 | '''retrieve help synopsis of a disabled extension (without importing)''' |
|
245 | '''retrieve help synopsis of a disabled extension (without importing)''' | |
214 | try: |
|
246 | try: | |
@@ -216,7 +248,7 b' def _disabledhelp(path):' | |||||
216 | except IOError: |
|
248 | except IOError: | |
217 | return |
|
249 | return | |
218 | else: |
|
250 | else: | |
219 |
doc = |
|
251 | doc = moduledoc(file) | |
220 | file.close() |
|
252 | file.close() | |
221 |
|
253 | |||
222 | if doc: # extracting localized synopsis |
|
254 | if doc: # extracting localized synopsis |
@@ -10,39 +10,6 b' import sys, os' | |||||
10 | import extensions |
|
10 | import extensions | |
11 | import util |
|
11 | import util | |
12 |
|
12 | |||
13 |
|
||||
14 | def moduledoc(file): |
|
|||
15 | '''return the top-level python documentation for the given file |
|
|||
16 |
|
||||
17 | Loosely inspired by pydoc.source_synopsis(), but rewritten to |
|
|||
18 | handle triple quotes and to return the whole text instead of just |
|
|||
19 | the synopsis''' |
|
|||
20 | result = [] |
|
|||
21 |
|
||||
22 | line = file.readline() |
|
|||
23 | while line[:1] == '#' or not line.strip(): |
|
|||
24 | line = file.readline() |
|
|||
25 | if not line: |
|
|||
26 | break |
|
|||
27 |
|
||||
28 | start = line[:3] |
|
|||
29 | if start == '"""' or start == "'''": |
|
|||
30 | line = line[3:] |
|
|||
31 | while line: |
|
|||
32 | if line.rstrip().endswith(start): |
|
|||
33 | line = line.split(start)[0] |
|
|||
34 | if line: |
|
|||
35 | result.append(line) |
|
|||
36 | break |
|
|||
37 | elif not line: |
|
|||
38 | return None # unmatched delimiter |
|
|||
39 | result.append(line) |
|
|||
40 | line = file.readline() |
|
|||
41 | else: |
|
|||
42 | return None |
|
|||
43 |
|
||||
44 | return ''.join(result) |
|
|||
45 |
|
||||
46 | def listexts(header, exts, indent=1): |
|
13 | def listexts(header, exts, indent=1): | |
47 | '''return a text listing of the given extensions''' |
|
14 | '''return a text listing of the given extensions''' | |
48 | if not exts: |
|
15 | if not exts: |
General Comments 0
You need to be logged in to leave comments.
Login now