Skip to content

Conversation

colleenmcginnis
Copy link
Contributor

Warns when a heading contains an inline applies_to.

@theletterf and I paired today on adding a warning when we detect inline applies_to syntax in the heading text. We tried a couple different approaches. This one works, but I'm not sure if it's the best place to check for this.

Open questions for @elastic/docs-engineering:

  • Is this an appropriate place to check for applies_to syntax in a heading?
  • Does it make sense to use regex to check?
  • Is there a way to add more context (like the line number and highlighting the text that's causing the error) to the warning message? Right now it just looks like this:
    Screenshot 2025-08-25 at 12 34 10 PM

@colleenmcginnis colleenmcginnis self-assigned this Aug 25, 2025
@theletterf
Copy link
Contributor

I find this solution pretty clean, given that inline roles can potentially be placed anywhere!

@cotti
Copy link
Contributor

cotti commented Aug 26, 2025

My 2c: The placement looks right!

In order to get the extra info (and clean up the call to EmitWarning), this branch needs to extend ProcessorDiagnosticExtensions to have at least an EmitWarning and its accompanying Emit for BlockProcessor.

After it's implemented, it can be called just with a processor.EmitWarning(block, "Do not use inline 'applies_to' annotations with headings. Use a section 'applies_to' annotation instead.");

…peeking into the file for error localization
@Mpdreamz
Copy link
Member

I just implemented it without looking at @cotti's review but ended up doing the same thing. NICE!

image

@Mpdreamz Mpdreamz marked this pull request as ready for review August 26, 2025 17:48
@Mpdreamz Mpdreamz requested a review from a team as a code owner August 26, 2025 17:48
@Mpdreamz Mpdreamz merged commit b08b4cf into main Aug 26, 2025
19 checks passed
@Mpdreamz Mpdreamz deleted the check-headings-for-applies_to branch August 26, 2025 17:49
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.

4 participants