Skip to content

Commit

Permalink
Fix Google rule generation
Browse files Browse the repository at this point in the history
Signed-off-by: Jack Baldry <[email protected]>
  • Loading branch information
jdbaldry committed Dec 5, 2024
1 parent 854e7ba commit 7618ba3
Show file tree
Hide file tree
Showing 9 changed files with 92 additions and 99 deletions.
84 changes: 40 additions & 44 deletions docs/sources/review/lint-prose/rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ Use 'AM' or 'PM' (preceded by a space).

_`<CURRENT TEXT>`_ was matched by one or more of the following regular expressions:

- `\d{1,2}[AP]M`
- `\d{1,2} ?[ap]m`
- `\d{1,2}[AP]M\b`
- `\d{1,2} ?[ap]m\b`
- `\d{1,2} ?[aApP]\.[mM]\.`

[More information ->](https://developers.google.com/style/word-list)
Expand Down Expand Up @@ -165,47 +165,43 @@ Extends: substitution

Consider using _`<REPLACEMENT TEXT>`_ instead of _`<CURRENT TEXT>`_.

| Current text | Replacement text |
| ------------------------------ | ----------------------------- |
| `(?:alumnae\|alumni)` | `graduates` |
| `(?:alumna\|alumnus)` | `graduate` |
| `air(?:m[ae]n\|wom[ae]n)` | `pilot(s)` |
| `anchor(?:m[ae]n\|wom[ae]n)` | `anchor(s)` |
| `authoress` | `author` |
| `camera(?:m[ae]n\|wom[ae]n)` | `camera operator(s)` |
| `chair(?:m[ae]n\|wom[ae]n)` | `chair(s)` |
| `congress(?:m[ae]n\|wom[ae]n)` | `member(s) of congress` |
| `door(?:m[ae]\|wom[ae]n)` | `concierge(s)` |
| `draft(?:m[ae]n\|wom[ae]n)` | `drafter(s)` |
| `fire(?:m[ae]n\|wom[ae]n)` | `firefighter(s)` |
| `fisher(?:m[ae]n\|wom[ae]n)` | `fisher(s)` |
| `fresh(?:m[ae]n\|wom[ae]n)` | `first-year student(s)` |
| `garbage(?:m[ae]n\|wom[ae]n)` | `waste collector(s)` |
| `lady lawyer` | `lawyer` |
| `ladylike` | `courteous` |
| `landlord` | `building manager` |
| `mail(?:m[ae]n\|wom[ae]n)` | `mail carriers` |
| `man and wife` | `husband and wife` |
| `man enough` | `strong enough` |
| `mankind` | `human kind` |
| `manmade` | `manufactured` |
| `manpower` | `personnel` |
| `men and girls` | `men and women` |
| `middle(?:m[ae]n\|wom[ae]n)` | `intermediary` |
| `news(?:m[ae]n\|wom[ae]n)` | `journalist(s)` |
| `ombuds(?:man\|woman)` | `ombuds` |
| `oneupmanship` | `upstaging` |
| `poetess` | `poet` |
| `police(?:m[ae]n\|wom[ae]n)` | `police officer(s)` |
| `repair(?:m[ae]n\|wom[ae]n)` | `technician(s)` |
| `sales(?:m[ae]n\|wom[ae]n)` | `salesperson or sales people` |
| `service(?:m[ae]n\|wom[ae]n)` | `soldier(s)` |
| `steward(?:ess)?` | `flight attendant` |
| `tribes(?:m[ae]n\|wom[ae]n)` | `tribe member(s)` |
| `waitress` | `waiter` |
| `woman doctor` | `doctor` |
| `woman scientist[s]?` | `scientist(s)` |
| `work(?:m[ae]n\|wom[ae]n)` | `worker(s)` |
| Current text | Replacement text |
| ----------------------------- | ----------------------------- |
| `(?:alumnae\|alumni)` | `graduates` |
| `(?:alumna\|alumnus)` | `graduate` |
| `air(?:m[ae]n\|wom[ae]n)` | `pilot(s)` |
| `anchor(?:m[ae]n\|wom[ae]n)` | `anchor(s)` |
| `authoress` | `author` |
| `camera(?:m[ae]n\|wom[ae]n)` | `camera operator(s)` |
| `door(?:m[ae]\|wom[ae]n)` | `concierge(s)` |
| `draft(?:m[ae]n\|wom[ae]n)` | `drafter(s)` |
| `fire(?:m[ae]n\|wom[ae]n)` | `firefighter(s)` |
| `fisher(?:m[ae]n\|wom[ae]n)` | `fisher(s)` |
| `fresh(?:m[ae]n\|wom[ae]n)` | `first-year student(s)` |
| `garbage(?:m[ae]n\|wom[ae]n)` | `waste collector(s)` |
| `lady lawyer` | `lawyer` |
| `ladylike` | `courteous` |
| `mail(?:m[ae]n\|wom[ae]n)` | `mail carriers` |
| `man and wife` | `husband and wife` |
| `man enough` | `strong enough` |
| `mankind` | `human kind\|humanity` |
| `manmade` | `manufactured` |
| `manpower` | `personnel` |
| `middle(?:m[ae]n\|wom[ae]n)` | `intermediary` |
| `news(?:m[ae]n\|wom[ae]n)` | `journalist(s)` |
| `ombuds(?:man\|woman)` | `ombuds` |
| `oneupmanship` | `upstaging` |
| `poetess` | `poet` |
| `police(?:m[ae]n\|wom[ae]n)` | `police officer(s)` |
| `repair(?:m[ae]n\|wom[ae]n)` | `technician(s)` |
| `sales(?:m[ae]n\|wom[ae]n)` | `salesperson or sales people` |
| `service(?:m[ae]n\|wom[ae]n)` | `soldier(s)` |
| `steward(?:ess)?` | `flight attendant` |
| `tribes(?:m[ae]n\|wom[ae]n)` | `tribe member(s)` |
| `waitress` | `waiter` |
| `woman doctor` | `doctor` |
| `woman scientist[s]?` | `scientist(s)` |
| `work(?:m[ae]n\|wom[ae]n)` | `worker(s)` |

[More information ->](https://developers.google.com/style/inclusive-documentation)

Expand All @@ -217,7 +213,7 @@ _`<CURRENT TEXT>`_ doesn't need a hyphen.

_`<CURRENT TEXT>`_ was matched by one or more of the following regular expressions:

- `\s[^\s-]+ly-`
- `\b[^\s-]+ly-\w+\b`

[More information ->](https://developers.google.com/style/hyphens)

Expand Down
4 changes: 2 additions & 2 deletions vale/Grafana/styles/Grafana/GoogleAMPM.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"message": "Use 'AM' or 'PM' (preceded by a space)."
"nonword": true
"tokens":
- "\\d{1,2}[AP]M"
- "\\d{1,2} ?[ap]m"
- "\\d{1,2}[AP]M\\b"
- "\\d{1,2} ?[ap]m\\b"
- "\\d{1,2} ?[aApP]\\.[mM]\\."
2 changes: 1 addition & 1 deletion vale/Grafana/styles/Grafana/GoogleEmDash.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"action":
"name": "edit"
"params":
- "remove"
- "trim"
- " "
"extends": "existence"
"level": "error"
Expand Down
6 changes: 1 addition & 5 deletions vale/Grafana/styles/Grafana/GoogleGenderBias.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
"anchor(?:m[ae]n|wom[ae]n)": "anchor(s)"
"authoress": "author"
"camera(?:m[ae]n|wom[ae]n)": "camera operator(s)"
"chair(?:m[ae]n|wom[ae]n)": "chair(s)"
"congress(?:m[ae]n|wom[ae]n)": "member(s) of congress"
"door(?:m[ae]|wom[ae]n)": "concierge(s)"
"draft(?:m[ae]n|wom[ae]n)": "drafter(s)"
"fire(?:m[ae]n|wom[ae]n)": "firefighter(s)"
Expand All @@ -22,14 +20,12 @@
"garbage(?:m[ae]n|wom[ae]n)": "waste collector(s)"
"lady lawyer": "lawyer"
"ladylike": "courteous"
"landlord": "building manager"
"mail(?:m[ae]n|wom[ae]n)": "mail carriers"
"man and wife": "husband and wife"
"man enough": "strong enough"
"mankind": "human kind"
"mankind": "human kind|humanity"
"manmade": "manufactured"
"manpower": "personnel"
"men and girls": "men and women"
"middle(?:m[ae]n|wom[ae]n)": "intermediary"
"news(?:m[ae]n|wom[ae]n)": "journalist(s)"
"ombuds(?:man|woman)": "ombuds"
Expand Down
2 changes: 1 addition & 1 deletion vale/Grafana/styles/Grafana/GoogleHeadingPunctuation.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"action":
"name": "edit"
"params":
- "remove"
- "trim_right"
- "."
"extends": "existence"
"level": "warning"
Expand Down
4 changes: 2 additions & 2 deletions vale/Grafana/styles/Grafana/GoogleLyHyphens.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"action":
"name": "edit"
"params":
- "replace"
- "regex"
- "-"
- " "
"extends": "existence"
Expand All @@ -11,4 +11,4 @@
"message": "'%s' doesn't need a hyphen."
"nonword": true
"tokens":
- "\\s[^\\s-]+ly-"
- "\\b[^\\s-]+ly-\\w+\\b"
2 changes: 1 addition & 1 deletion vale/Grafana/styles/Grafana/GoogleOptionalPlurals.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"action":
"name": "edit"
"params":
- "remove"
- "trim_right"
- "(s)"
"extends": "existence"
"level": "error"
Expand Down
10 changes: 5 additions & 5 deletions vale/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ GIT_ROOT := $(shell git rev-parse --show-toplevel)

DICTIONARIES := Grafana/styles/config/dictionaries/en_US-grafana.dic
TESTS := fixtures/Grafana
STYLES := Grafana/styles/Grafana/GrafanaGoogle Grafana/styles/Grafana/Readability
STYLES := Grafana/styles/Grafana/Google Grafana/styles/Grafana/Readability
RULES := Grafana/styles/Grafana/Acronyms.yml Grafana/styles/Grafana/AmazonProductNames.yml Grafana/styles/Grafana/ApacheProjectNames.yml Grafana/styles/Grafana/GoogleProductNames.yml Grafana/styles/Grafana/Headings.yml Grafana/styles/Grafana/ProductPossessives.yml Grafana/styles/Grafana/WordList.yml
DOCUMENTATION := ../docs/sources/review/lint-prose/rules.md

Expand All @@ -30,7 +30,7 @@ Grafana/styles/config/dictionaries/en_US-grafana.%: dictionary.libsonnet

.PHONY: grafana/vale
grafana/vale: ## Builds a container image for Vale with the Grafana style loaded.
grafana/vale: Grafana/styles/config/dictionaries/en_US-grafana.aff Grafana/styles/config/dictionaries/en_US-grafana.dic Grafana/styles/Grafana/GrafanaGoogle .vale.ini
grafana/vale: Grafana/styles/config/dictionaries/en_US-grafana.aff Grafana/styles/config/dictionaries/en_US-grafana.dic Grafana/styles/Grafana/Google .vale.ini
$(PODMAN) build \
--platform linux/x86_64,linux/arm64 \
--progress plain \
Expand Down Expand Up @@ -60,9 +60,9 @@ sync:
jsonnet -Se "(import '.vale.jsonnet').container" | sed '$${/^$$/d;}' > .vale.ini
jsonnet -Se "(import '.vale.jsonnet').repository" | sed '$${/^$$/d;}' > ../.vale.ini

.PHONY: Grafana/styles/Grafana/GrafanaGoogle
Grafana/styles/Grafana/GrafanaGoogle: ## Generate the Grafana style from the Google style.
Grafana/styles/Grafana/GrafanaGoogle: google.jsonnet
.PHONY: Grafana/styles/Grafana/Google
Grafana/styles/Grafana/Google: ## Generate the Grafana style from the Google style.
Grafana/styles/Grafana/Google: google.jsonnet
rm -f "$$(jsonnet -Se 'std.join(" ", std.objectFields(import "google.jsonnet"))')"
jsonnet -S -m . google.jsonnet
prettier -w $@*.yml
Expand Down
77 changes: 39 additions & 38 deletions vale/google.jsonnet
Original file line number Diff line number Diff line change
@@ -1,47 +1,48 @@
std.prune({
'Grafana/styles/Grafana/GrafanaGoogleAMPM.yml': std.manifestYamlDoc(std.parseYaml(importstr 'Google/AMPM.yml')),
// Replaced by Grafana/styles/GrafanaAcronyms.yml.
'Grafana/styles/Grafana/GrafanaGoogleAcronyms.yml': null,
'Grafana/styles/Grafana/GoogleAMPM.yml': std.manifestYamlDoc(std.parseYaml(importstr 'Google/AMPM.yml')),
// Replaced by Grafana/Acronyms.yml.
'Grafana/styles/Grafana/GoogleAcronyms.yml': null,
// Not sure that this is that useful.
'Grafana/styles/Grafana/GrafanaGoogleColons.yml': null,
'Grafana/styles/Grafana/GrafanaGoogleContractions.yml': std.manifestYamlDoc(std.parseYaml(importstr 'Google/Contractions.yml')),
'Grafana/styles/Grafana/GrafanaGoogleDateFormat.yml': std.manifestYamlDoc(std.parseYaml(importstr 'Google/DateFormat.yml')),
'Grafana/styles/Grafana/GrafanaGoogleEllipses.yml': std.manifestYamlDoc(std.parseYaml(importstr 'Google/Ellipses.yml')),
// Replaced by Grafana/styles/GrafanaExclamation.yml.
'Grafana/styles/Grafana/GrafanaGoogleExclamation.yml': null,
'Grafana/styles/Grafana/GrafanaGoogleFirstPerson.yml': std.manifestYamlDoc(std.parseYaml(importstr 'Google/FirstPerson.yml')),
'Grafana/styles/Grafana/GrafanaGoogleGender.yml': std.manifestYamlDoc(std.parseYaml(importstr 'Google/Gender.yml')),
'Grafana/styles/Grafana/GrafanaGoogleGenderBias.yml': std.manifestYamlDoc(std.parseYaml(importstr 'Google/GenderBias.yml')),
'Grafana/styles/Grafana/GrafanaGoogleHeadingPunctuation.yml': std.manifestYamlDoc(std.parseYaml(importstr 'Google/HeadingPunctuation.yml')),
// Replaced by Grafana/styles/GrafanaHeadings.yml.
'Grafana/styles/Grafana/GrafanaGoogleHeadings.yml': null,
// Replaced by Grafana/styles/GrafanaLatin.yml.
'Grafana/styles/Grafana/GrafanaGoogleLatin.yml': null,
'Grafana/styles/Grafana/GrafanaGoogleLyHyphens.yml': std.manifestYamlDoc(std.parseYaml(importstr 'Google/LyHyphens.yml')),
'Grafana/styles/Grafana/GrafanaGoogleOptionalPlurals.yml': std.manifestYamlDoc(std.parseYaml(importstr 'Google/OptionalPlurals.yml')),
// Replaced by Grafana/styles/GrafanaOrdinal.yml.
'Grafana/styles/Grafana/GrafanaGoogleOrdinal.yml': null,
'Grafana/styles/Grafana/GrafanaGoogleOxfordComma.yml': std.manifestYamlDoc(std.parseYaml(importstr 'Google/OxfordComma.yml') { level: 'suggestion' }),
// Replaced by Grafana/styles/GrafanaParentheses.yml.
'Grafana/styles/Grafana/GrafanaGoogleParens.yml': null,
'Grafana/styles/Grafana/GrafanaGooglePassive.yml': std.manifestYamlDoc(std.parseYaml(importstr 'Google/Passive.yml')),
'Grafana/styles/Grafana/GrafanaGooglePeriods.yml': std.manifestYamlDoc(std.parseYaml(importstr 'Google/Periods.yml')),
'Grafana/styles/Grafana/GoogleColons.yml': null,
'Grafana/styles/Grafana/GoogleContractions.yml': std.manifestYamlDoc(std.parseYaml(importstr 'Google/Contractions.yml')),
'Grafana/styles/Grafana/GoogleDateFormat.yml': std.manifestYamlDoc(std.parseYaml(importstr 'Google/DateFormat.yml')),
'Grafana/styles/Grafana/GoogleEllipses.yml': std.manifestYamlDoc(std.parseYaml(importstr 'Google/Ellipses.yml')),
'Grafana/styles/Grafana/GoogleEmDash.yml': std.manifestYamlDoc(std.parseYaml(importstr 'Google/EmDash.yml')),
// Replaced by Grafana/Exclamation.yml.
'Grafana/styles/Grafana/GoogleExclamation.yml': null,
'Grafana/styles/Grafana/GoogleFirstPerson.yml': std.manifestYamlDoc(std.parseYaml(importstr 'Google/FirstPerson.yml')),
'Grafana/styles/Grafana/GoogleGender.yml': std.manifestYamlDoc(std.parseYaml(importstr 'Google/Gender.yml')),
'Grafana/styles/Grafana/GoogleGenderBias.yml': std.manifestYamlDoc(std.parseYaml(importstr 'Google/GenderBias.yml')),
'Grafana/styles/Grafana/GoogleHeadingPunctuation.yml': std.manifestYamlDoc(std.parseYaml(importstr 'Google/HeadingPunctuation.yml')),
// Replaced by Grafana/Headings.yml.
'Grafana/styles/Grafana/GoogleHeadings.yml': null,
// Replaced by Grafana/Latin.yml.
'Grafana/styles/Grafana/GoogleLatin.yml': null,
'Grafana/styles/Grafana/GoogleLyHyphens.yml': std.manifestYamlDoc(std.parseYaml(importstr 'Google/LyHyphens.yml')),
'Grafana/styles/Grafana/GoogleOptionalPlurals.yml': std.manifestYamlDoc(std.parseYaml(importstr 'Google/OptionalPlurals.yml')),
// Replaced by Grafana/Ordinal.yml.
'Grafana/styles/Grafana/GoogleOrdinal.yml': null,
'Grafana/styles/Grafana/GoogleOxfordComma.yml': std.manifestYamlDoc(std.parseYaml(importstr 'Google/OxfordComma.yml') { level: 'suggestion' }),
// Replaced by Grafana/Parentheses.yml.
'Grafana/styles/Grafana/GoogleParens.yml': null,
'Grafana/styles/Grafana/GooglePassive.yml': std.manifestYamlDoc(std.parseYaml(importstr 'Google/Passive.yml')),
'Grafana/styles/Grafana/GooglePeriods.yml': std.manifestYamlDoc(std.parseYaml(importstr 'Google/Periods.yml')),
// Google.Quotes more often a false positive for usage.
'Grafana/styles/Grafana/GrafanaGoogleQuotes.yml': null,
'Grafana/styles/Grafana/GrafanaGoogleRanges.yml': std.manifestYamlDoc(std.parseYaml(importstr 'Google/Ranges.yml')),
'Grafana/styles/Grafana/GrafanaGoogleSemicolons.yml': std.manifestYamlDoc(std.parseYaml(importstr 'Google/Semicolons.yml')),
'Grafana/styles/Grafana/GrafanaGoogleSlang.yml': std.manifestYamlDoc(std.parseYaml(importstr 'Google/Slang.yml')),
'Grafana/styles/Grafana/GrafanaGoogleSpacing.yml': std.manifestYamlDoc(std.parseYaml(importstr 'Google/Spacing.yml')),
'Grafana/styles/Grafana/GrafanaGoogleSpelling.yml': std.manifestYamlDoc(std.parseYaml(importstr 'Google/Spelling.yml')),
'Grafana/styles/Grafana/GoogleQuotes.yml': null,
'Grafana/styles/Grafana/GoogleRanges.yml': std.manifestYamlDoc(std.parseYaml(importstr 'Google/Ranges.yml')),
'Grafana/styles/Grafana/GoogleSemicolons.yml': std.manifestYamlDoc(std.parseYaml(importstr 'Google/Semicolons.yml')),
'Grafana/styles/Grafana/GoogleSlang.yml': std.manifestYamlDoc(std.parseYaml(importstr 'Google/Slang.yml')),
'Grafana/styles/Grafana/GoogleSpacing.yml': std.manifestYamlDoc(std.parseYaml(importstr 'Google/Spacing.yml')),
'Grafana/styles/Grafana/GoogleSpelling.yml': std.manifestYamlDoc(std.parseYaml(importstr 'Google/Spelling.yml')),
// More often than not, we need to be consistent with Prometheus units or units used Grafana UI which are not represented in the form encouraged by SI.
'Grafana/styles/Grafana/GrafanaGoogleUnits.yml': null,
// Replaced by Grafana/styles/GrafanaWe.yml.
'Grafana/styles/Grafana/GrafanaGoogleWe.yml': null,
'Grafana/styles/Grafana/GrafanaGoogleWill.yml': std.manifestYamlDoc(std.parseYaml(importstr 'Google/Will.yml') {
'Grafana/styles/Grafana/GoogleUnits.yml': null,
// Replaced by Grafana/We.yml.
'Grafana/styles/Grafana/GoogleWe.yml': null,
'Grafana/styles/Grafana/GoogleWill.yml': std.manifestYamlDoc(std.parseYaml(importstr 'Google/Will.yml') {
message: super.message + '\n\n' + |||
Use present tense for statements that describe general behavior that's not associated with a particular time.
|||,
}),
// Replaced by Grafana/styles/GrafanaWordList.yml.
'Grafana/styles/Grafana/GrafanaGoogleWordList.yml': null,
// Replaced by Grafana/WordList.yml.
'Grafana/styles/Grafana/GoogleWordList.yml': null,
})

0 comments on commit 7618ba3

Please sign in to comment.