From 45302e140eb6f074656414a8e7fe7a844223b942 Mon Sep 17 00:00:00 2001 From: Scott Sanderson Date: Mon, 22 Aug 2016 12:58:55 -0400 Subject: [PATCH 1/2] DOC: Fix docs formatting for sharedoc. The first line of indentation was incorrect. --- zipline/utils/sharedoc.py | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/zipline/utils/sharedoc.py b/zipline/utils/sharedoc.py index 8ba028c6..12ced172 100644 --- a/zipline/utils/sharedoc.py +++ b/zipline/utils/sharedoc.py @@ -11,17 +11,24 @@ PIPELINE_DOWNSAMPLING_FREQUENCY_DOC = dedent( frequency : {'year_start', 'quarter_start', 'month_start', 'week_start'} A string indicating desired sampling dates: - 'year_start' -> first trading day of each year - 'quarter_start' -> first trading day of January, April, July, October - 'month_start' -> first trading day of each month - 'week_start' -> first trading_day of each week + * 'year_start' -> first trading day of each year + * 'quarter_start' -> first trading day of January, April, July, October + * 'month_start' -> first trading day of each month + * 'week_start' -> first trading_day of each week """ ) -def pad_lines(prefix, s): - """Apply a prefix to each line in s.""" - return '\n'.join(prefix + line for line in s.splitlines()) +def _gen_for_pad_lines_after_first(prefix, s): + lines = iter(s.splitlines()) + yield next(lines) + for line in lines: + yield prefix + line + + +def pad_lines_after_first(prefix, s): + """Apply a prefix to each line in s after the first.""" + return '\n'.join(_gen_for_pad_lines_after_first(prefix, s)) def format_docstring(owner_name, docstring, formatters): @@ -66,7 +73,10 @@ def format_docstring(owner_name, docstring, formatters): ) (leading_whitespace, _) = matches[0] - format_params[target] = pad_lines(leading_whitespace, doc_for_target) + format_params[target] = pad_lines_after_first( + leading_whitespace, + doc_for_target, + ) return docstring.format(**format_params) From 346a58604e1f9a63b07dd5931e7a1b41d7f91cac Mon Sep 17 00:00:00 2001 From: Scott Sanderson Date: Mon, 22 Aug 2016 13:14:31 -0400 Subject: [PATCH 2/2] MAINT: Simpler impl of `pad_lines_after_first`. --- zipline/utils/sharedoc.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/zipline/utils/sharedoc.py b/zipline/utils/sharedoc.py index 12ced172..9669366c 100644 --- a/zipline/utils/sharedoc.py +++ b/zipline/utils/sharedoc.py @@ -19,16 +19,9 @@ PIPELINE_DOWNSAMPLING_FREQUENCY_DOC = dedent( ) -def _gen_for_pad_lines_after_first(prefix, s): - lines = iter(s.splitlines()) - yield next(lines) - for line in lines: - yield prefix + line - - def pad_lines_after_first(prefix, s): """Apply a prefix to each line in s after the first.""" - return '\n'.join(_gen_for_pad_lines_after_first(prefix, s)) + return ('\n' + prefix).join(s.splitlines()) def format_docstring(owner_name, docstring, formatters):