Skip to content

Conversation

@theletterf
Copy link
Contributor

@theletterf theletterf commented Oct 21, 2025

Fixes #2083

Added a new docs-builder format command to automatically fix formatting issues in documentation files. The command currently handles irregular space characters (no-break spaces, en spaces, zero-width spaces, etc.) by replacing them with regular spaces. The formatter only processes markdown files included in the docset configuration.

Note that the command supports a --dry-run flag to preview changes without modifying files. I also updated the space normalizer linter to emit a single hint per file instead of per occurrence, directing users to run docs-builder format to fix all instances automatically.

The formatter architecture is extensible by using the IFormatter interface, making it straightforward to add additional formatting operations in the future (trailing whitespace, line endings, etc.) without modifying the core service logic.

How to test

  1. Add irregular spaces
python3 -c "with open('docs/index.md', 'r') as f: content = f.read(); content = content.replace('Elastic Docs V3 is our', 'Elastic Docs V3 is\u00A0our'); open('docs/index.md', 'w').write(content)"
  1. Build and see hint
dotnet run --project src/tooling/docs-builder/docs-builder.csproj -- --path docs 2>&1 | grep Hint
  1. Format to fix
dotnet run --project src/tooling/docs-builder/docs-builder.csproj -- format --path docs
  1. Verify hint is gone
dotnet run --project src/tooling/docs-builder/docs-builder.csproj -- --path docs 2>&1 | grep Hint

Co-authored by Claude 4.5 using Claude CLI 2.0 inside Cursor

@theletterf theletterf self-assigned this Oct 21, 2025
@theletterf theletterf requested review from a team as code owners October 21, 2025 09:43
@theletterf theletterf requested a review from cotti October 21, 2025 09:43
@github-actions
Copy link

github-actions bot commented Oct 21, 2025

🔍 Preview links for changed docs

Copy link
Member

@Mpdreamz Mpdreamz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love it! Some small PR notes.

@theletterf
Copy link
Contributor Author

Added --check and --write flags

@Mpdreamz Mpdreamz merged commit 224b089 into main Oct 21, 2025
22 checks passed
@Mpdreamz Mpdreamz deleted the add-docsbuilder-format-command branch October 21, 2025 17:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reduce irregular spaces hints' noise and add command to replace them

4 participants