autogen_config.py
33 lines
| 1.0 KiB
| text/x-python
|
PythonLexer
/ docs / autogen_config.py
Yaroslav Halchenko
|
r16197 | #!/usr/bin/env python | ||
Min RK
|
r21590 | from os.path import join, dirname, abspath | ||
Thomas Kluyver
|
r13459 | from IPython.terminal.ipapp import TerminalIPythonApp | ||
Thomas Kluyver
|
r21400 | from ipykernel.kernelapp import IPKernelApp | ||
Thomas Kluyver
|
r13459 | |||
Min RK
|
r21590 | here = abspath(dirname(__file__)) | ||
options = join(here, 'source', 'config', 'options') | ||||
klonuo
|
r22516 | generated = join(options, 'config-generated.txt') | ||
Min RK
|
r21590 | |||
Thomas Kluyver
|
r21400 | def write_doc(name, title, app, preamble=None): | ||
Thomas Kluyver
|
r22615 | filename = join(options, name+'.rst') | ||
with open(filename, 'w') as f: | ||||
Thomas Kluyver
|
r13459 | f.write(title + '\n') | ||
f.write(('=' * len(title)) + '\n') | ||||
f.write('\n') | ||||
if preamble is not None: | ||||
f.write(preamble + '\n\n') | ||||
Thomas Kluyver
|
r21400 | f.write(app.document_config_options()) | ||
Yaroslav Halchenko
|
r16197 | |||
Thomas Kluyver
|
r13459 | |||
if __name__ == '__main__': | ||||
Thomas Kluyver
|
r22615 | # Touch this file for the make target | ||
klonuo
|
r22516 | with open(generated, 'w'): | ||
pass | ||||
Yaroslav Halchenko
|
r16197 | |||
Thomas Kluyver
|
r21400 | write_doc('terminal', 'Terminal IPython options', TerminalIPythonApp()) | ||
write_doc('kernel', 'IPython kernel options', IPKernelApp(), | ||||
preamble=("These options can be used in :file:`ipython_kernel_config.py`. " | ||||
"The kernel also respects any options in `ipython_config.py`"), | ||||
MinRK
|
r18030 | ) | ||