Show More
@@ -1,70 +1,65 b'' | |||
|
1 | 1 | # encoding: utf-8 |
|
2 | 2 | """ |
|
3 | 3 | Utilities for warnings. Shoudn't we just use the built in warnings module. |
|
4 | 4 | """ |
|
5 | 5 | |
|
6 | 6 | # Copyright (c) IPython Development Team. |
|
7 | 7 | # Distributed under the terms of the Modified BSD License. |
|
8 | 8 | |
|
9 | 9 | from __future__ import print_function |
|
10 | 10 | |
|
11 | 11 | import sys |
|
12 | 12 | import warnings |
|
13 | from IPython.utils.decorators import undoc | |
|
14 | 13 | |
|
15 | 14 | warnings.warn("The module IPython.utils.warn is deprecated since IPython 4.0, use the standard warnings module instead", DeprecationWarning) |
|
16 | 15 | |
|
17 | @undoc | |
|
18 | 16 | def warn(msg,level=2,exit_val=1): |
|
19 | 17 | """Deprecated |
|
20 | 18 | |
|
21 | 19 | Standard warning printer. Gives formatting consistency. |
|
22 | 20 | |
|
23 | 21 | Output is sent to io.stderr (sys.stderr by default). |
|
24 | 22 | |
|
25 | 23 | Options: |
|
26 | 24 | |
|
27 | 25 | -level(2): allows finer control: |
|
28 | 26 | 0 -> Do nothing, dummy function. |
|
29 | 27 | 1 -> Print message. |
|
30 | 28 | 2 -> Print 'WARNING:' + message. (Default level). |
|
31 | 29 | 3 -> Print 'ERROR:' + message. |
|
32 | 30 | 4 -> Print 'FATAL ERROR:' + message and trigger a sys.exit(exit_val). |
|
33 | 31 | |
|
34 | 32 | -exit_val (1): exit value returned by sys.exit() for a level 4 |
|
35 | 33 | warning. Ignored for all other levels.""" |
|
36 | 34 | |
|
37 | 35 | warnings.warn("The module IPython.utils.warn is deprecated since IPython 4.0, use the standard warnings module instead", DeprecationWarning) |
|
38 | 36 | if level>0: |
|
39 | 37 | header = ['','','WARNING: ','ERROR: ','FATAL ERROR: '] |
|
40 | 38 | print(header[level], msg, sep='', file=sys.stderr) |
|
41 | 39 | if level == 4: |
|
42 | 40 | print('Exiting.\n', file=sys.stderr) |
|
43 | 41 | sys.exit(exit_val) |
|
44 | 42 | |
|
45 | 43 | |
|
46 | @undoc | |
|
47 | 44 | def info(msg): |
|
48 | 45 | """Deprecated |
|
49 | 46 | |
|
50 | 47 | Equivalent to warn(msg,level=1).""" |
|
51 | 48 | |
|
52 | 49 | warn(msg,level=1) |
|
53 | 50 | |
|
54 | 51 | |
|
55 | @undoc | |
|
56 | 52 | def error(msg): |
|
57 | 53 | """Deprecated |
|
58 | 54 | |
|
59 | 55 | Equivalent to warn(msg,level=3).""" |
|
60 | 56 | |
|
61 | 57 | warn(msg,level=3) |
|
62 | 58 | |
|
63 | 59 | |
|
64 | @undoc | |
|
65 | 60 | def fatal(msg,exit_val=1): |
|
66 | 61 | """Deprecated |
|
67 | 62 | |
|
68 | 63 | Equivalent to warn(msg,exit_val=exit_val,level=4).""" |
|
69 | 64 | |
|
70 | 65 | warn(msg,exit_val=exit_val,level=4) |
@@ -1,75 +1,77 b'' | |||
|
1 | 1 | #!/usr/bin/env python |
|
2 | 2 | """Script to auto-generate our API docs. |
|
3 | 3 | """ |
|
4 | 4 | |
|
5 | 5 | import os |
|
6 | 6 | import sys |
|
7 | 7 | |
|
8 | 8 | pjoin = os.path.join |
|
9 | 9 | |
|
10 | 10 | here = os.path.abspath(os.path.dirname(__file__)) |
|
11 | 11 | sys.path.append(pjoin(os.path.abspath(here), 'sphinxext')) |
|
12 | 12 | |
|
13 | 13 | from apigen import ApiDocWriter |
|
14 | 14 | |
|
15 | 15 | source = pjoin(here, 'source') |
|
16 | 16 | |
|
17 | 17 | #***************************************************************************** |
|
18 | 18 | if __name__ == '__main__': |
|
19 | 19 | package = 'IPython' |
|
20 | 20 | outdir = pjoin(source, 'api', 'generated') |
|
21 | 21 | docwriter = ApiDocWriter(package,rst_extension='.rst') |
|
22 | 22 | # You have to escape the . here because . is a special char for regexps. |
|
23 | 23 | # You must do make clean if you change this! |
|
24 | 24 | docwriter.package_skip_patterns += [r'\.external$', |
|
25 | 25 | # Extensions are documented elsewhere. |
|
26 | 26 | r'\.extensions', |
|
27 | 27 | # Magics are documented separately |
|
28 | 28 | r'\.core\.magics', |
|
29 | 29 | # This isn't API |
|
30 | 30 | r'\.sphinxext', |
|
31 | 31 | # Shims |
|
32 | 32 | r'\.kernel', |
|
33 | 33 | r'\.terminal\.pt_inputhooks', |
|
34 | 34 | ] |
|
35 | 35 | |
|
36 | 36 | # The inputhook* modules often cause problems on import, such as trying to |
|
37 | 37 | # load incompatible Qt bindings. It's easiest to leave them all out. The |
|
38 | 38 | docwriter.module_skip_patterns += [ r'\.lib\.inputhook.+', |
|
39 | 39 | r'\.ipdoctest', |
|
40 | 40 | r'\.testing\.plugin', |
|
41 | 41 | # Backwards compat import for lib.lexers |
|
42 | 42 | r'\.nbconvert\.utils\.lexers', |
|
43 | 43 | # We document this manually. |
|
44 | 44 | r'\.utils\.py3compat', |
|
45 | 45 | # These are exposed in display |
|
46 | 46 | r'\.core\.display', |
|
47 | 47 | r'\.lib\.display', |
|
48 | 48 | # Shims |
|
49 | 49 | r'\.config', |
|
50 | 50 | r'\.consoleapp', |
|
51 | 51 | r'\.frontend$', |
|
52 | 52 | r'\.html', |
|
53 | 53 | r'\.nbconvert', |
|
54 | 54 | r'\.nbformat', |
|
55 | 55 | r'\.parallel', |
|
56 | 56 | r'\.qt', |
|
57 | # this is deprecated. | |
|
58 | r'\.utils\.warn', | |
|
57 | 59 | ] |
|
58 | 60 | # main API is in the inputhook module, which is documented. |
|
59 | 61 | |
|
60 | 62 | # These modules import functions and classes from other places to expose |
|
61 | 63 | # them as part of the public API. They must have __all__ defined. The |
|
62 | 64 | # non-API modules they import from should be excluded by the skip patterns |
|
63 | 65 | # above. |
|
64 | 66 | docwriter.names_from__all__.update({ |
|
65 | 67 | 'IPython.display', |
|
66 | 68 | }) |
|
67 | 69 | |
|
68 | 70 | # Now, generate the outputs |
|
69 | 71 | docwriter.write_api_docs(outdir) |
|
70 | 72 | # Write index with .txt extension - we can include it, but Sphinx won't try |
|
71 | 73 | # to compile it |
|
72 | 74 | docwriter.write_index(outdir, 'gen.txt', |
|
73 | 75 | relative_to = pjoin(source, 'api') |
|
74 | 76 | ) |
|
75 | 77 | print ('%d files written' % len(docwriter.written_modules)) |
General Comments 0
You need to be logged in to leave comments.
Login now