Skip to content

Commit

Permalink
MAINT: minor refactoring in docscrape (#297)
Browse files Browse the repository at this point in the history
* MAINT: rm unnecessary elses in _str methods

* rm unused indent method from NDS

* rm unused header method from NDS
  • Loading branch information
rossbar committed Aug 19, 2020
1 parent 20d9d98 commit 121c327
Showing 1 changed file with 5 additions and 24 deletions.
29 changes: 5 additions & 24 deletions numpydoc/docscrape.py
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

0 comments on commit 121c327

Please sign in to comment.