diff options
author | Cheryl Sabella <cheryl.sabella@gmail.com> | 2018-10-12 14:55:20 (GMT) |
---|---|---|
committer | Victor Stinner <vstinner@redhat.com> | 2018-10-12 14:55:20 (GMT) |
commit | 2d6097d027e0dd3debbabc702aa9c98d94ba32a3 (patch) | |
tree | 283b237b7e8da5afa68b5d79792d61f8d60596ac /Doc/tools | |
parent | da2bf9f66d0c95b988c5d87646d168f65499b316 (diff) | |
download | cpython-2d6097d027e0dd3debbabc702aa9c98d94ba32a3.zip cpython-2d6097d027e0dd3debbabc702aa9c98d94ba32a3.tar.gz cpython-2d6097d027e0dd3debbabc702aa9c98d94ba32a3.tar.bz2 |
bpo-11233: Create availability directive for documentation (GH-9692)
Replace "Availability: xxx" with ".. availability:: xxx" in the doc.
Original patch by Georg Brandl.
Co-Authored-By: Georg Brandl <georg@python.org>
Diffstat (limited to 'Doc/tools')
-rw-r--r-- | Doc/tools/extensions/pyspecific.py | 20 | ||||
-rwxr-xr-x | Doc/tools/rstlint.py | 23 |
2 files changed, 32 insertions, 11 deletions
diff --git a/Doc/tools/extensions/pyspecific.py b/Doc/tools/extensions/pyspecific.py index 8036daa..132920f 100644 --- a/Doc/tools/extensions/pyspecific.py +++ b/Doc/tools/extensions/pyspecific.py @@ -131,6 +131,25 @@ class ImplementationDetail(Directive): return [pnode] +# Support for documenting platform availability + +class Availability(Directive): + + has_content = False + required_arguments = 1 + optional_arguments = 0 + final_argument_whitespace = True + + def run(self): + pnode = nodes.paragraph(classes=['availability']) + n, m = self.state.inline_text(':ref:`Availability <availability>`: ', + self.lineno) + pnode.extend(n + m) + n, m = self.state.inline_text(self.arguments[0], self.lineno) + pnode.extend(n + m) + return [pnode] + + # Support for documenting decorators class PyDecoratorMixin(object): @@ -401,6 +420,7 @@ def setup(app): app.add_role('issue', issue_role) app.add_role('source', source_role) app.add_directive('impl-detail', ImplementationDetail) + app.add_directive('availability', Availability) app.add_directive('deprecated-removed', DeprecatedRemoved) app.add_builder(PydocTopicsBuilder) app.add_builder(suspicious.CheckSuspiciousMarkupBuilder) diff --git a/Doc/tools/rstlint.py b/Doc/tools/rstlint.py index 2c1816e..a3024d6 100755 --- a/Doc/tools/rstlint.py +++ b/Doc/tools/rstlint.py @@ -27,17 +27,18 @@ directives = [ 'table', 'target-notes', 'tip', 'title', 'topic', 'unicode', 'warning', # Sphinx and Python docs custom ones 'acks', 'attribute', 'autoattribute', 'autoclass', 'autodata', - 'autoexception', 'autofunction', 'automethod', 'automodule', 'centered', - 'cfunction', 'class', 'classmethod', 'cmacro', 'cmdoption', 'cmember', - 'code-block', 'confval', 'cssclass', 'ctype', 'currentmodule', 'cvar', - 'data', 'decorator', 'decoratormethod', 'deprecated-removed', - 'deprecated(?!-removed)', 'describe', 'directive', 'doctest', 'envvar', - 'event', 'exception', 'function', 'glossary', 'highlight', 'highlightlang', - 'impl-detail', 'index', 'literalinclude', 'method', 'miscnews', 'module', - 'moduleauthor', 'opcode', 'pdbcommand', 'productionlist', - 'program', 'role', 'sectionauthor', 'seealso', 'sourcecode', 'staticmethod', - 'tabularcolumns', 'testcode', 'testoutput', 'testsetup', 'toctree', 'todo', - 'todolist', 'versionadded', 'versionchanged' + 'autoexception', 'autofunction', 'automethod', 'automodule', + 'availability', 'centered', 'cfunction', 'class', 'classmethod', 'cmacro', + 'cmdoption', 'cmember', 'code-block', 'confval', 'cssclass', 'ctype', + 'currentmodule', 'cvar', 'data', 'decorator', 'decoratormethod', + 'deprecated-removed', 'deprecated(?!-removed)', 'describe', 'directive', + 'doctest', 'envvar', 'event', 'exception', 'function', 'glossary', + 'highlight', 'highlightlang', 'impl-detail', 'index', 'literalinclude', + 'method', 'miscnews', 'module', 'moduleauthor', 'opcode', 'pdbcommand', + 'productionlist', 'program', 'role', 'sectionauthor', 'seealso', + 'sourcecode', 'staticmethod', 'tabularcolumns', 'testcode', 'testoutput', + 'testsetup', 'toctree', 'todo', 'todolist', 'versionadded', + 'versionchanged' ] all_directives = '(' + '|'.join(directives) + ')' |