Skip to content

MAINT: minor refactoring in docscrape #297

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 19, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 5 additions & 24 deletions numpydoc/docscrape.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,28 +431,22 @@ def _str_header(self, name, symbol='-'):
return [name, len(name)*symbol]

def _str_indent(self, doc, indent=4):
out = []
for line in doc:
out += [' '*indent + line]
return out
return [' '*indent + line for line in doc]

def _str_signature(self):
if self['Signature']:
return [self['Signature'].replace('*', r'\*')] + ['']
else:
return ['']
return ['']

def _str_summary(self):
if self['Summary']:
return self['Summary'] + ['']
else:
return []
return []

def _str_extended_summary(self):
if self['Extended Summary']:
return self['Extended Summary'] + ['']
else:
return []
return []

def _str_param_list(self, name):
out = []
Expand Down Expand Up @@ -525,8 +519,7 @@ def _str_index(self):
out += [' :%s: %s' % (section, ', '.join(references))]
if output_index:
return out
else:
return ''
return ''

def __str__(self, func_role=''):
out = []
Expand All @@ -546,23 +539,11 @@ def __str__(self, func_role=''):
return '\n'.join(out)


def indent(str, indent=4):
indent_str = ' '*indent
if str is None:
return indent_str
lines = str.split('\n')
return '\n'.join(indent_str + l for l in lines)


def dedent_lines(lines):
"""Deindent a list of lines maximally"""
return textwrap.dedent("\n".join(lines)).split("\n")


def header(text, style='-'):
return text + '\n' + style*len(text) + '\n'


class FunctionDoc(NumpyDocString):
def __init__(self, func, role='func', doc=None, config={}):
self._f = func
Expand Down