mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Enable automatic formatting for `sphinx/domains/cpp/
`
This commit is contained in:
parent
3e2f89b820
commit
51a38d5f98
@ -396,11 +396,6 @@ exclude = [
|
|||||||
"sphinx/builders/latex/constants.py",
|
"sphinx/builders/latex/constants.py",
|
||||||
"sphinx/domains/changeset.py",
|
"sphinx/domains/changeset.py",
|
||||||
"sphinx/domains/citation.py",
|
"sphinx/domains/citation.py",
|
||||||
"sphinx/domains/cpp/_parser.py",
|
|
||||||
"sphinx/domains/cpp/_ids.py",
|
|
||||||
"sphinx/domains/cpp/__init__.py",
|
|
||||||
"sphinx/domains/cpp/_symbol.py",
|
|
||||||
"sphinx/domains/cpp/_ast.py",
|
|
||||||
"sphinx/domains/index.py",
|
"sphinx/domains/index.py",
|
||||||
"sphinx/domains/javascript.py",
|
"sphinx/domains/javascript.py",
|
||||||
"sphinx/domains/math.py",
|
"sphinx/domains/math.py",
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -254,13 +254,17 @@ from __future__ import annotations
|
|||||||
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
udl_identifier_re = re.compile(r'''
|
udl_identifier_re = re.compile(
|
||||||
[a-zA-Z_][a-zA-Z0-9_]*\b # note, no word boundary in the beginning
|
r'[a-zA-Z_][a-zA-Z0-9_]*\b' # note, no word boundary in the beginning
|
||||||
''', re.VERBOSE)
|
)
|
||||||
_string_re = re.compile(r"[LuU8]?('([^'\\]*(?:\\.[^'\\]*)*)'"
|
_string_re = re.compile(
|
||||||
r'|"([^"\\]*(?:\\.[^"\\]*)*)")', re.DOTALL)
|
r"[LuU8]?('([^'\\]*(?:\\.[^'\\]*)*)'"
|
||||||
|
r'|"([^"\\]*(?:\\.[^"\\]*)*)")',
|
||||||
|
re.DOTALL,
|
||||||
|
)
|
||||||
_visibility_re = re.compile(r'\b(public|private|protected)\b')
|
_visibility_re = re.compile(r'\b(public|private|protected)\b')
|
||||||
_operator_re = re.compile(r'''
|
_operator_re = re.compile(
|
||||||
|
r"""
|
||||||
\[\s*\]
|
\[\s*\]
|
||||||
| \(\s*\)
|
| \(\s*\)
|
||||||
| \+\+ | --
|
| \+\+ | --
|
||||||
@ -269,33 +273,49 @@ _operator_re = re.compile(r'''
|
|||||||
| <=>
|
| <=>
|
||||||
| [!<>=/*%+|&^~-]=?
|
| [!<>=/*%+|&^~-]=?
|
||||||
| (\b(and|and_eq|bitand|bitor|compl|not|not_eq|or|or_eq|xor|xor_eq)\b)
|
| (\b(and|and_eq|bitand|bitor|compl|not|not_eq|or|or_eq|xor|xor_eq)\b)
|
||||||
''', re.VERBOSE)
|
""",
|
||||||
_fold_operator_re = re.compile(r'''
|
re.VERBOSE,
|
||||||
|
)
|
||||||
|
_fold_operator_re = re.compile(
|
||||||
|
r"""
|
||||||
->\* | \.\* | \,
|
->\* | \.\* | \,
|
||||||
| (<<|>>)=? | && | \|\|
|
| (<<|>>)=? | && | \|\|
|
||||||
| !=
|
| !=
|
||||||
| [<>=/*%+|&^~-]=?
|
| [<>=/*%+|&^~-]=?
|
||||||
''', re.VERBOSE)
|
""",
|
||||||
|
re.VERBOSE,
|
||||||
|
)
|
||||||
# see https://en.cppreference.com/w/cpp/keyword
|
# see https://en.cppreference.com/w/cpp/keyword
|
||||||
_keywords = [
|
_keywords = [
|
||||||
'alignas', 'alignof', 'and', 'and_eq', 'asm', 'auto', 'bitand', 'bitor',
|
'alignas', 'alignof', 'and', 'and_eq', 'asm', 'auto',
|
||||||
'bool', 'break', 'case', 'catch', 'char', 'char8_t', 'char16_t', 'char32_t',
|
'bitand', 'bitor', 'bool', 'break',
|
||||||
'class', 'compl', 'concept', 'const', 'consteval', 'constexpr', 'constinit',
|
'case', 'catch', 'class', 'compl', 'concept', 'continue',
|
||||||
'const_cast', 'continue',
|
'char', 'char8_t', 'char16_t', 'char32_t',
|
||||||
'decltype', 'default', 'delete', 'do', 'double', 'dynamic_cast', 'else',
|
'const', 'const_cast', 'consteval', 'constexpr', 'constinit',
|
||||||
'enum', 'explicit', 'export', 'extern', 'false', 'float', 'for', 'friend',
|
'decltype', 'default', 'delete', 'do', 'double', 'dynamic_cast',
|
||||||
'goto', 'if', 'inline', 'int', 'long', 'mutable', 'namespace', 'new',
|
'else', 'enum', 'explicit', 'export', 'extern',
|
||||||
'noexcept', 'not', 'not_eq', 'nullptr', 'operator', 'or', 'or_eq',
|
'false', 'float', 'for', 'friend',
|
||||||
'private', 'protected', 'public', 'register', 'reinterpret_cast',
|
'goto',
|
||||||
'requires', 'return', 'short', 'signed', 'sizeof', 'static',
|
'if', 'inline', 'int',
|
||||||
'static_assert', 'static_cast', 'struct', 'switch', 'template', 'this',
|
'long',
|
||||||
'thread_local', 'throw', 'true', 'try', 'typedef', 'typeid', 'typename',
|
'mutable',
|
||||||
'union', 'unsigned', 'using', 'virtual', 'void', 'volatile', 'wchar_t',
|
'namespace', 'new', 'noexcept', 'not', 'not_eq', 'nullptr',
|
||||||
'while', 'xor', 'xor_eq',
|
'operator', 'or', 'or_eq',
|
||||||
]
|
'private', 'protected', 'public',
|
||||||
|
'register', 'reinterpret_cast', 'requires', 'return',
|
||||||
|
'short', 'signed', 'sizeof', 'static',
|
||||||
|
'static_assert', 'static_cast', 'struct', 'switch',
|
||||||
|
'template', 'this', 'thread_local', 'throw',
|
||||||
|
'true', 'try', 'typedef', 'typeid', 'typename',
|
||||||
|
'union', 'unsigned', 'using',
|
||||||
|
'virtual', 'void', 'volatile',
|
||||||
|
'wchar_t', 'while',
|
||||||
|
'xor', 'xor_eq',
|
||||||
|
] # fmt: skip
|
||||||
|
|
||||||
|
|
||||||
_simple_type_specifiers_re = re.compile(r"""
|
_simple_type_specifiers_re = re.compile(
|
||||||
|
r"""
|
||||||
\b(
|
\b(
|
||||||
auto|void|bool
|
auto|void|bool
|
||||||
|signed|unsigned
|
|signed|unsigned
|
||||||
@ -307,7 +327,9 @@ _simple_type_specifiers_re = re.compile(r"""
|
|||||||
|__float80|_Float64x|__float128|_Float128 # extension
|
|__float80|_Float64x|__float128|_Float128 # extension
|
||||||
|_Complex|_Imaginary # extension
|
|_Complex|_Imaginary # extension
|
||||||
)\b
|
)\b
|
||||||
""", re.VERBOSE)
|
""",
|
||||||
|
re.VERBOSE,
|
||||||
|
)
|
||||||
|
|
||||||
_max_id = 4
|
_max_id = 4
|
||||||
_id_prefix = [None, '', '_CPPv2', '_CPPv3', '_CPPv4']
|
_id_prefix = [None, '', '_CPPv2', '_CPPv3', '_CPPv4']
|
||||||
@ -433,8 +455,10 @@ _id_fundamental_v2 = {
|
|||||||
'float': 'f',
|
'float': 'f',
|
||||||
'double': 'd',
|
'double': 'd',
|
||||||
'long double': 'e',
|
'long double': 'e',
|
||||||
'__float80': 'e', '_Float64x': 'e',
|
'__float80': 'e',
|
||||||
'__float128': 'g', '_Float128': 'g',
|
'_Float64x': 'e',
|
||||||
|
'__float128': 'g',
|
||||||
|
'_Float128': 'g',
|
||||||
'_Complex float': 'Cf',
|
'_Complex float': 'Cf',
|
||||||
'_Complex double': 'Cd',
|
'_Complex double': 'Cd',
|
||||||
'_Complex long double': 'Ce',
|
'_Complex long double': 'Ce',
|
||||||
@ -456,38 +480,49 @@ _id_operator_v2 = {
|
|||||||
# '-(unary)' : 'ng',
|
# '-(unary)' : 'ng',
|
||||||
# '&(unary)' : 'ad',
|
# '&(unary)' : 'ad',
|
||||||
# '*(unary)' : 'de',
|
# '*(unary)' : 'de',
|
||||||
'~': 'co', 'compl': 'co',
|
'~': 'co',
|
||||||
|
'compl': 'co',
|
||||||
'+': 'pl',
|
'+': 'pl',
|
||||||
'-': 'mi',
|
'-': 'mi',
|
||||||
'*': 'ml',
|
'*': 'ml',
|
||||||
'/': 'dv',
|
'/': 'dv',
|
||||||
'%': 'rm',
|
'%': 'rm',
|
||||||
'&': 'an', 'bitand': 'an',
|
'&': 'an',
|
||||||
'|': 'or', 'bitor': 'or',
|
'bitand': 'an',
|
||||||
'^': 'eo', 'xor': 'eo',
|
'|': 'or',
|
||||||
|
'bitor': 'or',
|
||||||
|
'^': 'eo',
|
||||||
|
'xor': 'eo',
|
||||||
'=': 'aS',
|
'=': 'aS',
|
||||||
'+=': 'pL',
|
'+=': 'pL',
|
||||||
'-=': 'mI',
|
'-=': 'mI',
|
||||||
'*=': 'mL',
|
'*=': 'mL',
|
||||||
'/=': 'dV',
|
'/=': 'dV',
|
||||||
'%=': 'rM',
|
'%=': 'rM',
|
||||||
'&=': 'aN', 'and_eq': 'aN',
|
'&=': 'aN',
|
||||||
'|=': 'oR', 'or_eq': 'oR',
|
'and_eq': 'aN',
|
||||||
'^=': 'eO', 'xor_eq': 'eO',
|
'|=': 'oR',
|
||||||
|
'or_eq': 'oR',
|
||||||
|
'^=': 'eO',
|
||||||
|
'xor_eq': 'eO',
|
||||||
'<<': 'ls',
|
'<<': 'ls',
|
||||||
'>>': 'rs',
|
'>>': 'rs',
|
||||||
'<<=': 'lS',
|
'<<=': 'lS',
|
||||||
'>>=': 'rS',
|
'>>=': 'rS',
|
||||||
'==': 'eq',
|
'==': 'eq',
|
||||||
'!=': 'ne', 'not_eq': 'ne',
|
'!=': 'ne',
|
||||||
|
'not_eq': 'ne',
|
||||||
'<': 'lt',
|
'<': 'lt',
|
||||||
'>': 'gt',
|
'>': 'gt',
|
||||||
'<=': 'le',
|
'<=': 'le',
|
||||||
'>=': 'ge',
|
'>=': 'ge',
|
||||||
'<=>': 'ss',
|
'<=>': 'ss',
|
||||||
'!': 'nt', 'not': 'nt',
|
'!': 'nt',
|
||||||
'&&': 'aa', 'and': 'aa',
|
'not': 'nt',
|
||||||
'||': 'oo', 'or': 'oo',
|
'&&': 'aa',
|
||||||
|
'and': 'aa',
|
||||||
|
'||': 'oo',
|
||||||
|
'or': 'oo',
|
||||||
'++': 'pp',
|
'++': 'pp',
|
||||||
'--': 'mm',
|
'--': 'mm',
|
||||||
',': 'cm',
|
',': 'cm',
|
||||||
@ -505,12 +540,17 @@ _id_operator_unary_v2 = {
|
|||||||
'&': 'ad',
|
'&': 'ad',
|
||||||
'+': 'ps',
|
'+': 'ps',
|
||||||
'-': 'ng',
|
'-': 'ng',
|
||||||
'!': 'nt', 'not': 'nt',
|
'!': 'nt',
|
||||||
'~': 'co', 'compl': 'co',
|
'not': 'nt',
|
||||||
|
'~': 'co',
|
||||||
|
'compl': 'co',
|
||||||
}
|
}
|
||||||
_id_char_from_prefix: dict[str | None, str] = {
|
_id_char_from_prefix: dict[str | None, str] = {
|
||||||
None: 'c', 'u8': 'c',
|
None: 'c',
|
||||||
'u': 'Ds', 'U': 'Di', 'L': 'w',
|
'u8': 'c',
|
||||||
|
'u': 'Ds',
|
||||||
|
'U': 'Di',
|
||||||
|
'L': 'w',
|
||||||
}
|
}
|
||||||
# these are ordered by preceedence
|
# these are ordered by preceedence
|
||||||
_expression_bin_ops = [
|
_expression_bin_ops = [
|
||||||
@ -526,9 +566,34 @@ _expression_bin_ops = [
|
|||||||
['*', '/', '%'],
|
['*', '/', '%'],
|
||||||
['.*', '->*'],
|
['.*', '->*'],
|
||||||
]
|
]
|
||||||
_expression_unary_ops = ["++", "--", "*", "&", "+", "-", "!", "not", "~", "compl"]
|
_expression_unary_ops = [
|
||||||
_expression_assignment_ops = ["=", "*=", "/=", "%=", "+=", "-=",
|
'++',
|
||||||
">>=", "<<=", "&=", "and_eq", "^=", "|=", "xor_eq", "or_eq"]
|
'--',
|
||||||
|
'*',
|
||||||
|
'&',
|
||||||
|
'+',
|
||||||
|
'-',
|
||||||
|
'!',
|
||||||
|
'not',
|
||||||
|
'~',
|
||||||
|
'compl',
|
||||||
|
]
|
||||||
|
_expression_assignment_ops = [
|
||||||
|
'=',
|
||||||
|
'*=',
|
||||||
|
'/=',
|
||||||
|
'%=',
|
||||||
|
'+=',
|
||||||
|
'-=',
|
||||||
|
'>>=',
|
||||||
|
'<<=',
|
||||||
|
'&=',
|
||||||
|
'and_eq',
|
||||||
|
'^=',
|
||||||
|
'|=',
|
||||||
|
'xor_eq',
|
||||||
|
'or_eq',
|
||||||
|
]
|
||||||
_id_explicit_cast = {
|
_id_explicit_cast = {
|
||||||
'dynamic_cast': 'dc',
|
'dynamic_cast': 'dc',
|
||||||
'static_cast': 'sc',
|
'static_cast': 'sc',
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user