From ca2450ab8b18dc403045b68de79f2319e938e2e7 Mon Sep 17 00:00:00 2001 From: Mikhail Golubev Date: Thu, 19 Nov 2015 17:38:40 +0300 Subject: [PATCH] PY-17686 Patch our version of Napoleon to escape "*" in parameter names the same way it's done for Google code style docstrings --- python/helpers/sphinxcontrib/napoleon/docstring.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/python/helpers/sphinxcontrib/napoleon/docstring.py b/python/helpers/sphinxcontrib/napoleon/docstring.py index 400c24925205..e4694ac8419b 100644 --- a/python/helpers/sphinxcontrib/napoleon/docstring.py +++ b/python/helpers/sphinxcontrib/napoleon/docstring.py @@ -8,11 +8,10 @@ import collections import inspect import re import sys +from six.moves import range from pockets import modify_iter from six import string_types -from six.moves import range - _directive_regex = re.compile(r'\.\. \S+::') _google_section_regex = re.compile(r'^(\s|\w)+:\s*$') @@ -774,6 +773,12 @@ class NumpyDocstring(GoogleDocstring): _name, _type = _name.strip(), _type.strip() if prefer_type and not _type: _type, _name = _name, _type + + if _name[:2] == '**': + _name = r'\*\*'+_name[2:] + elif _name[:1] == '*': + _name = r'\*'+_name[1:] + indent = self._get_indent(line) _desc = self._dedent(self._consume_indented_block(indent + 1)) _desc = self.__class__(_desc, self._config).lines()