diff --git a/README.rst b/README.rst index ae2b0814b..dc6b16707 100644 --- a/README.rst +++ b/README.rst @@ -1,14 +1,20 @@ The CPython Developer's Guide ============================= -.. image:: https://readthedocs.org/projects/cpython-devguide/badge/ +|ReadTheDocs| |Zulip| |Codestyle| + +.. |ReadTheDocs| image:: https://readthedocs.org/projects/cpython-devguide/badge/ :target: https://devguide.python.org :alt: Documentation Status -.. image:: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg +.. |Zulip| image:: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg :alt: Python Zulip chat :target: https://python.zulipchat.com - + +.. |Codestyle| image:: https://img.shields.io/badge/code%20style-black-000000.svg + :target: https://github.com/ambv/black + :alt: Code style is black + This guide covers how to contribute to CPython. It is known by the nickname of "the devguide" by the Python core developers. diff --git a/conf.py b/conf.py index 1e867f02e..6c0cff11d 100644 --- a/conf.py +++ b/conf.py @@ -43,8 +43,8 @@ master_doc = 'index' # General information about the project. -project = u'Python Developer\'s Guide' -copyright = u'2011-%s, Python Software Foundation' % time.strftime('%Y') +project = 'Python Developer\'s Guide' +copyright = '2011-%s, Python Software Foundation' % time.strftime('%Y') # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the @@ -95,8 +95,8 @@ # Use the upstream python-docs-theme html_theme = 'python_docs_theme' html_theme_options = { - 'collapsiblesidebar': True, - 'issues_url': 'https://github.com/python/devguide/issues/new', + 'collapsiblesidebar': True, + 'issues_url': 'https://github.com/python/devguide/issues/new', } @@ -182,8 +182,13 @@ # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass [howto/manual]). latex_documents = [ - ('index', 'PythonDevelopersGuide.tex', u'Python Developer\'s Guide Documentation', - u'Brett Cannon', 'manual'), + ( + 'index', + 'PythonDevelopersGuide.tex', + 'Python Developer\'s Guide Documentation', + 'Brett Cannon', + 'manual', + ), ] # The name of an image file (relative to this directory) to place at the top of @@ -215,8 +220,13 @@ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - ('index', 'pythondevelopersguide', u"Python Developer's Guide Documentation", - [u'Brett Cannon'], 1) + ( + 'index', + 'pythondevelopersguide', + "Python Developer's Guide Documentation", + ['Brett Cannon'], + 1, + ), ] # ignore linkcheck anchors for /#/$ANCHOR since it is used for diff --git a/tools/rstlint.py b/tools/rstlint.py index d6d612dce..ed236fd33 100755 --- a/tools/rstlint.py +++ b/tools/rstlint.py @@ -20,26 +20,110 @@ directives = [ # standard docutils ones - 'admonition', 'attention', 'caution', 'class', 'compound', 'container', - 'contents', 'csv-table', 'danger', 'date', 'default-role', 'epigraph', - 'error', 'figure', 'footer', 'header', 'highlights', 'hint', 'image', - 'important', 'include', 'line-block', 'list-table', 'meta', 'note', - 'parsed-literal', 'pull-quote', 'raw', 'replace', - 'restructuredtext-test-directive', 'role', 'rubric', 'sectnum', 'sidebar', - 'table', 'target-notes', 'tip', 'title', 'topic', 'unicode', 'warning', + 'admonition', + 'attention', + 'caution', + 'class', + 'compound', + 'container', + 'contents', + 'csv-table', + 'danger', + 'date', + 'default-role', + 'epigraph', + 'error', + 'figure', + 'footer', + 'header', + 'highlights', + 'hint', + 'image', + 'important', + 'include', + 'line-block', + 'list-table', + 'meta', + 'note', + 'parsed-literal', + 'pull-quote', + 'raw', + 'replace', + 'restructuredtext-test-directive', + 'role', + 'rubric', + 'sectnum', + 'sidebar', + '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' + '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', ] all_directives = '(' + '|'.join(directives) + ')' @@ -55,12 +139,14 @@ def checker(*suffixes, **kwds): """Decorator to register a function as a checker.""" + def deco(func): for suffix in suffixes: checkers.setdefault(suffix, []).append(func) for prop in checker_props: setattr(func, prop, kwds.get(prop, checker_props[prop])) return func + return deco @@ -84,11 +170,11 @@ def check_suspicious_constructs(fn, lines): inprod = False for lno, line in enumerate(lines): if seems_directive_re.search(line): - yield lno+1, 'comment seems to be intended as a directive' + yield lno + 1, 'comment seems to be intended as a directive' if '.. productionlist::' in line: inprod = True elif not inprod and default_role_re.search(line): - yield lno+1, 'default role used' + yield lno + 1, 'default role used' elif inprod and not line.strip(): inprod = False @@ -98,11 +184,11 @@ def check_whitespace(fn, lines): """Check for whitespace and line length issues.""" for lno, line in enumerate(lines): if '\r' in line: - yield lno+1, '\\r in line' + yield lno + 1, '\\r in line' if '\t' in line: - yield lno+1, 'OMG TABS!!!1' + yield lno + 1, 'OMG TABS!!!1' if line[:-1].rstrip(' \t') != line[:-1]: - yield lno+1, 'trailing whitespace' + yield lno + 1, 'trailing whitespace' @checker('.rst', severity=0) @@ -111,12 +197,14 @@ def check_line_length(fn, lines): for lno, line in enumerate(lines): if len(line) > 81: # don't complain about tables, links and function signatures - if line.lstrip()[0] not in '+|' and \ - 'http://' not in line and \ - not line.lstrip().startswith(('.. function', - '.. method', - '.. cfunction')): - yield lno+1, "line too long" + if ( + line.lstrip()[0] not in '+|' + and 'http://' not in line + and not line.lstrip().startswith( + ('.. function', '.. method', '.. cfunction') + ) + ): + yield lno + 1, "line too long" @checker('.html', severity=2, falsepositives=True) @@ -126,7 +214,7 @@ def check_leaked_markup(fn, lines): """ for lno, line in enumerate(lines): if leaked_markup_re.search(line): - yield lno+1, 'possibly leaked markup: %r' % line + yield lno + 1, 'possibly leaked markup: %r' % line def main(argv): @@ -137,7 +225,8 @@ def main(argv): -f enable checkers that yield many false positives -s sev only show problems with severity >= sev -i path ignore subdir or file path -'''% argv[0] +''' % argv[0] + try: gopts, args = getopt.getopt(argv[1:], 'vfs:i:') except getopt.GetoptError: @@ -222,7 +311,7 @@ def main(argv): for severity in sorted(count): number = count[severity] print('%d problem%s with severity %d found.' % - (number, number > 1 and 's' or '', severity)) + (number, 's' if number > 1 else '', severity)) return int(bool(count)) diff --git a/tools/serve.py b/tools/serve.py index c47f889ba..98b1e5d46 100755 --- a/tools/serve.py +++ b/tools/serve.py @@ -35,4 +35,3 @@ def app(environ, respond): httpd.serve_forever() except KeyboardInterrupt: print("\b\bShutting down.") -