Skip to content

Commit 9f92aa5

Browse files
Merge pull request #3583 from VWS-Python/ci/snapper-semantic-line-breaks
Enforce semantic line breaks with Snapper
2 parents 969b00d + 3ca6041 commit 9f92aa5

10 files changed

Lines changed: 65 additions & 11 deletions

File tree

.snapperrc.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# These files contain markup constructs that Snapper main does not yet preserve.
2+
ignore = [
3+
"CHANGELOG.rst",
4+
"docs/source/differences-to-vws.rst",
5+
"docs/source/unverified-behavior.rst",
6+
]

.vale.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ MinAlertLevel = error
44
Packages = https://github.com/tbhb/vale-ai-tells/releases/download/v1.29.0/ai-tells.zip
55

66
[*.{rst,md}]
7-
BasedOnStyles = ai-tells
7+
BasedOnStyles = ai-tells, snapper
8+
snapper.SemanticLineBreaks = error
89

910
# These rules misclassify established technical, example, or release-note prose
1011
# in this repository. All other ai-tells rules remain enforced.

docs/source/ci-setup.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ Create environment variable files for secrets:
2424
$ cp vuforia_secrets.env.example ci_secrets/vuforia_secrets_1.env
2525
$ ...
2626
27-
Populate every variable listed in :file:`vuforia_secrets.env.example`.
28-
Each file needs distinct active Cloud database credentials so concurrent jobs do not modify the same database.
27+
Populate every variable listed in :file:`vuforia_secrets.env.example`. Each file needs distinct active Cloud database credentials so concurrent jobs do not modify the same database.
2928
The files can share the inactive Cloud, active and inactive VuMark, and Model Target credentials.
3029
Add at least as many consecutively numbered files, starting at zero, as there are builds in the GitHub test matrix.
3130

docs/source/contributing.rst

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ Create an environment variable file for secrets:
5656
$ cp vuforia_secrets.env.example vuforia_secrets.env
5757
5858
Some tests require Vuforia credentials.
59-
To run these tests, add the Vuforia credentials to the file :file:`vuforia_secrets.env`.
60-
See :ref:`connecting-to-vuforia`.
59+
To run these tests, add the Vuforia credentials to the file :file:`vuforia_secrets.env`. See :ref:`connecting-to-vuforia`.
6160

6261
Then run ``pytest``:
6362

@@ -73,14 +72,12 @@ Connecting to Vuforia
7372
To connect to Vuforia, Vuforia target databases must be created via the Vuforia Web UI.
7473
Then, secret keys must be set as environment variables.
7574

76-
The test infrastructure allows those keys to be set in the file :file:`vuforia_secrets.env`.
77-
See :file:`vuforia_secrets.env.example` for the environment variables to set.
75+
The test infrastructure allows those keys to be set in the file :file:`vuforia_secrets.env`. See :file:`vuforia_secrets.env.example` for the environment variables to set.
7876

7977
Do not use a target database that you are using for other purposes.
8078
This is because the test suite adds and deletes targets.
8179

82-
To create a target database, first create a license key in the `Vuforia License Manager`_.
83-
Then, add a database from the `Vuforia Target Manager`_.
80+
To create a target database, first create a license key in the `Vuforia License Manager`_. Then, add a database from the `Vuforia Target Manager`_.
8481

8582
To find the environment variables to set in the :file:`vuforia_secrets.env` file, visit the Target Database in the `Vuforia Target Manager`_ and view the "Database Access Keys".
8683

docs/source/unreleased.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Unreleased changes
22
==================
33

4-
Changes that have landed on the main branch but are not yet part of a
5-
tagged release. These entries are assembled into the
4+
Changes that have landed on the main branch but are not yet part of a tagged release.
5+
These entries are assembled into the
66
:doc:`changelog` when the next release is published.
77

88
.. towncrier-draft-entries::

prek.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,19 @@ hooks = [
407407
additional_dependencies = ["uv==0.11.7"],
408408
stages = ["pre-commit"]
409409
},
410+
{
411+
id = "snapper",
412+
name = "snapper",
413+
entry = "uv run --group=dev snapper --max-width 0 --in-place",
414+
language = "python",
415+
types_or = [
416+
"rst",
417+
"markdown"
418+
],
419+
require_serial = true,
420+
additional_dependencies = ["uv==0.11.7"],
421+
stages = ["pre-commit"]
422+
},
410423
{
411424
id = "vale",
412425
name = "vale",

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ dev = [
9999
# use it to lint shell commands in GitHub workflow files.
100100
"shellcheck-py==0.11.0.1",
101101
"shfmt-py==4.1.0",
102+
"snapper-fmt==0.11.0",
102103
"sphinx==9.1.0",
103104
"sphinx-copybutton==0.5.2",
104105
"sphinx-lint==1.0.2",

styles/snapper/LongProseLine.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
# Vale style rule: flag prose lines that are suspiciously long.
3+
# Likely indicates wrapped text that should use semantic line breaks.
4+
extends: existence
5+
message: Prose line exceeds 120 characters. Consider running 'snapper' to break at
6+
sentence boundaries.
7+
level: suggestion
8+
scope: paragraph
9+
# This catches lines > 120 chars that contain a period followed by a space.
10+
# Pure code or URLs are less likely to match.
11+
tokens: ['.{120,}']
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
# Vale style rule: flag lines containing multiple sentences.
3+
# These should be broken at sentence boundaries.
4+
extends: existence
5+
message: Line contains multiple sentences. Run 'snapper --check' or reformat with
6+
'snapper --in-place'.
7+
level: warning
8+
scope: paragraph
9+
# Match a sentence-ending punctuation followed by a space and a capital letter
10+
# on the same line (indicating two sentences on one line).
11+
tokens: ['[.!?]\\s+[A-Z]']

uv.lock

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)