From 6b8bccec5977f608f0b1e33f31a4888a2ea0d141 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Sat, 19 Feb 2022 22:44:45 +0000 Subject: Remove module titles in docstrings --- utils/checks.py | 3 --- utils/doclinter.py | 3 --- utils/jssplitter_generator.py | 3 --- 3 files changed, 9 deletions(-) (limited to 'utils') diff --git a/utils/checks.py b/utils/checks.py index 093817409..6798fde01 100644 --- a/utils/checks.py +++ b/utils/checks.py @@ -1,7 +1,4 @@ """ - utils.checks - ~~~~~~~~~~~~ - Custom, Sphinx-only flake8 plugins. :copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS. diff --git a/utils/doclinter.py b/utils/doclinter.py index b4b27748a..ed61b9c97 100644 --- a/utils/doclinter.py +++ b/utils/doclinter.py @@ -1,7 +1,4 @@ """ - utils.doclinter - ~~~~~~~~~~~~~~~ - A linter for Sphinx docs :copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS. diff --git a/utils/jssplitter_generator.py b/utils/jssplitter_generator.py index 7806d64d2..0e95cfe56 100644 --- a/utils/jssplitter_generator.py +++ b/utils/jssplitter_generator.py @@ -113,9 +113,6 @@ console.log(' ... ok\\n') python_src = '''\ """ - sphinx.search.jssplitter - ~~~~~~~~~~~~~~~~~~~~~~~~ - Provides Python compatible word splitter to JavaScript DO NOT EDIT. This is generated by utils/jssplitter_generator.py -- cgit v1.2.1 From 4f5a3269a6053fe659093096d9b635a2c8e7e55e Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Sun, 20 Feb 2022 00:06:24 +0000 Subject: Fix module docstring first line --- utils/checks.py | 3 +-- utils/doclinter.py | 3 +-- utils/jssplitter_generator.py | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) (limited to 'utils') diff --git a/utils/checks.py b/utils/checks.py index 6798fde01..f69242614 100644 --- a/utils/checks.py +++ b/utils/checks.py @@ -1,5 +1,4 @@ -""" - Custom, Sphinx-only flake8 plugins. +"""Custom, Sphinx-only flake8 plugins. :copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS. :license: BSD, see LICENSE for details. diff --git a/utils/doclinter.py b/utils/doclinter.py index ed61b9c97..93351becb 100644 --- a/utils/doclinter.py +++ b/utils/doclinter.py @@ -1,5 +1,4 @@ -""" - A linter for Sphinx docs +"""A linter for Sphinx docs :copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS. :license: BSD, see LICENSE for details. diff --git a/utils/jssplitter_generator.py b/utils/jssplitter_generator.py index 0e95cfe56..c62ceb37f 100644 --- a/utils/jssplitter_generator.py +++ b/utils/jssplitter_generator.py @@ -112,8 +112,7 @@ console.log(' ... ok\\n') ''' % js_src python_src = '''\ -""" - Provides Python compatible word splitter to JavaScript +"""Provides Python compatible word splitter to JavaScript DO NOT EDIT. This is generated by utils/jssplitter_generator.py -- cgit v1.2.1 From 5694e0ce60316b9cb9709d147e1a699ea9bde6da Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Sun, 20 Feb 2022 00:23:29 +0000 Subject: Fix module docstring indentation --- utils/checks.py | 4 ++-- utils/doclinter.py | 4 ++-- utils/jssplitter_generator.py | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'utils') diff --git a/utils/checks.py b/utils/checks.py index f69242614..952ab8afd 100644 --- a/utils/checks.py +++ b/utils/checks.py @@ -1,7 +1,7 @@ """Custom, Sphinx-only flake8 plugins. - :copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS. - :license: BSD, see LICENSE for details. +:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS. +:license: BSD, see LICENSE for details. """ import os diff --git a/utils/doclinter.py b/utils/doclinter.py index 93351becb..7b3c2f91d 100644 --- a/utils/doclinter.py +++ b/utils/doclinter.py @@ -1,7 +1,7 @@ """A linter for Sphinx docs - :copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS. - :license: BSD, see LICENSE for details. +:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS. +:license: BSD, see LICENSE for details. """ import os diff --git a/utils/jssplitter_generator.py b/utils/jssplitter_generator.py index c62ceb37f..0f2f3759a 100644 --- a/utils/jssplitter_generator.py +++ b/utils/jssplitter_generator.py @@ -114,10 +114,10 @@ console.log(' ... ok\\n') python_src = '''\ """Provides Python compatible word splitter to JavaScript - DO NOT EDIT. This is generated by utils/jssplitter_generator.py +DO NOT EDIT. This is generated by utils/jssplitter_generator.py - :copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS. - :license: BSD, see LICENSE for details. +:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS. +:license: BSD, see LICENSE for details. """ splitter_code = """ -- cgit v1.2.1 From 6bb7b891a16fbcd5fad1f88fb472505549b9c084 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Sun, 20 Feb 2022 02:59:02 +0000 Subject: Remove copyright and licence fields --- utils/checks.py | 3 --- utils/doclinter.py | 3 --- utils/jssplitter_generator.py | 3 --- 3 files changed, 9 deletions(-) (limited to 'utils') diff --git a/utils/checks.py b/utils/checks.py index 952ab8afd..aa1f2f206 100644 --- a/utils/checks.py +++ b/utils/checks.py @@ -1,7 +1,4 @@ """Custom, Sphinx-only flake8 plugins. - -:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS. -:license: BSD, see LICENSE for details. """ import os diff --git a/utils/doclinter.py b/utils/doclinter.py index 7b3c2f91d..544f9952b 100644 --- a/utils/doclinter.py +++ b/utils/doclinter.py @@ -1,7 +1,4 @@ """A linter for Sphinx docs - -:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS. -:license: BSD, see LICENSE for details. """ import os diff --git a/utils/jssplitter_generator.py b/utils/jssplitter_generator.py index 0f2f3759a..f0918ec3f 100644 --- a/utils/jssplitter_generator.py +++ b/utils/jssplitter_generator.py @@ -115,9 +115,6 @@ python_src = '''\ """Provides Python compatible word splitter to JavaScript DO NOT EDIT. This is generated by utils/jssplitter_generator.py - -:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS. -:license: BSD, see LICENSE for details. """ splitter_code = """ -- cgit v1.2.1 From 5775912455c25ee82734e1ff319a32f55946d79b Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Sun, 20 Feb 2022 03:05:56 +0000 Subject: Collapse single line docstrings --- utils/checks.py | 3 +-- utils/doclinter.py | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) (limited to 'utils') diff --git a/utils/checks.py b/utils/checks.py index aa1f2f206..3143357c2 100644 --- a/utils/checks.py +++ b/utils/checks.py @@ -1,5 +1,4 @@ -"""Custom, Sphinx-only flake8 plugins. -""" +"""Custom, Sphinx-only flake8 plugins.""" import os import re diff --git a/utils/doclinter.py b/utils/doclinter.py index 544f9952b..6ef8cbe10 100644 --- a/utils/doclinter.py +++ b/utils/doclinter.py @@ -1,5 +1,4 @@ -"""A linter for Sphinx docs -""" +"""A linter for Sphinx docs""" import os import re -- cgit v1.2.1 From 51c6642ec24ae56f9c8c5aba6aa03eba12fa7aa4 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Sun, 20 Feb 2022 03:13:19 +0000 Subject: Remove redundant `sphinx/utils/checks.py` --- utils/checks.py | 100 -------------------------------------------------------- 1 file changed, 100 deletions(-) delete mode 100644 utils/checks.py (limited to 'utils') diff --git a/utils/checks.py b/utils/checks.py deleted file mode 100644 index 3143357c2..000000000 --- a/utils/checks.py +++ /dev/null @@ -1,100 +0,0 @@ -"""Custom, Sphinx-only flake8 plugins.""" - -import os -import re - -import sphinx - -name_mail_re = r'[\w ]+(<.*?>)?' -copyright_re = re.compile(r'^ :copyright: Copyright 200\d(-20\d\d)? ' - r'by %s(, %s)*[,.]$' % (name_mail_re, name_mail_re)) -copyright_2_re = re.compile(r'^ %s(, %s)*[,.]$' % - (name_mail_re, name_mail_re)) -license_re = re.compile(r' :license: (.*?).\n') - - -def flake8ext(_func): - """Decorate flake8_asserts functions""" - _func.name = _func.__name__ - _func.version = sphinx.__version__ - _func.code = _func.__name__.upper() - - return _func - - -@flake8ext -def sphinx_has_header(physical_line, filename, lines, line_number): - """Check for correct headers. - - Make sure each Python file has a correct file header including - copyright and license information. - - X101 invalid header found - """ - # we have a state machine of sorts so we need to start on line 1. Also, - # there's no point checking really short files - if line_number != 1 or len(lines) < 10: - return - - # this file uses a funky license but unfortunately it's not possible to - # ignore specific errors on a file-level basis yet [1]. Simply skip it. - # - # [1] https://gitlab.com/pycqa/flake8/issues/347 - if os.path.samefile(filename, './sphinx/util/smartypants.py'): - return - - # if the top-level package or not inside the package, ignore - mod_name = os.path.splitext(filename)[0].strip('./\\').replace( - '/', '.').replace('.__init__', '') - if mod_name == 'sphinx' or not mod_name.startswith('sphinx.'): - return - - # line number correction - offset = 1 - if lines[0:1] == ['#!/usr/bin/env python3\n']: - lines = lines[1:] - offset = 2 - - llist = [] - doc_open = False - - for lno, line in enumerate(lines): - llist.append(line) - if lno == 0: - if line != '"""\n' and line != 'r"""\n': - return 0, 'X101 missing docstring begin (""")' - else: - doc_open = True - elif doc_open: - if line == '"""\n': - # end of docstring - if lno <= 3: - return 0, 'X101 missing module name in docstring' - break - - if line != '\n' and line[:4] != ' ' and doc_open: - return 0, 'X101 missing correct docstring indentation' - - if lno == 1: - mod_name_len = len(line.strip()) - if line.strip() != mod_name: - return 2, 'X101 wrong module name in docstring heading' - elif lno == 2: - if line.strip() != mod_name_len * '~': - return (3, 'X101 wrong module name underline, should be ' - '~~~...~') - else: - return 0, 'X101 missing end and/or start of docstring...' - - # check for copyright and license fields - license = llist[-2:-1] - if not license or not license_re.match(license[0]): - return 0, 'X101 no correct license info' - - offset = -3 - copyright = llist[offset:offset + 1] - while copyright and copyright_2_re.match(copyright[0]): - offset -= 1 - copyright = llist[offset:offset + 1] - if not copyright or not copyright_re.match(copyright[0]): - return 0, 'X101 no correct copyright info' -- cgit v1.2.1