diff options
author | Brad King <brad.king@kitware.com> | 2023-06-14 13:12:53 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2023-06-14 13:12:57 (GMT) |
commit | f19baf5846548a3a9dbb91234548e1c70dbf3583 (patch) | |
tree | 54bac786a579513bd3bcdde13c72178353d24319 | |
parent | cb5b148335af1466fcc9412c5fff0b4e6dbe8ebd (diff) | |
parent | 528cdc75519987a2004db94d1e7b0e445b1fb158 (diff) | |
download | CMake-f19baf5846548a3a9dbb91234548e1c70dbf3583.zip CMake-f19baf5846548a3a9dbb91234548e1c70dbf3583.tar.gz CMake-f19baf5846548a3a9dbb91234548e1c70dbf3583.tar.bz2 |
Merge topic 'improve-sphinx-check' into release-3.27
528cdc7551 Utilities/Sphinx: Fix some flake8 gripes
4bd1beded4 Utilities/Sphinx: Don't ignore flake8 E402
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !8561
-rw-r--r-- | Utilities/Sphinx/.flake8 | 3 | ||||
-rw-r--r-- | Utilities/Sphinx/cmake.py | 39 |
2 files changed, 19 insertions, 23 deletions
diff --git a/Utilities/Sphinx/.flake8 b/Utilities/Sphinx/.flake8 deleted file mode 100644 index 7218008..0000000 --- a/Utilities/Sphinx/.flake8 +++ /dev/null @@ -1,3 +0,0 @@ -[flake8] -per-file-ignores = - cmake.py: E402 diff --git a/Utilities/Sphinx/cmake.py b/Utilities/Sphinx/cmake.py index d3eb948..0afd705 100644 --- a/Utilities/Sphinx/cmake.py +++ b/Utilities/Sphinx/cmake.py @@ -5,30 +5,29 @@ import os import re - from dataclasses import dataclass from typing import Any, List, Tuple, Type, cast import sphinx -# Require at least Sphinx 2.x. -# flake8 issues E402 for imports after this, but the purpose of this -# check is to fail more clearly if the imports below will fail. -assert sphinx.version_info >= (2,) - -from docutils.utils.code_analyzer import Lexer, LexerError -from docutils.parsers.rst import Directive, directives -from docutils.transforms import Transform -from docutils.nodes import Element, Node, TextElement, system_message -from docutils import io, nodes - -from sphinx.directives import ObjectDescription, nl_escape_re -from sphinx.domains import Domain, ObjType -from sphinx.roles import XRefRole -from sphinx.util.docutils import ReferenceRole -from sphinx.util.nodes import make_refnode -from sphinx.util import logging, ws_re -from sphinx import addnodes +# The following imports may fail if we don't have Sphinx 2.x or later. +if sphinx.version_info >= (2,): + from docutils import io, nodes + from docutils.nodes import Element, Node, TextElement, system_message + from docutils.parsers.rst import Directive, directives + from docutils.transforms import Transform + from docutils.utils.code_analyzer import Lexer, LexerError + + from sphinx import addnodes + from sphinx.directives import ObjectDescription, nl_escape_re + from sphinx.domains import Domain, ObjType + from sphinx.roles import XRefRole + from sphinx.util import logging, ws_re + from sphinx.util.docutils import ReferenceRole + from sphinx.util.nodes import make_refnode +else: + # Sphinx 2.x is required. + assert sphinx.version_info >= (2,) # END imports @@ -47,10 +46,10 @@ from sphinx import addnodes # - manual/cmake-buildsystem.7.html # (with nested $<..>; relative and absolute paths, "::") +from pygments.lexer import bygroups # noqa I100 from pygments.lexers import CMakeLexer from pygments.token import (Comment, Name, Number, Operator, Punctuation, String, Text, Whitespace) -from pygments.lexer import bygroups # Notes on regular expressions below: # - [\.\+-] are needed for string constants like gtk+-2.0 |