diff --git a/docstring_to_markdown/rst.py b/docstring_to_markdown/rst.py index 40b42f0..d960862 100644 --- a/docstring_to_markdown/rst.py +++ b/docstring_to_markdown/rst.py @@ -598,9 +598,9 @@ def flush_buffer(): # lists handling: items detection # this one does NOT allow spaces on the left hand side (to avoid false positive matches) - match = re.match(r'^(?P[^:\s]+) : (?P.+)$', trimmed_line) + match = re.match(r'^(?P\s*)(?P[^:\s]+) : (?P.+)$', line) if match: - line = '- `' + match.group('argument') + '`: ' + match.group('type') + '' + line = match.group('indent') + '- `' + match.group('argument') + '`: ' + match.group('type') + '' else: if most_recent_section in SECTION_DIRECTIVES: for section_directive in SECTION_DIRECTIVES[most_recent_section]: diff --git a/tests/test_rst.py b/tests/test_rst.py index b6d171c..4a85c6d 100644 --- a/tests/test_rst.py +++ b/tests/test_rst.py @@ -568,6 +568,46 @@ def func(): pass will be represented by a ``cv_results_`` dict """ + +NESTED_PARAMETERS = """ +Parameters +---------- +transformers : list of tuples + List of (name, transformer, columns) tuples. + name : str + Like in Pipeline and FeatureUnion, this allows the transformer and + search. + transformer : {'drop', 'passthrough'} or estimator + Estimator must support :term:`fit` and :term:`transform`. + columns : str, array-like of str, int, array-like of int, \ + array-like of bool, slice or callable + Indexes the data on its second axis. Integers are interpreted as + above. To select multiple columns by name or dtype, you can use + :obj:`make_column_selector`. +remainder : {'drop', 'passthrough'} or estimator, default='drop' + By default, only the specified columns in `transformers` are +""" + +NESTED_PARAMETERS_MARKDOWN = """ +#### Parameters + +- `transformers`: list of tuples + List of (name, transformer, columns) tuples. + - `name`: str + Like in Pipeline and FeatureUnion, this allows the transformer and + search. + - `transformer`: {'drop', 'passthrough'} or estimator + Estimator must support `fit` and `transform`. + - `columns`: str, array-like of str, int, array-like of int, \ + array-like of bool, slice or callable + Indexes the data on its second axis. Integers are interpreted as + above. To select multiple columns by name or dtype, you can use + `make_column_selector`. +- `remainder`: {'drop', 'passthrough'} or estimator, default='drop' + By default, only the specified columns in `transformers` are +""" + + INTEGRATION = """ Return a fixed frequency DatetimeIndex. @@ -702,6 +742,10 @@ def func(): pass 'converts indented grid table': { 'rst': GRID_TABLE_IN_SKLEARN, 'md': GRID_TABLE_IN_SKLEARN_MARKDOWN + }, + 'converts nested parameter lists': { + 'rst': NESTED_PARAMETERS, + 'md': NESTED_PARAMETERS_MARKDOWN } }