Skip to content
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

SpellCheck Plugin: Supporting dictionary files #1161

Open
wants to merge 2 commits into
base: dev/202405
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .pytool/Plugin/SpellCheck/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ The plugin has a few configuration options to support the UEFI codebase.
"AuditOnly": False, # If True, log all errors and then mark as skipped
"IgnoreFiles": [], # use gitignore syntax to ignore errors in matching files
"ExtendWords": [], # words to extend to the dictionary for this package
"ExtraDictionaries": [] # Extra dictionary files for lots of custom words
"IgnoreStandardPaths": [], # Standard Plugin defined paths that should be ignore
"AdditionalIncludePaths": [] # Additional paths to spell check (wildcards supported)
}
Expand All @@ -45,6 +46,17 @@ This supports .gitignore file and folder matching strings including wildcards
This list allows words to be added to the dictionary for the spell checker when
this package is tested. These follow the rules of the cspell config words field.

### ExtraDictionaries

This list allows dictionary files to be added to the dictionary for the spell
checker when this package is tested. Dictionary files contain one word per line.
Dictionary paths interpreted from workspace root. All words in custom dictionary
files are added to the cspell config words field for simplicity. Useful if you
have a lot of custom words and allows integration with other cspell plugins
(ex: vscode's Code Spell Checker plugin). Comments are not supported; if a word
requires a comment it should be added to the `ExtendWords` config where comments
can be added.

### IgnoreStandardPaths

This plugin by default will check the below standard paths. If the package
Expand Down
7 changes: 7 additions & 0 deletions .pytool/Plugin/SpellCheck/SpellCheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class SpellCheck(ICiBuildPlugin):
"AuditOnly": False, # Don't fail the build if there are errors. Just log them
"IgnoreFiles": [], # use gitignore syntax to ignore errors in matching files
"ExtendWords": [], # words to extend to the dictionary for this package
"ExtraDictionaries": [] # Extra dictionary files for lots of custom words
"IgnoreStandardPaths": [], # Standard Plugin defined paths that should be ignore
"AdditionalIncludePaths": [] # Additional paths to spell check (wildcards supported)
}
Expand Down Expand Up @@ -148,6 +149,12 @@ def RunBuildPlugin(self, packagename, Edk2pathObj, pkgconfig, environment, PLM,

if("ExtendWords" in pkgconfig):
config["words"].extend(pkgconfig["ExtendWords"])

if "ExtraDictionaries" in pkgconfig:
for path in pkgconfig["ExtraDictionaries"]:
with open(os.path.join(Edk2pathObj.WorkspacePath, path), 'r') as dictionary:
config["words"].extend(dictionary.read().splitlines())

with open(config_file_path, "w") as o:
json.dump(config, o) # output as json so compat with cspell

Expand Down
Loading