-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle third party trademarks #168
base: main
Are you sure you want to change the base?
Changes from all commits
7776200
e213c9e
e19ff23
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,12 @@ def toc_md_files(toc, dirs): | |
|
||
assert anchor_re.findall('<a id="comparison-to-c"/>') == ['comparison-to-c'] | ||
|
||
third_party_trademarks = {'synopsys', 'coverity'} | ||
|
||
third_party_trademark_re = re.compile( | ||
r'(?i:(' + '|'.join(third_party_trademarks) | ||
+ r'))([*®™]|®|™|©|\\\*)?') | ||
Comment on lines
+29
to
+31
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. urgh, I can't read this. Can you document what you mean with a unit test? A simple Also, if you want to capture this in the future, then I suggest allowlist rather than blocklist, i.e. complain if the word before There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The regex can actually be improved a small bit (the second group doesn't need to try to match against anything but
Not good enough, that doesn't catch people using an external trademark without annotating it with an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually I want to keep the regex as-is and capitalize on it instead. Currently we check that an external trademark is annotated with * at least once per section it's referenced in. However, we should also check that no reference to an external trademark is annotated with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you want to protect from using external trademarks without And if we are to make this kind of check, then it's better to do it globally for all simics docs. |
||
|
||
def char_range(low, high): | ||
return map(chr, range(ord(low), ord(high) + 1)) | ||
|
||
|
@@ -95,11 +101,40 @@ def main(): | |
line = md_files[path][:match.start()].count('\n') + 1 | ||
sys.stderr.write(f'{path}:{line}: error: {message}\n') | ||
ok = False | ||
|
||
third_party_trademarks_referenced = {} | ||
third_party_trademarks_annotated = set() | ||
def check_third_party_trademarks(): | ||
for (tm, line) in third_party_trademarks_referenced.items(): | ||
if tm not in third_party_trademarks_annotated: | ||
sys.stderr.write( | ||
f"{path}:{line+1}: error: third party trademark " | ||
+ f"'{tm}' never annotated with '*' in this section\n") | ||
nonlocal ok | ||
ok = False | ||
third_party_trademarks_referenced.clear() | ||
third_party_trademarks_annotated.clear() | ||
|
||
for (i, line) in enumerate(md_files[path].split('\n')): | ||
if ' -- ' in f' {line} ': | ||
sys.stderr.write( | ||
f'{path}:{i+1}: error: replace -- with —\n') | ||
ok = False | ||
|
||
# A third party trademark must be annotated at least once per | ||
# (sub)section | ||
if line.startswith('#'): | ||
check_third_party_trademarks() | ||
for match in third_party_trademark_re.finditer(line): | ||
annotated = match.group(2) in {'*', '\\*'} | ||
|
||
tm = match.group(1).lower() | ||
third_party_trademarks_referenced.setdefault(tm, i) | ||
if annotated: | ||
third_party_trademarks_annotated.add(tm) | ||
|
||
check_third_party_trademarks() | ||
|
||
sys.exit(0 if ok else 1) | ||
|
||
if __name__ == '__main__': | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not be part of the md_to_github script: The md sources are compiled into both simics-native docs and into github wiki, so better fix this in the md sources instead. Or is this stuff also auto-added by dodoc?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Simics Online Documentation will have a separate solution that won't require authors to manually add acknowledgment lines. So this DML wiki exclusive logic should indeed be DML wiki exclusive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively... the DML wiki could have a
* Legal Information
page... hmm...Though that could be more cumbersome than an acknowledgement line (or awkward, if all it contains is the acknowledgement line)