Skip to content

Commit bb015d6

Browse files
committed
Support math profile extension to Unicode identifiers
https://www.unicode.org/L2/L2022/22230-math-profile.pdf
1 parent c156221 commit bb015d6

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

sphinx/util/cfamily.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,14 @@
3131
# make sure they are in sync.
3232
(~?\b[a-zA-Z_]) # ordinary identifiers
3333
| \p{XID_Start} # Unicode-allowed starting characters for identifiers
34+
| \p{ID_Compat_Math_Start} # Unicode-allowed starting mathematical characters for identifiers
3435
| (@[a-zA-Z0-9_]) # our extension for names of anonymous entities
3536
)
3637
(
3738
[a-zA-Z0-9_] # ordinary identifiers
3839
| \p{XID_Continue} # Unicode-allowed continuing characters for identifiers
39-
)*\b
40+
| \p{ID_Compat_Math_Continue} # Unicode-allowed continuing mathematical characters for identifiers
41+
)*
4042
""",
4143
flags=re.VERBOSE,
4244
)

tests/test_domains/test_domain_cpp.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -876,6 +876,9 @@ def test_domain_cpp_ast_function_definitions() -> None:
876876
2: '8ψcomputed',
877877
3: '8ψcomputed',
878878
4: '8ψcomputed'})
879+
check('function', 'norm₂(V x)', {1: 'norm₂__V', 2: '5norm₂1V', 3: '5norm₂1V', 4: '5norm₂1V'})
880+
check('function', '∇(V x)', {1: '∇__V', 2: '1∇1V', 3: '1∇1V', 4: '1∇1V'})
881+
check('function', 'compute∂(V x)', {1: 'compute∂__V', 2: '8compute∂1V', 3: '8compute∂1V', 4: '8compute∂1V'})
879882

880883
# TODO: make tests for functions in a template, e.g., Test<int&&()>
881884
# such that the id generation for function type types is correct.

0 commit comments

Comments
 (0)