Skip to content

Commit

Permalink
[docs] [revamp] - Beefing up Vale (#23754)
Browse files Browse the repository at this point in the history
## Summary & Motivation

This PR beefs up our Vale implementation with some custom rules and
vocabularies. The README for this will be updated in a subsequent PR.

## How I Tested These Changes

eyes, local
  • Loading branch information
erinkcochran87 authored and PedramNavid committed Aug 20, 2024
1 parent 3bd53c0 commit 41fc8e5
Show file tree
Hide file tree
Showing 60 changed files with 331 additions and 590 deletions.
46 changes: 27 additions & 19 deletions docs/.vale.ini
Original file line number Diff line number Diff line change
@@ -1,28 +1,36 @@
StylesPath = "vale/styles"
MinAlertLevel = suggestion
########################
# ABOUT #
########################

Packages = Google
Vocab = Dagster
# This file controls the Vale application, specifically what, where, and how it lints.

[*.{md,mdx,rst}]
BasedOnStyles = Vale, Google, Dagster
# Vale config reference: https://vale.sh/docs/topics/config
# INI syntax: https://ini.unknwon.io/docs/intro

; Ignore all :py directives
IgnorePatterns = (:py:[^`]+`[^`]+`)
########################
# CORE SETTINGS #
########################

StylesPath = "vale/styles"
MinAlertLevel = suggestion
Vocab = Dagster

; Error on headings that aren't sentence cased.
Google.Headings = Error
########################
# FORMAT ASSOCIATIONS #
########################

; Google avoids using will, we don't need to check for this
Google.Will = NO
Google.WordList = NO
[formats]
mdx = md

; Exclamation is fine
Google.Exclamation = NO
########################
# FORMAT-SPECIFIC #
########################

; Passive is a bit too noisy
Google.Passive = NO
[*.{md,mdx,rst}]
# Rules in this section are enforced in all md, mdx, and rst files

[*.{md,mdx,rst}]
BasedOnStyles = Dagster, Terms, Vale

[formats]
mdx = md
; Ignore all :py directives
IgnorePatterns = (:py:[^`]+`[^`]+`)
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ exceptions:
- DEBUG
- DOM
- DPI
- ETL
- FAQ
- GCC
- GDB
Expand All @@ -43,17 +44,21 @@ exceptions:
- POST
- RAM
- REPL
- REST
- RSA
- SCM
- SCSS
- SDA
- SDK
- SFTP
- SQL
- SSH
- SSL
- SVG
- TBD
- TCP
- TODO
- UI
- URI
- URL
- USB
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
extends: existence
message: "Remove whitespace characters from the end of the line."
link: https://docs.gitlab.com/ee/development/documentation/versions.html
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
## This rule finds capitalized words immediately following a colon (:)

extends: existence
message: "'%s' should be in lowercase."
link: 'https://developers.google.com/style/colons'
nonword: true
level: warning
scope: sentence
tokens:
- ':\s[A-Z]'
- ':\s[A-Z]'
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ swap:
what is: what's
when is: when's
where is: where's
will not: won't
will not: won't
20 changes: 0 additions & 20 deletions docs/vale/styles/Dagster/dagster_terms.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@ action:
- trim
- " "
tokens:
- '\s[—–]\s'

- '\s[—–]\s'
14 changes: 14 additions & 0 deletions docs/vale/styles/Dagster/gender.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
extends: existence
message: "Use a gender-neutral pronoun instead of '%s'."
link: "https://github.com/DataDog/documentation/blob/master/CONTRIBUTING.md#gender"
level: error
ignorecase: true
tokens:
- he/she
- s/he
- \(s\)he
- \bhe\b
- \bhim\b
- \bhis\b
- \bshe\b
- \bher\b
11 changes: 11 additions & 0 deletions docs/vale/styles/Dagster/heading-characters.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## This rule finds non-allowed characters in headings
## WHY? Headings don't need periods or formatting, ex: `@asset`

extends: existence
message: "Headings shouldn't have periods or other Markdown formatting"
level: error
scope: heading
ignorecase: false
nonword: true
raw:
- '`|(?<=.)\.$'
1 change: 0 additions & 1 deletion docs/vale/styles/Dagster/heading-content.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ ignorecase: true
nonword: true
scope: raw
tokens:
- '\#+ How it works'
- '\#+ Overview'
8 changes: 8 additions & 0 deletions docs/vale/styles/Dagster/headings-casing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## This rule finds section headings that don't use sentence casing.
## Ex: This is correct, but This Is Not Correct

extends: capitalization
message: "'%s' should be in sentence case"
level: error
scope: heading
match: $sentence
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## This rule flags gerunds (ex: "Linting" versus "Lint") in section headings
## WHY? Gerunds don't always translate well into other languages

extends: existence
message: Section '%v' should not start with a gerund (verb ending in "ing")
level: error
Expand Down
File renamed without changes.
File renamed without changes.
26 changes: 26 additions & 0 deletions docs/vale/styles/Dagster/link-text.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
## This rule flags vague language in links. Links should tell the user where you're sending them.

extends: substitution
message: "Avoid vague text in links like '%s' unless you can pair it with more descriptive text."
link: 'https://github.com/DataDog/documentation/blob/master/CONTRIBUTING.md#links'
ignorecase: true
scope: raw
nonword: true
level: warning

swap:
# For the word 'here' in Markdown and HTML links
'\[here\]\(.*?\)': 'here'
'<a\s*href\s*=\s*".*?".*?>\s*here\s*</a>': 'here'

# For the word 'this' in Markdown and HTML links
'\[this\]\(.*?\)': 'this'
'<a\s*href\s*=\s*".*?".*?>\s*this\s*</a>': 'this'

# For the word 'page' in Markdown and HTML links
'\[page\]\(.*?\)': 'page'
'<a\s*href\s*=\s*".*?".*?>\s*page\s*</a>': 'page'

# For the phrase 'this page' in Markdown and HTML links
'\[this page\]\(.*?\)': 'this page'
'<a\s*href\s*=\s*".*?".*?>\s*this page\s*</a>': 'this page'
9 changes: 9 additions & 0 deletions docs/vale/styles/Dagster/missing-tos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## This rule finds missing instances of 'to'. Ex: It would be great // // write a story.

extends: sequence
message: "Missing 'to': Did you mean '%[2]s %[3]s *to* %[4]s'?"
tokens:
- tag: MD
- pattern: be
- tag: JJ
- tag: VB|VBN
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
## This rule finds optional plurals in parentheses. Ex: 'The tag(s)'' instead of 'The tag or tags'

extends: existence
message: "Don't use plurals in parentheses such as in '%s'."
link: "https://developers.google.com/style/plurals-parentheses"
Expand All @@ -9,4 +11,4 @@ action:
- trim_right
- "(s)"
tokens:
- '\b\w+\(s\)'
- '\b\w+\(s\)'
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ link: 'https://developers.google.com/style/commas'
scope: sentence
level: warning
tokens:
- '(?:[^,]+,){1,}\s\w+\s(?:and|or)'
- '(?:[^,]+,){1,}\s\w+\s(?:and|or)'
File renamed without changes.
13 changes: 0 additions & 13 deletions docs/vale/styles/Dagster/programming.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
extends: existence
message: "Commas and periods go inside quotation marks."
message: "Commas, exclamation points, and periods go inside quotation marks."
link: 'https://developers.google.com/style/quotation-marks'
level: error
nonword: true
tokens:
- '"[^"]+"[.,?]'
- '"[^"]+"[.,?]'
8 changes: 8 additions & 0 deletions docs/vale/styles/Dagster/readability.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
extends: metric
message: "Try to keep the Automated Readability Index (%s) below 8."
link: https://en.wikipedia.org/wiki/Automated_readability_index

formula: |
(4.71 * (characters / words)) + (0.5 * (words / sentences)) - 21.43
condition: "> 8"
8 changes: 8 additions & 0 deletions docs/vale/styles/Dagster/repeated-words.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## This rule catches instances of repeated words. Ex: This //is is// a sentence.

extends: repetition
message: "'%s' is repeated!"
level: error
alpha: true
tokens:
- '[^\s]+'
7 changes: 0 additions & 7 deletions docs/vale/styles/Dagster/section-heading-depth.yml

This file was deleted.

5 changes: 0 additions & 5 deletions docs/vale/styles/Dagster/section-heading-sentence-case.yml

This file was deleted.

45 changes: 45 additions & 0 deletions docs/vale/styles/Dagster/sentence-length-variety.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
extends: script
message: "This paragraph has a stdev less than 2"
link: https://tengolang.com/
scope: paragraph
script: |
text := import("text")
math := import("math")
matches := []
each := func(seq, fn) {
for x in seq {
fn(x)
}
}
sum := func(seq) {
s := 0
each(seq, func(x) {
s += x
})
return s
}
stdev := func(seq) {
size := len(seq)
mean := sum(seq) / size
sd := 0.0
each(seq, func(x) {
sd += math.pow(x - mean, 2)
})
return math.sqrt(sd / size)
}
lengths := []
for sent in text.re_split(`[.!?] `, scope, -1) {
lengths = append(lengths, len(text.fields(sent)))
}
computed := stdev(lengths)
if computed < 2 && len(lengths) >= 3 {
matches = append(matches, {begin: 0, end: len(scope)})
}
10 changes: 10 additions & 0 deletions docs/vale/styles/Dagster/spacing.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
extends: existence
message: "Use only one space between words and sentences (not two)."
link: 'https://developers.google.com/style/sentence-spacing'
level: error
nonword: true
action:
name: remove
tokens:
- '[a-z][.?!] {2,}[A-Z]'
- '[a-z][.?!][A-Z]'
6 changes: 6 additions & 0 deletions docs/vale/styles/Dagster/spelling.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Uses the built-in dictionary and filters.
extends: spelling
message: "Is '%s' spelled correctly?"
level: error
ignore:
- ignore.txt
11 changes: 11 additions & 0 deletions docs/vale/styles/Dagster/todos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This rule will flag "TODO" or "todo" unless they occur inside HTML comments.

extends: existence
message: "Remove or comment out TODOs."
level: error
scope: text
ignorecase: true
tokens:
- '\b[Tt][Oo][Dd][Oo]\b'
exceptions:
- '<!--.*?\b[Tt][Oo][Dd][Oo]\b.*?-->'
Loading

0 comments on commit 41fc8e5

Please sign in to comment.