From d76811778334473274701a40b1f846146d0f92d1 2018-10-28 18:49:30 From: Antony Lee Date: 2018-10-28 18:49:30 Subject: [PATCH] Use inspect.cleandoc in autogen_config. ... instead of a custom implementation of the same thing. --- diff --git a/docs/autogen_config.py b/docs/autogen_config.py index e8af5f2..515e092 100755 --- a/docs/autogen_config.py +++ b/docs/autogen_config.py @@ -1,6 +1,7 @@ #!/usr/bin/env python from os.path import join, dirname, abspath +import inspect from IPython.terminal.ipapp import TerminalIPythonApp from ipykernel.kernelapp import IPKernelApp @@ -14,33 +15,6 @@ generated = join(options, 'config-generated.txt') import textwrap indent = lambda text,n: textwrap.indent(text,n*' ') -def dedent(text): - """Equivalent of textwrap.dedent that ignores unindented first line. - - This means it will still dedent strings like: - '''foo - is a bar - ''' - - For use in wrap_paragraphs. - """ - - if text.startswith('\n'): - # text starts with blank line, don't ignore the first line - return textwrap.dedent(text) - - # split first line - splits = text.split('\n',1) - if len(splits) == 1: - # only one line - return textwrap.dedent(text) - - first, rest = splits - # dedent everything but the first line - rest = textwrap.dedent(rest) - return '\n'.join([first, rest]) - - def interesting_default_value(dv): if (dv is None) or (dv is Undefined): @@ -72,7 +46,7 @@ def class_config_rst_doc(cls, trait_aliases): ] help = trait.help.rstrip() or 'No description' - lines.append(indent(dedent(help), 4) + '\n') + lines.append(indent(inspect.cleandoc(help), 4) + '\n') # Choices or type if 'Enum' in ttype: