Show More
@@ -1,57 +1,65 b'' | |||||
1 | # encoding: utf-8 |
|
1 | # encoding: utf-8 | |
2 | """ |
|
2 | """ | |
3 | Utilities for warnings. Shoudn't we just use the built in warnings module. |
|
3 | Utilities for warnings. Shoudn't we just use the built in warnings module. | |
4 | """ |
|
4 | """ | |
5 |
|
5 | |||
6 | # Copyright (c) IPython Development Team. |
|
6 | # Copyright (c) IPython Development Team. | |
7 | # Distributed under the terms of the Modified BSD License. |
|
7 | # Distributed under the terms of the Modified BSD License. | |
8 |
|
8 | |||
9 | from __future__ import print_function |
|
9 | from __future__ import print_function | |
10 |
|
10 | |||
11 | import sys |
|
11 | import sys | |
12 | import warnings |
|
12 | import warnings | |
13 |
|
13 | |||
14 | warnings.warn("The module IPython.utils.warn is deprecated since IPython 4.0, use the standard warnings module instead", DeprecationWarning) |
|
14 | warnings.warn("The module IPython.utils.warn is deprecated since IPython 4.0, use the standard warnings module instead", DeprecationWarning) | |
15 |
|
15 | |||
16 | def warn(msg,level=2,exit_val=1): |
|
16 | def warn(msg,level=2,exit_val=1): | |
17 | """Standard warning printer. Gives formatting consistency. |
|
17 | """Deprecated | |
|
18 | ||||
|
19 | Standard warning printer. Gives formatting consistency. | |||
18 |
|
20 | |||
19 | Output is sent to io.stderr (sys.stderr by default). |
|
21 | Output is sent to io.stderr (sys.stderr by default). | |
20 |
|
22 | |||
21 | Options: |
|
23 | Options: | |
22 |
|
24 | |||
23 | -level(2): allows finer control: |
|
25 | -level(2): allows finer control: | |
24 | 0 -> Do nothing, dummy function. |
|
26 | 0 -> Do nothing, dummy function. | |
25 | 1 -> Print message. |
|
27 | 1 -> Print message. | |
26 | 2 -> Print 'WARNING:' + message. (Default level). |
|
28 | 2 -> Print 'WARNING:' + message. (Default level). | |
27 | 3 -> Print 'ERROR:' + message. |
|
29 | 3 -> Print 'ERROR:' + message. | |
28 | 4 -> Print 'FATAL ERROR:' + message and trigger a sys.exit(exit_val). |
|
30 | 4 -> Print 'FATAL ERROR:' + message and trigger a sys.exit(exit_val). | |
29 |
|
31 | |||
30 | -exit_val (1): exit value returned by sys.exit() for a level 4 |
|
32 | -exit_val (1): exit value returned by sys.exit() for a level 4 | |
31 | warning. Ignored for all other levels.""" |
|
33 | warning. Ignored for all other levels.""" | |
32 |
|
34 | |||
33 | warnings.warn("The module IPython.utils.warn is deprecated since IPython 4.0, use the standard warnings module instead", DeprecationWarning) |
|
35 | warnings.warn("The module IPython.utils.warn is deprecated since IPython 4.0, use the standard warnings module instead", DeprecationWarning) | |
34 | if level>0: |
|
36 | if level>0: | |
35 | header = ['','','WARNING: ','ERROR: ','FATAL ERROR: '] |
|
37 | header = ['','','WARNING: ','ERROR: ','FATAL ERROR: '] | |
36 | print(header[level], msg, sep='', file=sys.stderr) |
|
38 | print(header[level], msg, sep='', file=sys.stderr) | |
37 | if level == 4: |
|
39 | if level == 4: | |
38 | print('Exiting.\n', file=sys.stderr) |
|
40 | print('Exiting.\n', file=sys.stderr) | |
39 | sys.exit(exit_val) |
|
41 | sys.exit(exit_val) | |
40 |
|
42 | |||
41 |
|
43 | |||
42 | def info(msg): |
|
44 | def info(msg): | |
43 | """Equivalent to warn(msg,level=1).""" |
|
45 | """Deprecated | |
|
46 | ||||
|
47 | Equivalent to warn(msg,level=1).""" | |||
44 |
|
48 | |||
45 | warn(msg,level=1) |
|
49 | warn(msg,level=1) | |
46 |
|
50 | |||
47 |
|
51 | |||
48 | def error(msg): |
|
52 | def error(msg): | |
49 | """Equivalent to warn(msg,level=3).""" |
|
53 | """Deprecated | |
|
54 | ||||
|
55 | Equivalent to warn(msg,level=3).""" | |||
50 |
|
56 | |||
51 | warn(msg,level=3) |
|
57 | warn(msg,level=3) | |
52 |
|
58 | |||
53 |
|
59 | |||
54 | def fatal(msg,exit_val=1): |
|
60 | def fatal(msg,exit_val=1): | |
55 | """Equivalent to warn(msg,exit_val=exit_val,level=4).""" |
|
61 | """Deprecated | |
|
62 | ||||
|
63 | Equivalent to warn(msg,exit_val=exit_val,level=4).""" | |||
56 |
|
64 | |||
57 | warn(msg,exit_val=exit_val,level=4) |
|
65 | warn(msg,exit_val=exit_val,level=4) |
@@ -1,164 +1,164 b'' | |||||
1 | # Makefile for Sphinx documentation |
|
1 | # Makefile for Sphinx documentation | |
2 | # |
|
2 | # | |
3 |
|
3 | |||
4 | # You can set these variables from the command line. |
|
4 | # You can set these variables from the command line. | |
5 | SPHINXOPTS = |
|
5 | SPHINXOPTS = | |
6 | SPHINXBUILD = sphinx-build |
|
6 | SPHINXBUILD = sphinx-build | |
7 | PAPER = |
|
7 | PAPER = | |
8 | SRCDIR = source |
|
8 | SRCDIR = source | |
9 | BUILDDIR = build |
|
9 | BUILDDIR = build | |
10 | PYTHON = python |
|
10 | PYTHON = python | |
11 |
|
11 | |||
12 | # Internal variables. |
|
12 | # Internal variables. | |
13 | PAPEROPT_a4 = -D latex_paper_size=a4 |
|
13 | PAPEROPT_a4 = -D latex_paper_size=a4 | |
14 | PAPEROPT_letter = -D latex_paper_size=letter |
|
14 | PAPEROPT_letter = -D latex_paper_size=letter | |
15 | ALLSPHINXOPTS = -d build/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) $(SRCDIR) |
|
15 | ALLSPHINXOPTS = -d build/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) $(SRCDIR) | |
16 |
|
16 | |||
17 | .PHONY: help clean html web pickle htmlhelp latex changes linkcheck api |
|
17 | .PHONY: help clean html web pickle htmlhelp latex changes linkcheck api | |
18 |
|
18 | |||
19 | default: html |
|
19 | default: html | |
20 |
|
20 | |||
21 | help: |
|
21 | help: | |
22 | @echo "Please use \`make <target>' where <target> is one of" |
|
22 | @echo "Please use \`make <target>' where <target> is one of" | |
23 | @echo " html standalone HTML files" |
|
23 | @echo " html standalone HTML files" | |
24 | @echo " html_noapi same as above, without the time consuming API docs" |
|
24 | @echo " html_noapi same as above, without the time consuming API docs" | |
25 | @echo " pickle pickle files (usable by e.g. sphinx-web)" |
|
25 | @echo " pickle pickle files (usable by e.g. sphinx-web)" | |
26 | @echo " htmlhelp HTML files and a HTML help project" |
|
26 | @echo " htmlhelp HTML files and a HTML help project" | |
27 | @echo " latex LaTeX files, you can set PAPER=a4 or PAPER=letter" |
|
27 | @echo " latex LaTeX files, you can set PAPER=a4 or PAPER=letter" | |
28 | @echo " texinfo Texinfo files" |
|
28 | @echo " texinfo Texinfo files" | |
29 | @echo " info Texinfo files and run them through makeinfo" |
|
29 | @echo " info Texinfo files and run them through makeinfo" | |
30 | @echo " changes an overview over all changed/added/deprecated items" |
|
30 | @echo " changes an overview over all changed/added/deprecated items" | |
31 | @echo " linkcheck check all external links for integrity (takes a long time)" |
|
31 | @echo " linkcheck check all external links for integrity (takes a long time)" | |
32 | @echo " gh-pages clone IPython docs in ./gh-pages/ , build doc, autocommit" |
|
32 | @echo " gh-pages clone IPython docs in ./gh-pages/ , build doc, autocommit" | |
33 | @echo |
|
33 | @echo | |
34 | @echo "Compound utility targets:" |
|
34 | @echo "Compound utility targets:" | |
35 | @echo "pdf latex and then runs the PDF generation" |
|
35 | @echo "pdf latex and then runs the PDF generation" | |
36 | @echo "all html and pdf" |
|
36 | @echo "all html and pdf" | |
37 | @echo "dist all, and then puts the results in dist/" |
|
37 | @echo "dist all, and then puts the results in dist/" | |
38 |
|
38 | |||
39 | clean_api: |
|
39 | clean_api: | |
40 | -rm -rf $(SRCDIR)/api/generated |
|
40 | -rm -rf $(SRCDIR)/api/generated | |
41 |
|
41 | |||
42 | clean: clean_api |
|
42 | clean: clean_api | |
43 | -rm -rf build/* dist/* |
|
43 | -rm -rf build/* dist/* | |
44 | -rm -f $(SRCDIR)/config/options/config-generated.txt |
|
44 | -rm -f $(SRCDIR)/config/options/config-generated.txt | |
45 | -rm -f $(SRCDIR)/config/shortcuts/*.csv |
|
45 | -rm -f $(SRCDIR)/config/shortcuts/*.csv | |
46 | -rm -f $(SRCDIR)/interactive/magics-generated.txt |
|
46 | -rm -f $(SRCDIR)/interactive/magics-generated.txt | |
47 |
|
47 | |||
48 | pdf: latex |
|
48 | pdf: latex | |
49 | cd build/latex && make all-pdf |
|
49 | cd build/latex && make all-pdf | |
50 |
|
50 | |||
51 | all: html pdf |
|
51 | all: html pdf | |
52 |
|
52 | |||
53 | # For final distribution, only build HTML (our pdf is now so large as to be |
|
53 | # For final distribution, only build HTML (our pdf is now so large as to be | |
54 | # unusable, takes forever to build and just bloats the downloads). We leave |
|
54 | # unusable, takes forever to build and just bloats the downloads). We leave | |
55 | # them hardlinked at the top-level so users find them easily, though the |
|
55 | # them hardlinked at the top-level so users find them easily, though the | |
56 | # original build/html dir is left in-place (useful to reload builds while |
|
56 | # original build/html dir is left in-place (useful to reload builds while | |
57 | # testing). |
|
57 | # testing). | |
58 | dist: html |
|
58 | dist: html | |
59 | rm -rf html |
|
59 | rm -rf html | |
60 | cp -al build/html . |
|
60 | cp -al build/html . | |
61 | @echo "Build finished. Final docs are in html/" |
|
61 | @echo "Build finished. Final docs are in html/" | |
62 |
|
62 | |||
63 | html: api autoconfig automagic autogen_shortcuts |
|
63 | html: api autoconfig automagic autogen_shortcuts | |
64 | html_noapi: clean_api autoconfig automagic autogen_shortcuts |
|
64 | html_noapi: clean_api autoconfig automagic autogen_shortcuts | |
65 |
|
65 | |||
66 | html html_noapi: |
|
66 | html html_noapi: | |
67 | mkdir -p build/html build/doctrees |
|
67 | mkdir -p build/html build/doctrees | |
68 | $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) build/html |
|
68 | $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) build/html | |
69 | @echo |
|
69 | @echo | |
70 | @echo "Build finished. The HTML pages are in build/html." |
|
70 | @echo "Build finished. The HTML pages are in build/html." | |
71 |
|
71 | |||
72 | automagic: source/interactive/magics-generated.txt |
|
72 | automagic: source/interactive/magics-generated.txt | |
73 |
|
73 | |||
74 | source/interactive/magics-generated.txt: autogen_magics.py |
|
74 | source/interactive/magics-generated.txt: autogen_magics.py | |
75 | $(PYTHON) autogen_magics.py |
|
75 | $(PYTHON) autogen_magics.py | |
76 | @echo "Created docs for line & cell magics" |
|
76 | @echo "Created docs for line & cell magics" | |
77 |
|
77 | |||
78 | autoconfig: source/config/options/config-generated.txt |
|
78 | autoconfig: source/config/options/config-generated.txt | |
79 |
|
79 | |||
80 | source/config/options/config-generated.txt: |
|
80 | source/config/options/config-generated.txt: | |
81 | $(PYTHON) autogen_config.py |
|
81 | $(PYTHON) autogen_config.py | |
82 | @echo "Created docs for config options" |
|
82 | @echo "Created docs for config options" | |
83 |
|
83 | |||
84 | api: source/api/generated/gen.txt |
|
84 | api: source/api/generated/gen.txt | |
85 |
|
85 | |||
86 | source/api/generated/gen.txt: |
|
86 | source/api/generated/gen.txt: | |
87 | $(PYTHON) autogen_api.py |
|
87 | $(PYTHON) autogen_api.py | |
88 | @echo "Build API docs finished." |
|
88 | @echo "Build API docs finished." | |
89 |
|
89 | |||
90 | autogen_shortcuts: |
|
90 | autogen_shortcuts: autogen_shortcuts.py ../IPython/terminal/interactiveshell.py source/config/shortcuts/index.rst | |
91 | $(PYTHON) autogen_shortcuts.py |
|
91 | $(PYTHON) autogen_shortcuts.py | |
92 | @echo "Created docs for shortcuts" |
|
92 | @echo "Created docs for shortcuts" | |
93 |
|
93 | |||
94 | pickle: |
|
94 | pickle: | |
95 | mkdir -p build/pickle build/doctrees |
|
95 | mkdir -p build/pickle build/doctrees | |
96 | $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) build/pickle |
|
96 | $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) build/pickle | |
97 | @echo |
|
97 | @echo | |
98 | @echo "Build finished; now you can process the pickle files or run" |
|
98 | @echo "Build finished; now you can process the pickle files or run" | |
99 | @echo " sphinx-web build/pickle" |
|
99 | @echo " sphinx-web build/pickle" | |
100 | @echo "to start the sphinx-web server." |
|
100 | @echo "to start the sphinx-web server." | |
101 |
|
101 | |||
102 | web: pickle |
|
102 | web: pickle | |
103 |
|
103 | |||
104 | htmlhelp: |
|
104 | htmlhelp: | |
105 | mkdir -p build/htmlhelp build/doctrees |
|
105 | mkdir -p build/htmlhelp build/doctrees | |
106 | $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) build/htmlhelp |
|
106 | $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) build/htmlhelp | |
107 | @echo |
|
107 | @echo | |
108 | @echo "Build finished; now you can run HTML Help Workshop with the" \ |
|
108 | @echo "Build finished; now you can run HTML Help Workshop with the" \ | |
109 | ".hhp project file in build/htmlhelp." |
|
109 | ".hhp project file in build/htmlhelp." | |
110 |
|
110 | |||
111 | qthelp: |
|
111 | qthelp: | |
112 | mkdir -p build/qthelp |
|
112 | mkdir -p build/qthelp | |
113 | $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) build/qthelp |
|
113 | $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) build/qthelp | |
114 | @echo |
|
114 | @echo | |
115 | @echo "Build finished; now you can run "qcollectiongenerator" with the" \ |
|
115 | @echo "Build finished; now you can run "qcollectiongenerator" with the" \ | |
116 | ".qhcp project file in $(BUILDDIR)/qthelp, like this:" |
|
116 | ".qhcp project file in $(BUILDDIR)/qthelp, like this:" | |
117 | @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/IPython.qhcp" |
|
117 | @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/IPython.qhcp" | |
118 | @echo "To view the help file:" |
|
118 | @echo "To view the help file:" | |
119 | @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/IPython.qhc" |
|
119 | @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/IPython.qhc" | |
120 |
|
120 | |||
121 | latex: api autoconfig |
|
121 | latex: api autoconfig | |
122 | mkdir -p build/latex build/doctrees |
|
122 | mkdir -p build/latex build/doctrees | |
123 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) build/latex |
|
123 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) build/latex | |
124 | @echo |
|
124 | @echo | |
125 | @echo "Build finished; the LaTeX files are in build/latex." |
|
125 | @echo "Build finished; the LaTeX files are in build/latex." | |
126 | @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \ |
|
126 | @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \ | |
127 | "run these through (pdf)latex." |
|
127 | "run these through (pdf)latex." | |
128 |
|
128 | |||
129 | changes: |
|
129 | changes: | |
130 | mkdir -p build/changes build/doctrees |
|
130 | mkdir -p build/changes build/doctrees | |
131 | $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) build/changes |
|
131 | $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) build/changes | |
132 | @echo |
|
132 | @echo | |
133 | @echo "The overview file is in build/changes." |
|
133 | @echo "The overview file is in build/changes." | |
134 |
|
134 | |||
135 | linkcheck: |
|
135 | linkcheck: | |
136 | mkdir -p build/linkcheck build/doctrees |
|
136 | mkdir -p build/linkcheck build/doctrees | |
137 | $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) build/linkcheck |
|
137 | $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) build/linkcheck | |
138 | @echo |
|
138 | @echo | |
139 | @echo "Link check complete; look for any errors in the above output " \ |
|
139 | @echo "Link check complete; look for any errors in the above output " \ | |
140 | "or in build/linkcheck/output.rst." |
|
140 | "or in build/linkcheck/output.rst." | |
141 |
|
141 | |||
142 | nightly: dist |
|
142 | nightly: dist | |
143 | rsync -avH --delete dist/ ipython:www/doc/nightly |
|
143 | rsync -avH --delete dist/ ipython:www/doc/nightly | |
144 |
|
144 | |||
145 | gh-pages: clean html |
|
145 | gh-pages: clean html | |
146 | # if VERSION is unspecified, it will be dev |
|
146 | # if VERSION is unspecified, it will be dev | |
147 | # For releases, VERSION should be just the major version, |
|
147 | # For releases, VERSION should be just the major version, | |
148 | # e.g. VERSION=2 make gh-pages |
|
148 | # e.g. VERSION=2 make gh-pages | |
149 | $(PYTHON) gh-pages.py $(VERSION) |
|
149 | $(PYTHON) gh-pages.py $(VERSION) | |
150 |
|
150 | |||
151 | texinfo: |
|
151 | texinfo: | |
152 | mkdir -p $(BUILDDIR)/texinfo |
|
152 | mkdir -p $(BUILDDIR)/texinfo | |
153 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo |
|
153 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo | |
154 | @echo |
|
154 | @echo | |
155 | @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." |
|
155 | @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." | |
156 | @echo "Run \`make' in that directory to run these through makeinfo" \ |
|
156 | @echo "Run \`make' in that directory to run these through makeinfo" \ | |
157 | "(use \`make info' here to do that automatically)." |
|
157 | "(use \`make info' here to do that automatically)." | |
158 |
|
158 | |||
159 | info: |
|
159 | info: | |
160 | mkdir -p $(BUILDDIR)/texinfo |
|
160 | mkdir -p $(BUILDDIR)/texinfo | |
161 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo |
|
161 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo | |
162 | @echo "Running Texinfo files through makeinfo..." |
|
162 | @echo "Running Texinfo files through makeinfo..." | |
163 | make -C $(BUILDDIR)/texinfo info |
|
163 | make -C $(BUILDDIR)/texinfo info | |
164 | @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." |
|
164 | @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." |
@@ -1,75 +1,77 b'' | |||||
1 | #!/usr/bin/env python |
|
1 | #!/usr/bin/env python | |
2 | """Script to auto-generate our API docs. |
|
2 | """Script to auto-generate our API docs. | |
3 | """ |
|
3 | """ | |
4 |
|
4 | |||
5 | import os |
|
5 | import os | |
6 | import sys |
|
6 | import sys | |
7 |
|
7 | |||
8 | pjoin = os.path.join |
|
8 | pjoin = os.path.join | |
9 |
|
9 | |||
10 | here = os.path.abspath(os.path.dirname(__file__)) |
|
10 | here = os.path.abspath(os.path.dirname(__file__)) | |
11 | sys.path.append(pjoin(os.path.abspath(here), 'sphinxext')) |
|
11 | sys.path.append(pjoin(os.path.abspath(here), 'sphinxext')) | |
12 |
|
12 | |||
13 | from apigen import ApiDocWriter |
|
13 | from apigen import ApiDocWriter | |
14 |
|
14 | |||
15 | source = pjoin(here, 'source') |
|
15 | source = pjoin(here, 'source') | |
16 |
|
16 | |||
17 | #***************************************************************************** |
|
17 | #***************************************************************************** | |
18 | if __name__ == '__main__': |
|
18 | if __name__ == '__main__': | |
19 | package = 'IPython' |
|
19 | package = 'IPython' | |
20 | outdir = pjoin(source, 'api', 'generated') |
|
20 | outdir = pjoin(source, 'api', 'generated') | |
21 | docwriter = ApiDocWriter(package,rst_extension='.rst') |
|
21 | docwriter = ApiDocWriter(package,rst_extension='.rst') | |
22 | # You have to escape the . here because . is a special char for regexps. |
|
22 | # You have to escape the . here because . is a special char for regexps. | |
23 | # You must do make clean if you change this! |
|
23 | # You must do make clean if you change this! | |
24 | docwriter.package_skip_patterns += [r'\.external$', |
|
24 | docwriter.package_skip_patterns += [r'\.external$', | |
25 | # Extensions are documented elsewhere. |
|
25 | # Extensions are documented elsewhere. | |
26 | r'\.extensions', |
|
26 | r'\.extensions', | |
27 | # Magics are documented separately |
|
27 | # Magics are documented separately | |
28 | r'\.core\.magics', |
|
28 | r'\.core\.magics', | |
29 | # This isn't API |
|
29 | # This isn't API | |
30 | r'\.sphinxext', |
|
30 | r'\.sphinxext', | |
31 | # Shims |
|
31 | # Shims | |
32 | r'\.kernel', |
|
32 | r'\.kernel', | |
33 | r'\.terminal\.pt_inputhooks', |
|
33 | r'\.terminal\.pt_inputhooks', | |
34 | ] |
|
34 | ] | |
35 |
|
35 | |||
36 | # The inputhook* modules often cause problems on import, such as trying to |
|
36 | # The inputhook* modules often cause problems on import, such as trying to | |
37 | # load incompatible Qt bindings. It's easiest to leave them all out. The |
|
37 | # load incompatible Qt bindings. It's easiest to leave them all out. The | |
38 | docwriter.module_skip_patterns += [ r'\.lib\.inputhook.+', |
|
38 | docwriter.module_skip_patterns += [ r'\.lib\.inputhook.+', | |
39 | r'\.ipdoctest', |
|
39 | r'\.ipdoctest', | |
40 | r'\.testing\.plugin', |
|
40 | r'\.testing\.plugin', | |
41 | # Backwards compat import for lib.lexers |
|
41 | # Backwards compat import for lib.lexers | |
42 | r'\.nbconvert\.utils\.lexers', |
|
42 | r'\.nbconvert\.utils\.lexers', | |
43 | # We document this manually. |
|
43 | # We document this manually. | |
44 | r'\.utils\.py3compat', |
|
44 | r'\.utils\.py3compat', | |
45 | # These are exposed in display |
|
45 | # These are exposed in display | |
46 | r'\.core\.display', |
|
46 | r'\.core\.display', | |
47 | r'\.lib\.display', |
|
47 | r'\.lib\.display', | |
48 | # Shims |
|
48 | # Shims | |
49 | r'\.config', |
|
49 | r'\.config', | |
50 | r'\.consoleapp', |
|
50 | r'\.consoleapp', | |
51 | r'\.frontend$', |
|
51 | r'\.frontend$', | |
52 | r'\.html', |
|
52 | r'\.html', | |
53 | r'\.nbconvert', |
|
53 | r'\.nbconvert', | |
54 | r'\.nbformat', |
|
54 | r'\.nbformat', | |
55 | r'\.parallel', |
|
55 | r'\.parallel', | |
56 | r'\.qt', |
|
56 | r'\.qt', | |
|
57 | # this is deprecated. | |||
|
58 | r'\.utils\.warn', | |||
57 | ] |
|
59 | ] | |
58 | # main API is in the inputhook module, which is documented. |
|
60 | # main API is in the inputhook module, which is documented. | |
59 |
|
61 | |||
60 | # These modules import functions and classes from other places to expose |
|
62 | # These modules import functions and classes from other places to expose | |
61 | # them as part of the public API. They must have __all__ defined. The |
|
63 | # them as part of the public API. They must have __all__ defined. The | |
62 | # non-API modules they import from should be excluded by the skip patterns |
|
64 | # non-API modules they import from should be excluded by the skip patterns | |
63 | # above. |
|
65 | # above. | |
64 | docwriter.names_from__all__.update({ |
|
66 | docwriter.names_from__all__.update({ | |
65 | 'IPython.display', |
|
67 | 'IPython.display', | |
66 | }) |
|
68 | }) | |
67 |
|
69 | |||
68 | # Now, generate the outputs |
|
70 | # Now, generate the outputs | |
69 | docwriter.write_api_docs(outdir) |
|
71 | docwriter.write_api_docs(outdir) | |
70 | # Write index with .txt extension - we can include it, but Sphinx won't try |
|
72 | # Write index with .txt extension - we can include it, but Sphinx won't try | |
71 | # to compile it |
|
73 | # to compile it | |
72 | docwriter.write_index(outdir, 'gen.txt', |
|
74 | docwriter.write_index(outdir, 'gen.txt', | |
73 | relative_to = pjoin(source, 'api') |
|
75 | relative_to = pjoin(source, 'api') | |
74 | ) |
|
76 | ) | |
75 | print ('%d files written' % len(docwriter.written_modules)) |
|
77 | print ('%d files written' % len(docwriter.written_modules)) |
@@ -1,83 +1,85 b'' | |||||
1 | from os.path import abspath, dirname, join |
|
1 | from os.path import abspath, dirname, join | |
2 |
|
2 | |||
3 | from IPython.terminal.interactiveshell import KeyBindingManager |
|
3 | from IPython.terminal.interactiveshell import KeyBindingManager | |
4 |
|
4 | |||
5 |
|
5 | |||
6 | def name(c): |
|
6 | def name(c): | |
7 | s = c.__class__.__name__ |
|
7 | s = c.__class__.__name__ | |
|
8 | if s == '_Invert': | |||
|
9 | return '(Not: %s)' % name(c.filter) | |||
|
10 | if s in log_filters.keys(): | |||
|
11 | return '(%s: %s)' % (log_filters[s], ', '.join(name(x) for x in c.filters)) | |||
8 | return log_filters[s] if s in log_filters.keys() else s |
|
12 | return log_filters[s] if s in log_filters.keys() else s | |
9 |
|
13 | |||
10 |
|
14 | |||
11 | def sentencize(s): |
|
15 | def sentencize(s): | |
12 | """Extract first sentence |
|
16 | """Extract first sentence | |
13 | """ |
|
17 | """ | |
14 | s = s.replace('\n', ' ').strip().split('.') |
|
18 | s = s.replace('\n', ' ').strip().split('.') | |
15 | s = s[0] if len(s) else s |
|
19 | s = s[0] if len(s) else s | |
16 | try: |
|
20 | try: | |
17 | return " ".join(s.split()) |
|
21 | return " ".join(s.split()) | |
18 | except AttributeError: |
|
22 | except AttributeError: | |
19 | return s |
|
23 | return s | |
20 |
|
24 | |||
21 |
|
25 | |||
22 | def most_common(lst, n=3): |
|
26 | def most_common(lst, n=3): | |
23 | """Most common elements occurring more then `n` times |
|
27 | """Most common elements occurring more then `n` times | |
24 | """ |
|
28 | """ | |
25 | from collections import Counter |
|
29 | from collections import Counter | |
26 |
|
30 | |||
27 | c = Counter(lst) |
|
31 | c = Counter(lst) | |
28 | return [k for (k, v) in c.items() if k and v > n] |
|
32 | return [k for (k, v) in c.items() if k and v > n] | |
29 |
|
33 | |||
30 |
|
34 | |||
31 | def multi_filter_str(flt): |
|
35 | def multi_filter_str(flt): | |
32 | """Yield readable conditional filter |
|
36 | """Yield readable conditional filter | |
33 | """ |
|
37 | """ | |
34 | assert hasattr(flt, 'filters'), 'Conditional filter required' |
|
38 | assert hasattr(flt, 'filters'), 'Conditional filter required' | |
35 |
|
||||
36 | yield name(flt) |
|
39 | yield name(flt) | |
37 | for subfilter in flt.filters: |
|
|||
38 | yield name(subfilter) |
|
|||
39 | if hasattr(subfilter, 'filter'): |
|
|||
40 | yield name(subfilter.filter) |
|
|||
41 |
|
40 | |||
42 |
|
41 | |||
43 |
log_filters = dict(_AndList=' |
|
42 | log_filters = dict(_AndList='And', _OrList='Or') | |
|
43 | log_invert = {'_Invert'} | |||
44 |
|
44 | |||
45 | kbm = KeyBindingManager.for_prompt() |
|
45 | kbm = KeyBindingManager.for_prompt() | |
46 | ipy_bindings = kbm.registry.key_bindings |
|
46 | ipy_bindings = kbm.registry.key_bindings | |
47 |
|
47 | |||
48 | dummy_docs = [] # ignore bindings without proper documentation |
|
48 | dummy_docs = [] # ignore bindings without proper documentation | |
49 |
|
49 | |||
50 | common_docs = most_common([kb.handler.__doc__ for kb in ipy_bindings]) |
|
50 | common_docs = most_common([kb.handler.__doc__ for kb in ipy_bindings]) | |
51 | if common_docs: |
|
51 | if common_docs: | |
52 | dummy_docs.extend(common_docs) |
|
52 | dummy_docs.extend(common_docs) | |
53 |
|
53 | |||
54 | dummy_docs = list(set(dummy_docs)) |
|
54 | dummy_docs = list(set(dummy_docs)) | |
55 |
|
55 | |||
56 | single_filter = dict() |
|
56 | single_filter = dict() | |
57 | multi_filter = dict() |
|
57 | multi_filter = dict() | |
58 | for kb in ipy_bindings: |
|
58 | for kb in ipy_bindings: | |
59 | doc = kb.handler.__doc__ |
|
59 | doc = kb.handler.__doc__ | |
60 | if not doc or doc in dummy_docs: |
|
60 | if not doc or doc in dummy_docs: | |
61 | continue |
|
61 | continue | |
62 |
|
62 | |||
63 | shortcut = ' '.join([k if isinstance(k, str) else k.name for k in kb.keys]) |
|
63 | shortcut = ' '.join([k if isinstance(k, str) else k.name for k in kb.keys]) | |
64 | shortcut += shortcut.endswith('\\') and '\\' or '' |
|
64 | shortcut += shortcut.endswith('\\') and '\\' or '' | |
65 | if hasattr(kb.filter, 'filters'): |
|
65 | if hasattr(kb.filter, 'filters'): | |
66 | flt = ' '.join(multi_filter_str(kb.filter)) |
|
66 | flt = ' '.join(multi_filter_str(kb.filter)) | |
67 | multi_filter[(shortcut, flt)] = sentencize(doc) |
|
67 | multi_filter[(shortcut, flt)] = sentencize(doc) | |
68 | else: |
|
68 | else: | |
69 | single_filter[(shortcut, name(kb.filter))] = sentencize(doc) |
|
69 | single_filter[(shortcut, name(kb.filter))] = sentencize(doc) | |
70 |
|
70 | |||
71 |
|
71 | |||
72 | if __name__ == '__main__': |
|
72 | if __name__ == '__main__': | |
73 |
|
73 | |||
|
74 | sort_key = lambda k:(str(k[0][1]),str(k[0][0])) | |||
|
75 | ||||
74 | here = abspath(dirname(__file__)) |
|
76 | here = abspath(dirname(__file__)) | |
75 | dest = join(here, 'source', 'config', 'shortcuts') |
|
77 | dest = join(here, 'source', 'config', 'shortcuts') | |
76 |
|
78 | |||
77 | with open(join(dest, 'single_filtered.csv'), 'w') as csv: |
|
79 | with open(join(dest, 'single_filtered.csv'), 'w') as csv: | |
78 | for k, v in sorted(single_filter.items()): |
|
80 | for k, v in sorted(single_filter.items(), key=sort_key): | |
79 | csv.write(':kbd:`{}`\t{}\t{}\n'.format(k[0], k[1], v)) |
|
81 | csv.write(':kbd:`{}`\t{}\t{}\n'.format(k[0], k[1], v)) | |
80 |
|
82 | |||
81 | with open(join(dest, 'multi_filtered.csv'), 'w') as csv: |
|
83 | with open(join(dest, 'multi_filtered.csv'), 'w') as csv: | |
82 | for k, v in sorted(multi_filter.items()): |
|
84 | for k, v in sorted(multi_filter.items(), key=sort_key): | |
83 | csv.write(':kbd:`{}`\t{}\t{}\n'.format(k[0], k[1], v)) |
|
85 | csv.write(':kbd:`{}`\t{}\t{}\n'.format(k[0], k[1], v)) |
@@ -1,25 +1,31 b'' | |||||
1 | ================= |
|
1 | ================= | |
2 | IPython shortcuts |
|
2 | IPython shortcuts | |
3 | ================= |
|
3 | ================= | |
4 |
|
4 | |||
5 | Available shortcut in IPython terminal. |
|
5 | Available shortcut in IPython terminal. | |
6 |
|
6 | |||
|
7 | .. warning:: | |||
|
8 | ||||
|
9 | This list is automatically generated, and may not hold all the available | |||
|
10 | shortcut. In particular, it may depends on the version of ``prompt_toolkit`` | |||
|
11 | installed during the generation of this page. | |||
|
12 | ||||
7 |
|
13 | |||
8 | Single Filtered shortcuts |
|
14 | Single Filtered shortcuts | |
9 | ========================= |
|
15 | ========================= | |
10 |
|
16 | |||
11 | .. csv-table:: |
|
17 | .. csv-table:: | |
12 | :header: Shortcut,Filter,Description |
|
18 | :header: Shortcut,Filter,Description | |
13 | :widths: 30, 30, 100 |
|
19 | :widths: 30, 30, 100 | |
14 | :delim: tab |
|
20 | :delim: tab | |
15 | :file: single_filtered.csv |
|
21 | :file: single_filtered.csv | |
16 |
|
22 | |||
17 |
|
23 | |||
18 | Multi Filtered shortcuts |
|
24 | Multi Filtered shortcuts | |
19 | ========================= |
|
25 | ========================= | |
20 |
|
26 | |||
21 | .. csv-table:: |
|
27 | .. csv-table:: | |
22 | :header: Shortcut,Filter,Description |
|
28 | :header: Shortcut,Filter,Description | |
23 | :widths: 30, 30, 100 |
|
29 | :widths: 30, 30, 100 | |
24 | :delim: tab |
|
30 | :delim: tab | |
25 | :file: multi_filtered.csv |
|
31 | :file: multi_filtered.csv |
General Comments 0
You need to be logged in to leave comments.
Login now