Skip to content

Commit 6de3d5b

Browse files
author
Dave Bartolomeo
committed
C++: Change opcode QLDocs to refer to instruction QLDocs
As discussed in today's C++ analysis team meeting. `Opcode` is rarely used directly, so we'll just refer to the documentation for the corresponding `Instruction` class. I've preserved the script in case we want to do a bulk change of all of the `Opcode` comments, but I don't expect it will be needed if we just add a new `Opcode` or two.
1 parent 4dcdd8a commit 6de3d5b

File tree

3 files changed

+627
-271
lines changed

3 files changed

+627
-271
lines changed

config/opcode-qldoc.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import re
55
path = os.path
66

7+
needs_an_re = re.compile(r'^(?!Unary)[AEIOU]') # Name requiring "an" instead of "a".
78
start_qldoc_re = re.compile(r'^\s*/\*\*') # Start of a QLDoc comment
89
end_qldoc_re = re.compile(r'\*/\s*$') # End of a QLDoc comment
910
blank_qldoc_line_re = re.compile(r'^\s*\*\s*$') # A line in a QLDoc comment with only the '*'
@@ -84,9 +85,14 @@
8485
# Found an `Opcode` that matches a known `Instruction`. Replace the QLDoc with
8586
# a copy of the one from the `Instruction`.
8687
if instruction_comments.get(name_without_suffix):
87-
# Rename `instruction` to `operation`.
88-
qldoc_lines = [(indent + qldoc_line.replace(' An instruction ', ' An operation '))
89-
for qldoc_line in instruction_comments[name_without_suffix]]
88+
article = 'an' if needs_an_re.search(name_without_suffix) else 'a'
89+
qldoc_lines = [
90+
indent + '/**\n',
91+
indent + ' * The `Opcode` for ' + article + ' `' + name_without_suffix + 'Instruction`.\n',
92+
indent + ' *\n',
93+
indent + ' * See the `' + name_without_suffix + 'Instruction` documentation for more details.\n',
94+
indent + ' */\n'
95+
]
9096
output_lines.extend(qldoc_lines)
9197
qldoc_lines = []
9298
output_lines.append(line)

0 commit comments

Comments
 (0)