diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2020-05-03 01:59:47 +0900 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2020-05-03 01:59:47 +0900 |
commit | 1ba671a6771be858078207d5d8848f7962417b07 (patch) | |
tree | 2f8fc8027b2d542c3958b9bb88c6c0de226cfda4 /sphinx/util/docstrings.py | |
parent | daed2ec1ae2e51ca090b8d04ddd6a249fb308eb3 (diff) | |
download | sphinx-git-1ba671a6771be858078207d5d8848f7962417b07.tar.gz |
Deprecate ignore parameter for Documenter.get_doc()
Diffstat (limited to 'sphinx/util/docstrings.py')
-rw-r--r-- | sphinx/util/docstrings.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/sphinx/util/docstrings.py b/sphinx/util/docstrings.py index 7b3f011d1..64fdbf1d7 100644 --- a/sphinx/util/docstrings.py +++ b/sphinx/util/docstrings.py @@ -10,10 +10,13 @@ import re import sys +import warnings from typing import Dict, List from docutils.parsers.rst.states import Body +from sphinx.deprecation import RemovedInSphinx50Warning + field_list_item_re = re.compile(Body.patterns['field_marker']) @@ -42,7 +45,7 @@ def extract_metadata(s: str) -> Dict[str, str]: return metadata -def prepare_docstring(s: str, ignore: int = 1, tabsize: int = 8) -> List[str]: +def prepare_docstring(s: str, ignore: int = None, tabsize: int = 8) -> List[str]: """Convert a docstring into lines of parseable reST. Remove common leading indentation, where the indentation of a given number of lines (usually just one) is ignored. @@ -51,6 +54,12 @@ def prepare_docstring(s: str, ignore: int = 1, tabsize: int = 8) -> List[str]: ViewList (used as argument of nested_parse().) An empty line is added to act as a separator between this docstring and following content. """ + if ignore is None: + ignore = 1 + else: + warnings.warn("The 'ignore' argument to parepare_docstring() is deprecated.", + RemovedInSphinx50Warning, stacklevel=2) + lines = s.expandtabs(tabsize).splitlines() # Find minimum indentation of any non-blank lines after ignored lines. margin = sys.maxsize |