Lines Matching +full:re +full:-
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016-2025 by Mauro Carvalho Chehab <mchehab@kernel.org>.
13 enums and enum symbols and create cross-references for all of them.
25 import re
31 Creates an enriched version of a Kernel header file with cross-links
35 uAPI headers will create cross-reference links to the code.
38 enums and enum symbols and create cross-references for all of them.
58 - A simple symbol name;
59 - A full Sphinx reference.
65 Sets C namespace to be used during cross-reference generation. Can
69 - ioctl: for defines that end with _IO*, e.g. ioctl definitions
70 - define: for other defines
71 - symbol: for symbols defined within enums;
72 - typedef: for typedefs;
73 - enum: for the name of a non-anonymous enum;
74 - struct: for structs.
88 re.compile(r"^\s*enum\s+([\w_]+)\s*\{"),
89 re.compile(r"^\s*enum\s+([\w_]+)\s*$"),
90 re.compile(r"^\s*typedef\s*enum\s+([\w_]+)\s*\{"),
91 re.compile(r"^\s*typedef\s*enum\s+([\w_]+)\s*$"),
94 re.compile(r"^\s*struct\s+([_\w][\w\d_]+)\s*\{"),
95 re.compile(r"^\s*struct\s+([_\w][\w\d_]+)$"),
96 re.compile(r"^\s*typedef\s*struct\s+([_\w][\w\d_]+)\s*\{"),
97 re.compile(r"^\s*typedef\s*struct\s+([_\w][\w\d_]+)$"),
118 # We're calling each definition inside an enum as "symbol"
166 with open(fname, "r", encoding="utf-8", errors="backslashreplace") as f:
174 match = re.match(r"^ignore\s+(\w+)\s+(\S+)", line)
181 match = re.match(r"^replace\s+(\S+)\s+(\S+)\s+(\S+)", line)
187 match = re.match(r"^namespace\s+(\S+)", line)
217 match = re.match(r"^\:c\:(\w+)\:\`(.+)\`", new)
222 match = re.search(r"(\:ref)\:\`(.+)\`", new)
247 By default, underscores are replaced by "-"
260 # c-type references don't support hash
262 ref_name = ref_name.replace("_", "-")
293 encoding="utf-8", errors="backslashreplace") as f:
300 multiline += line[-1]
309 if re.search(r"/\*.*", line):
312 # Strip C99-style comments
313 line = re.sub(r"(//.*)", "", line)
316 if re.search(r".*\*/", line):
323 # if lines end with \ or if they have multi-line comments
325 # and there's no need to use re.DOTALL for the logic below
327 line = re.sub(r"(/\*.*\*/)", "", line)
332 # having comments stripped and multi-lines grouped.
339 # 1. it makes easier to debug issues not-parsed symbols;
344 match = re.match(r"^\s*([_\w][\w\d_]+)\s*[\,=]?", line)
351 match = re.match(r"^\s*#\s*define\s+([\w_]+)\s+_IO", line)
357 match = re.match(r"^\s*#\s*define\s+([\w_]+)(\s+|$)", line)
362 match = re.match(r"^\s*typedef\s+([_\w][\w\d_]+)\s+(.*)\s+([_\w][\w\d_]+);",
400 print(f" #{ln:<5d} {symbol} -> {ref}")
408 text = re.sub(r"\s+$", "", self.data) + "\n"
409 text = re.sub(r"\n\s+\n", "\n\n", text)
412 text = re.sub(r"([\_\`\*\<\>\&\\\\:\/\|\%\$\#\{\}\~\^])", r"\\\1", text)
415 text = re.sub(r"DEPRECATED", "**DEPRECATED**", text)
424 symbol = re.escape(re.sub(r"([\_\`\*\<\>\&\\\\:\/])", r"\\\1", symbol))
425 text = re.sub(fr'{start_delim}{symbol}{end_delim}',
429 text = re.sub(r"\\ ([\n ])", r"\1", text)
430 text = re.sub(r" \\ ", " ", text)
455 text.append("-" * len(description))
460 text.append(f"- LINENO_{ln}: {ref}")
474 with open(file_out, "w", encoding="utf-8", errors="backslashreplace") as f:
475 f.write(".. -*- coding: utf-8; mode: rst -*-\n\n")
480 f.write(".. parsed-literal::\n\n")