Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
blender-dev-tools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
blender
blender-dev-tools
Commits
58241bb6
Commit
58241bb6
authored
Sep 17, 2022
by
Campbell Barton
Browse files
Options
Downloads
Patches
Plain Diff
check_source: ignore single identifier comments
parent
3c1f2581
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
check_source/check_spelling.py
+20
-2
20 additions, 2 deletions
check_source/check_spelling.py
with
20 additions
and
2 deletions
check_source/check_spelling.py
+
20
−
2
View file @
58241bb6
...
...
@@ -36,6 +36,10 @@ SuggestMap = Dict[str, str]
ONLY_ONCE
=
True
USE_COLOR
=
True
# Ignore: `/*identifier*/` as these are used in C++ for unused arguments or to denote struct members.
# These identifiers can be ignored in most cases.
USE_SKIP_SINGLE_IDENTIFIER_COMMENTS
=
True
_words_visited
=
set
()
_files_visited
=
set
()
...
...
@@ -193,6 +197,9 @@ re_words = re.compile(
re_not_newline
=
re
.
compile
(
"
[^
\n
]
"
)
if
USE_SKIP_SINGLE_IDENTIFIER_COMMENTS
:
re_single_word_c_comments
=
re
.
compile
(
r
"
\/\*[\s]*[a-zA-Z_]+[a-zA-Z0-9_]*[\s]*\*\/
"
)
def
words_from_text
(
text
:
str
,
check_type
:
str
)
->
List
[
Tuple
[
str
,
int
]]:
"""
Extract words to treat as English for spell checking.
...
...
@@ -353,16 +360,27 @@ def extract_c_comments(filepath: str) -> Tuple[List[Comment], Set[str]]:
comment_ranges
=
[]
if
USE_SKIP_SINGLE_IDENTIFIER_COMMENTS
:
comment_ignore_offsets
=
set
()
for
match
in
re_single_word_c_comments
.
finditer
(
text
):
comment_ignore_offsets
.
add
(
match
.
start
(
0
))
i
=
0
while
i
!=
-
1
:
i
=
text
.
find
(
BEGIN
,
i
)
if
i
!=
-
1
:
i_next
=
text
.
find
(
END
,
i
)
if
i_next
!=
-
1
:
do_comment_add
=
True
if
USE_SKIP_SINGLE_IDENTIFIER_COMMENTS
:
if
i
in
comment_ignore_offsets
:
do_comment_add
=
False
# Not essential but seek back to find beginning of line.
while
i
>
0
and
text
[
i
-
1
]
in
{
"
\t
"
,
"
"
}:
i
-=
1
i_next
+=
len
(
END
)
if
do_comment_add
:
comment_ranges
.
append
((
i
,
i_next
))
i
=
i_next
else
:
...
...
@@ -715,7 +733,7 @@ def main() -> None:
else
:
# single file
for
report
in
spell_check_file_with_cache_support
(
filepath
,
extract_type
=
extract_type
,
cache_data
=
cache_data
):
filepath
,
check_type
,
extract_type
=
extract_type
,
cache_data
=
cache_data
):
spell_check_report
(
filepath
,
check_type
,
report
)
except
KeyboardInterrupt
:
clear_stale_cache
=
False
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment