Module: Yard::Lint::Validators::Documentation::TextSubstitution

Defined in:
lib/yard/lint/validators/documentation/text_substitution.rb,
lib/yard/lint/validators/documentation/text_substitution/config.rb,
lib/yard/lint/validators/documentation/text_substitution/parser.rb,
lib/yard/lint/validators/documentation/text_substitution/result.rb,
lib/yard/lint/validators/documentation/text_substitution/validator.rb,
lib/yard/lint/validators/documentation/text_substitution/messages_builder.rb

Overview

TextSubstitution validator

Detects forbidden characters or strings in YARD documentation comments and suggests replacements. The primary use case is detecting AI-generated em-dashes (—, U+2014) and en-dashes (–, U+2013) where a plain hyphen (-) is preferred, but any string-to-string substitution rule can be configured.

All substitution rules are checked on every line — multiple violations can be reported for the same line when more than one forbidden string appears. Fenced code blocks (“‘ … “`) are skipped.

Disabled by default — enable it and configure Substitutions to taste.

## Configuration

Enable with built-in defaults (em-dash and en-dash):

Documentation/TextSubstitution:
  Enabled: true

Enable with explicit substitution rules:

Documentation/TextSubstitution:
  Enabled: true
  Substitutions:
    "—": "-"    # em-dash (U+2014)
    "–": "-"    # en-dash (U+2013)
    "…": "..."  # ellipsis (U+2026)

To disable:

Documentation/TextSubstitution:
  Enabled: false

Examples:

Bad - em-dash used in documentation

# Connects the start — and end of the range.
def connect(start, finish)
end

Good - plain hyphen

# Connects the start - and end of the range.
def connect(start, finish)
end

Defined Under Namespace

Classes: Config, MessagesBuilder, Parser, Result, Validator