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:58 (GMT) |
commit | 6743256b94bebc17d6d1b6f38d411410c365058b (patch) | |
tree | 1ab5d1e40dac2de25558a6a328ac408b4288b07a /Utilities | |
parent | 12518c7b0f51086382f4b4865fdef28e54144908 (diff) | |
parent | 528cdc75519987a2004db94d1e7b0e445b1fb158 (diff) | |
download | CMake-6743256b94bebc17d6d1b6f38d411410c365058b.zip CMake-6743256b94bebc17d6d1b6f38d411410c365058b.tar.gz CMake-6743256b94bebc17d6d1b6f38d411410c365058b.tar.bz2 |
Merge topic 'improve-sphinx-check'
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
Diffstat (limited to 'Utilities')
-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 |