-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add initial vale configuration and apply editorial changes to documen…
…tation (#3567) * Fix editorial issues raised by Vale * Add vale configuration * Prepare vale pre-commit hook * Add .vale/justfile to help local development of styles * Generate DAG docs for Vale editorial change * Configure easier to use just recipes * Revert unnecessary lint recipe changes * Update Vale config documentation * Always run using local Vale docker image and pin Vale package versions * Prevent CI docker issue * Check all markdown files, not just documentation site * Prevent false positives for term casing * Check admonition blocks * Include mdx as markdown * Add .vale to CODEOWNERS * Address vale errors for files added during rebase
- Loading branch information
1 parent
6d8bf25
commit e12fd14
Showing
42 changed files
with
298 additions
and
90 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
styles/* | ||
!styles/Vocab/ | ||
!styles/Openverse/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
StylesPath = styles | ||
|
||
MinAlertLevel = suggestion | ||
Vocab = Openverse | ||
# Using an explicit reference to downloads for package zips rather than the shorthand allows us to | ||
# pin the package to a specific version. Otherwise, changes in the upstream style configuration can | ||
# cause sudden and unexpected failures during linting. | ||
Packages = https://github.com/errata-ai/proselint/releases/download/v0.3.3/proselint.zip | ||
|
||
# The default settings also ignore `pre` and `code`, which includes admonition code blocks. | ||
# We may encounter false positives by including code blocks, but we use admonitions | ||
# so frequently in Openverse documentation that it is probably worth it to include them. | ||
SkippedScopes = script, style, figure | ||
IgnoredScopes = tt | ||
|
||
[formats] | ||
# Treat mdx as markdown (for Storybook support) | ||
mdx = md | ||
|
||
# Only configure Markdown, because that's the only language we use to write documentation in | ||
# (Except MDX, but if we want to add Vale there it will have to be at a later date to avoid complexity | ||
# in the initial setup) | ||
[*.md] | ||
BasedOnStyles = proselint, Vale, Openverse | ||
|
||
# Avoid Vale.Spelling for now, but we do want Vale.Terms for the vocab at least | ||
Vale.Spelling = NO | ||
|
||
# The suggested terms are obscure | ||
proselint.AnimalLabels = NO | ||
|
||
# These are rarely necessary changes and can be more fiddly than they are helpful | ||
proselint.Typography = NO | ||
|
||
# proselint.Needless considers a host of terms "needless" which are natural and wide-spread changes in the English language, | ||
# and is clearly favouring US changes rather than others (the US isn't the only or even the largest English speaking country). | ||
# You don't have to look far to find examples of this rule preferring variants of terms in line with 18th century elite preferences: | ||
# https://www.merriam-webster.com/grammar/preventive-or-preventative | ||
# In other words, it's a linguistic prescriptive holdover to insist on some of these terms being "needless" when they're in | ||
# fact widespread and well understood. Not all the terms have this issue, but we'd have to rewrite | ||
# practically the entire rule to sort out which ones we cared about. If we find any we _do_ care about, we can add them to our | ||
# own substitution rule. | ||
proselint.Needless = NO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM jdkato/vale:v2.30.0 | ||
|
||
WORKDIR /vale | ||
COPY .vale.ini . | ||
COPY styles styles | ||
|
||
RUN vale sync | ||
|
||
ENTRYPOINT ["vale", "--config=/vale/.vale.ini"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Openverse Vale configuration | ||
|
||
Openverse runs Vale using Docker. This bypasses the need for contributors to | ||
install the Vale binary on their computers. It also prevents Vale styles getting | ||
downloaded into the repository in clear text, which is critical to avoid lists | ||
of sensitive terms being accidentally too-easily available. | ||
|
||
For more information about this motivation to avoid lists of sensitive terms in | ||
the Openverse monorepo, refer to the README at | ||
[WordPress/openverse-sensitive-terms](https://github.com/WordPress/openverse-sensitive-terms). | ||
|
||
To run Vale with Openverse's configuration, use the just recipe: | ||
|
||
``` | ||
$ just .vale/run | ||
``` | ||
|
||
This recipe _always_ builds Vale. The Openverse Vale docker image is fast to | ||
build, and the most expensive steps are cached. Docker will automatically reuse | ||
the pre-existing image unless there are changes to the Vale configuration. | ||
|
||
Typically it is unnecessary to run Vale directly, as pre-commit automatically | ||
runs Vale on each commit. You only need to run Vale directly when iterating on | ||
changes to Openverse's Vale configuration. | ||
|
||
Refer to the `VALE_FILES` variable [in the justfile](./justfile) to identify | ||
which files we currently check with Vale. A comment on the variable explains the | ||
rationale for that choice. The list of files will ideally expand in the future | ||
to include all textual content in the repository. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
COLOR := "\\033[0;34m" | ||
NO_COLOR := "\\033[0m" | ||
|
||
|
||
# Show all available recipes | ||
@_default: | ||
printf "\n{{ COLOR }}# Vale (path: \`.vale/\`)\n" | ||
printf "===================={{ NO_COLOR }}\n" | ||
just --list --unsorted | ||
|
||
|
||
# Build a local version of `openverse-vale:local` for testing | ||
build: | ||
docker build . -t openverse-vale:local | ||
|
||
|
||
# The --glob setting excludes things that should not be linted, including | ||
# build artefacts, dependencies, and automatically generated files like | ||
# the changelogs (without excluding `changelogs/index.md`). Project proposals | ||
# are also excluded for want of a good way to ignore existing proposals and only | ||
# lint _new_ proposals. Project proposals aren't "living documents" in the way | ||
# the rest of our documentation is, so it doesn't seem right to retroactively | ||
# edit them for mere editorial purposes (rather than, for example, to correct | ||
# some grave inacurracy). | ||
# Leading `,` compensates for lack of trailing comma support | ||
# Note the lack of space before the trailing \ on each line, this is to prevent | ||
# the addition of a space between each pattern, which isn't supported by Vale's glob | ||
# If you change this and Vale takes a very long time to run (more than 30 seconds) | ||
# then chances are the change is breaking the glob pattern. Unfortunately the only | ||
# feedback you get when the glob pattern is not working as intended is a very long | ||
# run time for Vale as it checks everything that should have otherwise been ignored, | ||
# but wasn't due to some minor issue in the pattern syntax. | ||
# This is fiddly, but I can't find a good way around it. | ||
_IGNORE_PATTERNS := """ | ||
_build\ | ||
,_static\ | ||
,venv\ | ||
,.venv\ | ||
,.nuxt\ | ||
,.pnpm-store\ | ||
,node_modules\ | ||
,test-results\ | ||
,storebook-static\ | ||
,.ruff-cache\ | ||
,projects/proposals\ | ||
,changelogs/api\ | ||
,changelogs/frontend\ | ||
,changelogs/catalog\ | ||
,changelogs/ingestion_server\ | ||
""" | ||
|
||
VALE_GLOB := "--glob='!*{" + _IGNORE_PATTERNS + "}*'" | ||
|
||
|
||
# Run Vale configured for Openverse in Docker. | ||
# Using Docker avoids the need for contributors to install the Vale binary. | ||
#Configuration defaults to what is used for CI. | ||
run +files=".": build | ||
docker run --rm \ | ||
-v $PWD/..:/src:rw,Z \ | ||
--workdir=/src \ | ||
openverse-vale:local \ | ||
{{ files }} \ | ||
{{ VALE_GLOB }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Openverse vale style | ||
|
||
The Openverse vale style is manually curated by Openverse maintainers. These | ||
rules are primarily meant to cater to exceptions in the Openverse documentation | ||
style that do not fit into pre-existing style guides, whether because of | ||
disagreements in style or different institutional or contextual requirements | ||
based on Openverse's domain and nature as a FOSS project within the WordPress | ||
community. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# While Vale.Terms could be used for these, it is too inflexible, and thus incapable | ||
# of ignoring common false-positives like GitHub usernames or GitHub team names | ||
extends: substitution | ||
message: "Incorrect casing. Use '%s' instead of '%s'." | ||
level: error | ||
ignorecase: false | ||
scope: | ||
- paragraph | ||
swap: | ||
# [^/\.] prevents matching things that look like URLs, file paths, or GitHub team mentions | ||
# For example: @WordPress/openverse-maintainers | ||
'[^/\.]openverse[^.\.]': Openverse | ||
# OpenVerse should never be used, except as an example of something that is always wrong, | ||
# in which case we'll tell Vale to ignore that line. | ||
"OpenVerse": Openverse | ||
'[^/\.]wordpress[^.\.]': WordPress | ||
# Wordpress is the same as OpenVerse | ||
"Wordpress": WordPress | ||
'[^/\.]github[^.\.]': GitHub | ||
# Github is the same as Wordpress and OpenVerse | ||
"Github": GitHub |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# This matches "cliche" rulesets, but we actually use this term in earnest and with clear explanation of what we mean by it | ||
Decision-Making Process | ||
decision-making process |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.