|
15 | 15 | import re |
16 | 16 | from itertools import chain |
17 | 17 |
|
| 18 | +# |
| 19 | +# Python 2 lacks re.ASCII... |
| 20 | +# |
| 21 | +try: |
| 22 | + ascii_p3 = re.ASCII |
| 23 | +except AttributeError: |
| 24 | + ascii_p3 = 0 |
| 25 | + |
18 | 26 | # |
19 | 27 | # Regex nastiness. Of course. |
20 | 28 | # Try to identify "function()" that's not already marked up some |
21 | 29 | # other way. Sphinx doesn't like a lot of stuff right after a |
22 | 30 | # :c:func: block (i.e. ":c:func:`mmap()`s" flakes out), so the last |
23 | 31 | # bit tries to restrict matches to things that won't create trouble. |
24 | 32 | # |
25 | | -RE_function = re.compile(r'\b(([a-zA-Z_]\w+)\(\))', flags=re.ASCII) |
| 33 | +RE_function = re.compile(r'\b(([a-zA-Z_]\w+)\(\))', flags=ascii_p3) |
26 | 34 |
|
27 | 35 | # |
28 | 36 | # Sphinx 2 uses the same :c:type role for struct, union, enum and typedef |
29 | 37 | # |
30 | 38 | RE_generic_type = re.compile(r'\b(struct|union|enum|typedef)\s+([a-zA-Z_]\w+)', |
31 | | - flags=re.ASCII) |
| 39 | + flags=ascii_p3) |
32 | 40 |
|
33 | 41 | # |
34 | 42 | # Sphinx 3 uses a different C role for each one of struct, union, enum and |
35 | 43 | # typedef |
36 | 44 | # |
37 | | -RE_struct = re.compile(r'\b(struct)\s+([a-zA-Z_]\w+)', flags=re.ASCII) |
38 | | -RE_union = re.compile(r'\b(union)\s+([a-zA-Z_]\w+)', flags=re.ASCII) |
39 | | -RE_enum = re.compile(r'\b(enum)\s+([a-zA-Z_]\w+)', flags=re.ASCII) |
40 | | -RE_typedef = re.compile(r'\b(typedef)\s+([a-zA-Z_]\w+)', flags=re.ASCII) |
| 45 | +RE_struct = re.compile(r'\b(struct)\s+([a-zA-Z_]\w+)', flags=ascii_p3) |
| 46 | +RE_union = re.compile(r'\b(union)\s+([a-zA-Z_]\w+)', flags=ascii_p3) |
| 47 | +RE_enum = re.compile(r'\b(enum)\s+([a-zA-Z_]\w+)', flags=ascii_p3) |
| 48 | +RE_typedef = re.compile(r'\b(typedef)\s+([a-zA-Z_]\w+)', flags=ascii_p3) |
41 | 49 |
|
42 | 50 | # |
43 | 51 | # Detects a reference to a documentation page of the form Documentation/... with |
|
0 commit comments