File: generate_help.py

package info (click to toggle)
metakernel 0.27.5-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 1,280 kB
  • sloc: python: 5,018; makefile: 207; sh: 27
file content (33 lines) | stat: -rw-r--r-- 887 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from __future__ import print_function
import sys

from metakernel_python import MetaKernelPython

kernel = MetaKernelPython()

path = "metakernel/magics/README.md"

with open(path) as fid:
    prev = fid.read()

print("Generating README.md...")
prefix = kernel.magic_prefixes['magic']
text = "# Line Magics\n\n"
for magic in sorted(kernel.line_magics.keys()):
    text += "## `" + prefix + magic + "`\n\n"
    text += kernel.get_help_on(prefix + magic) + "\n\n"

text += "# Cell Magics\n\n"
for magic in sorted(kernel.cell_magics.keys()):
    text += "## `" + prefix + prefix + magic + "`\n\n"
    text += kernel.get_help_on(prefix + prefix + magic) + "\n\n"

with open(path, 'w') as fid:
    fid.write(text)

print("done!")

if text != prev:
    print('Readme changed, please commit the changes')
    print('If this is on Travis, run `make help` locally to regenerate')
    sys.exit(1)