Show More
@@ -1,4 +1,3 b'' | |||||
1 | import os |
|
|||
2 |
|
|
1 | from pathlib import Path | |
3 | from IPython.core.alias import Alias |
|
2 | from IPython.core.alias import Alias | |
4 | from IPython.core.interactiveshell import InteractiveShell |
|
3 | from IPython.core.interactiveshell import InteractiveShell | |
@@ -10,7 +9,7 b' magics = shell.magics_manager.magics' | |||||
10 |
|
9 | |||
11 | def _strip_underline(line): |
|
10 | def _strip_underline(line): | |
12 | chars = set(line.strip()) |
|
11 | chars = set(line.strip()) | |
13 |
if len(chars) == 1 and ( |
|
12 | if len(chars) == 1 and ("-" in chars or "=" in chars): | |
14 | return "" |
|
13 | return "" | |
15 | else: |
|
14 | else: | |
16 | return line |
|
15 | return line | |
@@ -32,7 +31,7 b' output = [' | |||||
32 | # Case insensitive sort by name |
|
31 | # Case insensitive sort by name | |
33 | def sortkey(s): return s[0].lower() |
|
32 | def sortkey(s): return s[0].lower() | |
34 |
|
33 | |||
35 |
for name, func in sorted(magics[ |
|
34 | for name, func in sorted(magics["line"].items(), key=sortkey): | |
36 | if isinstance(func, Alias) or isinstance(func, MagicAlias): |
|
35 | if isinstance(func, Alias) or isinstance(func, MagicAlias): | |
37 | # Aliases are magics, but shouldn't be documented here |
|
36 | # Aliases are magics, but shouldn't be documented here | |
38 | # Also skip aliases to other magics |
|
37 | # Also skip aliases to other magics | |
@@ -48,11 +47,11 b' output.extend([' | |||||
48 | "", |
|
47 | "", | |
49 | ]) |
|
48 | ]) | |
50 |
|
49 | |||
51 |
for name, func in sorted(magics[ |
|
50 | for name, func in sorted(magics["cell"].items(), key=sortkey): | |
52 | if name == "!": |
|
51 | if name == "!": | |
53 | # Special case - don't encourage people to use %%! |
|
52 | # Special case - don't encourage people to use %%! | |
54 | continue |
|
53 | continue | |
55 |
if func == magics[ |
|
54 | if func == magics["line"].get(name, "QQQP"): | |
56 | # Don't redocument line magics that double as cell magics |
|
55 | # Don't redocument line magics that double as cell magics | |
57 | continue |
|
56 | continue | |
58 | if isinstance(func, MagicAlias): |
|
57 | if isinstance(func, MagicAlias): | |
@@ -62,6 +61,6 b" for name, func in sorted(magics['cell'].items(), key=sortkey):" | |||||
62 | format_docstring(func), |
|
61 | format_docstring(func), | |
63 | ""]) |
|
62 | ""]) | |
64 |
|
63 | |||
65 | here = os.path.dirname(__file__) |
|
64 | src_path = Path(__file__).parent | |
66 |
dest = |
|
65 | dest = src_path.joinpath("source", "interactive", "magics-generated.txt") | |
67 | dest.write_text("\n".join(output)) |
|
66 | dest.write_text("\n".join(output)) |
General Comments 0
You need to be logged in to leave comments.
Login now