Skip to content

Tests scoping down SentenceSpacing somewhat

Amy Qualls requested to merge aqualls-set-scope-sentence-rule into master

What does this MR do?

tl;dr Adds a scope (https://vale.sh/docs/topics/scoping/#markup) to SentenceSpacing.yml, though I want a second opinion on whether I've added the correct one. Includes instructions on how to reproduce.

@mwoolf pinged me this morning with a failing pipeline in !159440, saying it was a false positive, and he was right. The SentenceSpacing.yml rule was tripping up on this (correctly marked up) code example:

from django.db import models
class Animal(models.Model):
    name = models.CharField(max_length=200)
    number_of_legs = models.IntegerField(default=2) # 's.I' was flagged here
    dangerous = models.BooleanField(default=False)

I've been staring at it, asking myself why this got flagged. I kept reading the rule contents over and over before I spotted the ABSENCE of something. Don't ask how long it took me to spot there's no scope in the file:

extends: existence
message: "Use exactly one space between sentences and clauses. Check '%s' for spacing problems."
link: https://docs.gitlab.com/ee/development/documentation/styleguide/index.html#punctuation
level: error
nonword: true
tokens:
  - '[a-z][.?!,][A-Z]'
  - '[\w.?!,\(\)\-":] {2,}[\w.?!,\(\)\-":]'

I mean, Vale shouldn't be scanning code blocks, but @eread and @marcel.amirault and I have all encountered in the past that rules with anything regex-like can be overly grabby and tough to disable. Is that what's happening here? Is it possible that the lack of scope is letting this rule work like a raw-scoped rule, and ingest code blocks?

I can't get this rule to fail reliably with my own edits, but you can reproduce it locally by reversing my changes to Max's merge request:

  1. git fetch origin
  2. git checkout -b 'mw/o11y/django-tutorial' 'origin/mw/o11y/django-tutorial' from !159440
  3. open doc/tutorials/observability/observability_django_tutorial.md
  4. Remove the rule-disabling codes on line 24 and the end of the file, and resave the file
  5. line 110-ish should fail

Setting any of these scopes in SentenceSpacing.yml removes the error:

  • scope: text.html (the broadest scope I can find)
  • scope: paragraph (narrower)
  • scope: sentence (probably too narrow but I'm unsure how to test)

I think we probably want to keep the scope of this rule as broad as possible without triggering the problem, but I need more eyes.

Related issues

Related to Draft: Add Django tutorial for observability to... (!159440) where I spotted the problem.

Author's checklist

If you are a GitLab team member and only adding documentation, do not add any of the following labels:

  • ~"frontend"
  • ~"backend"
  • ~"type::bug"
  • ~"database"

These labels cause the MR to be added to code verification QA issues.

Reviewer's checklist

Documentation-related MRs should be reviewed by a Technical Writer for a non-blocking review, based on Documentation Guidelines and the Style Guide.

If you aren't sure which tech writer to ask, use roulette or ask in the #docs Slack channel.

  • If the content requires it, ensure the information is reviewed by a subject matter expert.
  • Technical writer review items:
    • Ensure docs metadata is present and up-to-date.
    • Ensure the appropriate labels are added to this MR.
    • Ensure a release milestone is set.
    • If relevant to this MR, ensure content topic type principles are in use, including:
      • The headings should be something you'd do a Google search for. Instead of Default behavior, say something like Default behavior when you close an issue.
      • The headings (other than the page title) should be active. Instead of Configuring GDK, say something like Configure GDK.
      • Any task steps should be written as a numbered list.
      • If the content still needs to be edited for topic types, you can create a follow-up issue with the docs-technical-debt label.
  • Review by assigned maintainer, who can always request/require the reviews above. Maintainer's review can occur before or after a technical writer review.
Edited by Amy Qualls

Merge request reports