Skip to content

Commit

Permalink
Merge pull request #12604 from digitalvirtuoso/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Carreau committed Oct 13, 2020
2 parents 887e93e + 7eded0e commit 44d4746
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions docs/autogen_magics.py
@@ -1,4 +1,3 @@
import os
from pathlib import Path
from IPython.core.alias import Alias
from IPython.core.interactiveshell import InteractiveShell
Expand All @@ -10,7 +9,7 @@

def _strip_underline(line):
chars = set(line.strip())
if len(chars) == 1 and ('-' in chars or '=' in chars):
if len(chars) == 1 and ("-" in chars or "=" in chars):
return ""
else:
return line
Expand All @@ -32,7 +31,7 @@ def format_docstring(func):
# Case insensitive sort by name
def sortkey(s): return s[0].lower()

for name, func in sorted(magics['line'].items(), key=sortkey):
for name, func in sorted(magics["line"].items(), key=sortkey):
if isinstance(func, Alias) or isinstance(func, MagicAlias):
# Aliases are magics, but shouldn't be documented here
# Also skip aliases to other magics
Expand All @@ -48,11 +47,11 @@ def sortkey(s): return s[0].lower()
"",
])

for name, func in sorted(magics['cell'].items(), key=sortkey):
for name, func in sorted(magics["cell"].items(), key=sortkey):
if name == "!":
# Special case - don't encourage people to use %%!
continue
if func == magics['line'].get(name, 'QQQP'):
if func == magics["line"].get(name, "QQQP"):
# Don't redocument line magics that double as cell magics
continue
if isinstance(func, MagicAlias):
Expand All @@ -62,6 +61,6 @@ def sortkey(s): return s[0].lower()
format_docstring(func),
""])

here = os.path.dirname(__file__)
dest = Path(os.path.join(here, "source", "interactive", "magics-generated.txt"))
src_path = Path(__file__).parent
dest = src_path.joinpath("source", "interactive", "magics-generated.txt")
dest.write_text("\n".join(output))

0 comments on commit 44d4746

Please sign in to comment.