Skip to contentSkip to conversation

manuals: add initial stylechecks with Vale

PATCH In review [email protected] 3 participants 5 messages Mar 12, 2024 – Mar 13, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 manuals: add initial stylechecks with Vale

From: Michael Opdenacker <[email protected]>

Use the "Vale" (https://vale.sh) tool to perform text style checks Run "make stylecheck" to run the checks.

This just checks the text, not the Sphinx syntax style choices.

---

See https://lwn.net/Articles/964075/ for a recent introduction. Don't hesitate to run the checks, propose fixes for the reported issues and improvements to the checking rules and accepted words!

---
 documentation/.gitignore                          |  2 ++
 documentation/.vale.ini                           |  7 +++++++
 documentation/Makefile                            |  9 ++++++++-
 documentation/README                              | 14 ++++++++++++++
 documentation/standards.md                        | 15 +++++++++++++++
 .../config/vocabularies/OpenSource/accept.txt     |  4 ++++
 .../styles/config/vocabularies/Yocto/accept.txt   |  4 ++++
 7 files changed, 54 insertions(+), 1 deletion(-)
 create mode 100644 documentation/.vale.ini
 create mode 100644 documentation/styles/config/vocabularies/OpenSource/accept.txt
 create mode 100644 documentation/styles/config/vocabularies/Yocto/accept.txt
documentation/.gitignore +2 -0
index 494b4f4de5..b23d598054 100644
@@ -7,3 +7,5 @@ releases.rst
 .vscode/
 */svg/*.png
 */svg/*.pdf
+styles/*
+!styles/config
documentation/.vale.ini new file +7 -0
new file mode 100644
index 0000000000..02042bb632
@@ -0,0 +1,7 @@
+StylesPath = styles
+MinAlertLevel = suggestion
+Packages = RedHat, proselint, write-good, alex, Readability, Joblint
+Vocab = Yocto, OpenSource
+[*.rst]
+BasedOnStyles = Vale, RedHat, proselint, write-good, alex, Readability, Joblint
+
documentation/Makefile +8 -1
index 9fb6814c8f..e1b61f17f1 100644
@@ -5,6 +5,9 @@
 # from the environment for the first two.
 SPHINXOPTS    ?= -W --keep-going -j auto
 SPHINXBUILD   ?= sphinx-build
+# Release notes are excluded because they contain contributor names and commit messages which can't be modified
+VALEOPTS      ?= --no-wrap --no-wrap --glob '!migration-guides/release-notes-*.rst'
+VALEDOCS      ?= .
 SOURCEDIR     = .
 IMAGEDIRS     = */svg
 BUILDDIR      = _build
@@ -20,7 +23,7 @@ endif
 help:
 	@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
 
-.PHONY: all help Makefile clean publish epub latexpdf
+.PHONY: all help Makefile clean stylecheck publish epub latexpdf
 
 publish: Makefile html singlehtml
 	rm -rf $(BUILDDIR)/$(DESTDIR)/
@@ -46,6 +49,10 @@ PNGs := $(foreach dir, $(IMAGEDIRS), $(patsubst %.svg,%.png,$(wildcard $(SOURCED
 clean:
 	@rm -rf $(BUILDDIR) $(PNGs) $(PDFs) poky.yaml sphinx-static/switchers.js
 
+stylecheck:
+	vale init
+	vale $(VALEOPTS) $(VALEDOCS)
+
 epub: $(PNGs)
 	$(SOURCEDIR)/set_versions.py
 	@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
documentation/README +14 -0
index 4d31036e69..8035418cac 100644
@@ -151,6 +151,20 @@ dependencies in a virtual environment:
  $ pipenv install
  $ pipenv run make html
 
+Style checking the Yocto Project documentation
+==============================================
+
+The project is starting to use Vale (https://vale.sh/)
+to validate the text style.
+
+To install Vale:
+
+ $ pip install vale
+
+To run Vale:
+
+ $ make stylecheck
+
 Sphinx theme and CSS customization
 ==================================
 
documentation/standards.md +15 -0
index 9f4771ebd9..a4f8be0dcf 100644
@@ -5,6 +5,21 @@ documentation is created.
 
 It is currently a work in progress.
 
+## Automatic style validation
+
+There is an ongoing effort to automate style validation
+through the [Vale](https://vale.sh/). To try it, run:
+
+    $ make vale
+
+Note that this just applies to text. Therefore, the syntax
+conventions described below still apply.
+
+If you wish to add words to the "accept.txt" files
+(./styles/config/vocabularies/<Vocab>/accept.txt),
+make sure the spelling and capitalization matches
+what Wikipedia uses. Wikipedia is our reference!
+
 ## Text standards
 
 ### Bulleted lists
documentation/styles/config/vocabularies/OpenSource/accept.txt new file +4 -0
new file mode 100644
index 0000000000..98e76ae1f5
@@ -0,0 +1,4 @@
+ftrace
+toolchain
+systemd
+LTTng
documentation/styles/config/vocabularies/Yocto/accept.txt new file +4 -0
new file mode 100644
index 0000000000..b725414014
@@ -0,0 +1,4 @@
+Yocto
+BSP
+BitBake
+OpenEmbedded
Signature · 1 line
2.34.1
#1 lore raw

Hi Michael,

Quoted 5 lines · Michael Opdenacker via lists.yoctoproject.org

From: Michael Opdenacker <[email protected]>

Use the "Vale" (https://vale.sh) tool to perform text style checks Run "make stylecheck" to run the checks.

Quoted 8 lines

This just checks the text, not the Sphinx syntax style choices.

---

See https://lwn.net/Articles/964075/ for a recent introduction.

This is an article that requires subscription to LWN unfortunately.

Quoted 46 lines

Don't hesitate to run the checks, propose fixes for the reported issues and improvements to the checking rules and accepted words!
---

documentation/.gitignore                          |  2 ++
documentation/.vale.ini                           |  7 +++++++
documentation/Makefile                            |  9 ++++++++-
documentation/README                              | 14 ++++++++++++++
documentation/standards.md                        | 15 +++++++++++++++
.../config/vocabularies/OpenSource/accept.txt     |  4 ++++
.../styles/config/vocabularies/Yocto/accept.txt   |  4 ++++
7 files changed, 54 insertions(+), 1 deletion(-)

create mode 100644 documentation/.vale.ini
create mode 100644 documentation/styles/config/vocabularies/OpenSource/accept.txt create mode 100644 documentation/styles/config/vocabularies/Yocto/accept.txt

documentation/.gitignore +0 -0
index 494b4f4de5..b23d598054 100644
@@ -7,3 +7,5 @@ releases.rst

.vscode/
*/svg/*.png
*/svg/*.pdf

documentation/.gitignore +2 -0
+styles/*
+!styles/config
documentation/.vale.ini new file +7 -0
new file mode 100644
index 0000000000..02042bb632
@@ -0,0 +1,7 @@
+StylesPath = styles
+MinAlertLevel = suggestion
+Packages = RedHat, proselint, write-good, alex, Readability, Joblint
+Vocab = Yocto, OpenSource
+[*.rst]
+BasedOnStyles = Vale, RedHat, proselint, write-good, alex, Readability, Joblint
+
documentation/Makefile +0 -0
index 9fb6814c8f..e1b61f17f1 100644
@@ -5,6 +5,9 @@
 # from the environment for the first two.

SPHINXOPTS ?= -W --keep-going -j auto
SPHINXBUILD ?= sphinx-build

documentation/Makefile line 9

Quoted 2 lines
documentation/Makefile +2 -0
+# Release notes are excluded because they contain contributor names and commit messages which can't be modified
+VALEOPTS      ?= --no-wrap --no-wrap --glob '!migration-guides/release-notes-*.rst'

Do we really need --no-wrap twice here?

[...]

Quoted 8 lines
documentation/standards.md +0 -0
index 9f4771ebd9..a4f8be0dcf 100644
@@ -5,6 +5,21 @@ documentation is created.
 

It is currently a work in progress.

documentation/standards.md documentation is created. · line 14

Quoted 7 lines
documentation/standards.md +7 -0
+## Automatic style validation
+
+There is an ongoing effort to automate style validation
+through the [Vale](https://vale.sh/). To try it, run:
+
+    $ make vale
+

Isn't this supposed to be make stylecheck here?

Quoted 17 lines
documentation/standards.md +8 -0
+Note that this just applies to text. Therefore, the syntax
+conventions described below still apply.
+
+If you wish to add words to the "accept.txt" files
+(./styles/config/vocabularies/<Vocab>/accept.txt),
+make sure the spelling and capitalization matches
+what Wikipedia uses. Wikipedia is our reference!
+

## Text standards

### Bulleted lists

documentation/styles/config/vocabularies/OpenSource/accept.txt new file +0 -0
new file mode 100644
index 0000000000..98e76ae1f5

documentation/styles/config/vocabularies/OpenSource/accept.txt line 4

Quoted 4 lines
documentation/styles/config/vocabularies/OpenSource/accept.txt new file +4 -0
@@ -0,0 +1,4 @@
+ftrace
+toolchain
+systemd
+LTTng

Are those strings matched even when they are highlighted with simple/double tick quotes? If not, that could be a way to not have to expand this list too often and also it's nice to highlight the name of pieces of SW (well, excluding toolchain from my remark obviously).

Cheers,
Quentin

#2 lore raw

Hi Quentin

I was sure the topic would interest you! Thanks for the review.

Quoted 10 lines · Quentin Schulz

Hi Michael,

Quoted 7 lines · Michael Opdenacker via lists.yoctoproject.org

From: Michael Opdenacker <[email protected]>

Use the "Vale" (https://vale.sh) tool to perform text style checks Run "make stylecheck" to run the checks.

This just checks the text, not the Sphinx syntax style choices.

Quoted 7 lines
Quoted 6 lines

---

See https://lwn.net/Articles/964075/ for a recent introduction.

This is an article that requires subscription to LWN unfortunately.

Ouch, sorry for the oversight. We just have to wait until the article is open to everyone.

Quoted 42 lines
Quoted 42 lines

Don't hesitate to run the checks, propose fixes for the reported issues and improvements to the checking rules and accepted words!
---

documentation/.gitignore                          |  2 ++
documentation/.vale.ini                           |  7 +++++++
documentation/Makefile                            |  9 ++++++++-
documentation/README                              | 14 ++++++++++++++
documentation/standards.md                        | 15 +++++++++++++++
.../config/vocabularies/OpenSource/accept.txt     |  4 ++++
.../styles/config/vocabularies/Yocto/accept.txt   |  4 ++++
7 files changed, 54 insertions(+), 1 deletion(-)

create mode 100644 documentation/.vale.ini
create mode 100644 documentation/styles/config/vocabularies/OpenSource/accept.txt create mode 100644 documentation/styles/config/vocabularies/Yocto/accept.txt

documentation/.gitignore +0 -0
index 494b4f4de5..b23d598054 100644
@@ -7,3 +7,5 @@ releases.rst

.vscode/
*/svg/*.png
*/svg/*.pdf

documentation/.gitignore +2 -0
+styles/*
+!styles/config
documentation/.vale.ini new file +7 -0
new file mode 100644
index 0000000000..02042bb632
@@ -0,0 +1,7 @@
+StylesPath = styles
+MinAlertLevel = suggestion
+Packages = RedHat, proselint, write-good, alex, Readability, Joblint
+Vocab = Yocto, OpenSource
+[*.rst]
+BasedOnStyles = Vale, RedHat, proselint, write-good, alex, Readability, Joblint
+
documentation/Makefile +0 -1
index 9fb6814c8f..e1b61f17f1 100644
--- a/documentation/Makefile
Quoted 8 lines

documentation/Makefile line 9

Quoted 7 lines

+++ b/documentation/Makefile

documentation/Makefile +0 -0
@@ -5,6 +5,9 @@
 # from the environment for the first two.

SPHINXOPTS ?= -W --keep-going -j auto
SPHINXBUILD ?= sphinx-build

documentation/Makefile +2 -0
+# Release notes are excluded because they contain contributor names and commit messages which can't be modified
+VALEOPTS      ?= --no-wrap --no-wrap --glob '!migration-guides/release-notes-*.rst'

Do we really need --no-wrap twice here?

Oops, fixed.

Quoted 11 lines

[...]

Quoted 8 lines
documentation/standards.md +0 -0
index 9f4771ebd9..a4f8be0dcf 100644
@@ -5,6 +5,21 @@ documentation is created.
 

It is currently a work in progress.

Quoted 8 lines

documentation/standards.md documentation is created. · line 14

Quoted 7 lines
documentation/standards.md +7 -0
+## Automatic style validation
+
+There is an ongoing effort to automate style validation
+through the [Vale](https://vale.sh/). To try it, run:
+
+    $ make vale
+

Isn't this supposed to be make stylecheck here?

Oops, fixed too.

Quoted 11 lines
Quoted 11 lines
documentation/standards.md +8 -0
+Note that this just applies to text. Therefore, the syntax
+conventions described below still apply.
+
+If you wish to add words to the "accept.txt" files
+(./styles/config/vocabularies/<Vocab>/accept.txt),
+make sure the spelling and capitalization matches
+what Wikipedia uses. Wikipedia is our reference!
+

## Text standards

Quoted 12 lines

documentation/styles/config/vocabularies/OpenSource/accept.txt line 4

Quoted 11 lines

### Bulleted lists

documentation/styles/config/vocabularies/OpenSource/accept.txt new file +4 -0
new file mode 100644
index 0000000000..98e76ae1f5
@@ -0,0 +1,4 @@
+ftrace
+toolchain
+systemd
+LTTng

Are those strings matched even when they are highlighted with simple/double tick quotes? If not, that could be a way to not have to expand this list too often and also it's nice to highlight the name of pieces of SW (well, excluding toolchain from my remark obviously).

I've just checked by adding a typo, like "Yotco", and found out that:

- ``Yotco`` is not reported

- But "Yotco" is

So, yes, using "``" allows to write any string we want, and the tool won't check such strings. So, this avoids lots of false positives and this can actually help to locate instances when such double quotes are missing!

An issue though. If I add "Yotco" to one of the variable definitions in ref-manual/variables.rst, the typo remains unnoticed! Adding this to my issue list...

Cheers
Michael.

Signature · 3 lines
Michael Opdenacker, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#3 lore raw

Hi Michael,

Quoted 4 lines · Michael Opdenacker via lists.yoctoproject.org

Hi Quentin

I was sure the topic would interest you! Thanks for the review.

It is actually a quite interesting timing, I myself was vaguely looking for linters for our user manuals yesterday.

So I can say I found the following:
- sphinx-lint (https://github.com/sphinx-contrib/sphinx-lint). This mainly complained about tabs being used, but maybe it would find some interesting things in the YP docs?
- sphinxawesome-codelinter (https://github.com/kai687/sphinxawesome-codelinter). This is to run a specific command for snippets inside code blocks with an assigned language. This will be useful to us because we wrote quite a lot of shell scripts in our user manual so having shellcheck run on those will be nice :) For YP/OE though... not sure. I think there's oelint-adv we could use?

[...]

Quoted 13 lines
Quoted 11 lines

documentation/styles/config/vocabularies/OpenSource/accept.txt line 4

Quoted 10 lines
documentation/styles/config/vocabularies/OpenSource/accept.txt new file +4 -0
new file mode 100644
index 0000000000..98e76ae1f5
@@ -0,0 +1,4 @@
+ftrace
+toolchain
+systemd
+LTTng

Are those strings matched even when they are highlighted with simple/double tick quotes? If not, that could be a way to not have to expand this list too often and also it's nice to highlight the name of pieces of SW (well, excluding toolchain from my remark obviously).

Quoted 8 lines

I've just checked by adding a typo, like "Yotco", and found out that:

- ``Yotco`` is not reported

- But "Yotco" is

So, yes, using "``" allows to write any string we want, and the tool won't check such strings. So, this avoids lots of false positives and this can actually help to locate instances when such double quotes are missing!

Thanks for checking!

That was the idea behind my question :) Nice to hear (though.... who's going to check for typos inside those single ticks now :D?).

Cheers,
Quentin

#4 lore raw

Hi Quentin,

Quoted 4 lines · Quentin Schulz

So I can say I found the following:
- sphinx-lint (https://github.com/sphinx-contrib/sphinx-lint). This
mainly complained about tabs being used, but maybe it would find some interesting things in the YP docs?

Thanks for sharing. This one may indeed be interesting to enforce our "syntax style" preferences.

My time is limited at the moment, but don't hesitate to try it by yourself on the Yocto docs too.

Cheers
Michael.

Signature · 3 lines
Michael Opdenacker, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com