Skip to content

[ddoc preprocessor] Highlight multiple <word> and nested [...] in CLI switches#4422

Merged
dkorpel merged 9 commits intodlang:masterfrom
ntrel:flags-pre
Mar 14, 2026
Merged

[ddoc preprocessor] Highlight multiple <word> and nested [...] in CLI switches#4422
dkorpel merged 9 commits intodlang:masterfrom
ntrel:flags-pre

Conversation

@ntrel
Copy link
Copy Markdown
Contributor

@ntrel ntrel commented Mar 11, 2026

Fixes #4421.

Before only the first <> and first [] was matched in the flag string.
Also inner [ chars were wrongly italicised.

Before a space was added before the ] presumably because a tall italic character before runs into it. The trouble with that is it can look weird in other places, adding spaces where there shouldn't be any (e.g. <arch>-<os>, so I removed that.

Update: Also highlight any <word> in helpText even if not in flag string.

@dlang-bot
Copy link
Copy Markdown
Contributor

Thanks for your pull request and interest in making D better, @ntrel! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

@ntrel ntrel marked this pull request as draft March 11, 2026 12:41
@ntrel ntrel changed the title [ddoc preprocessor] Fix highlighting <> and nested [] in CLI switches [ddoc preprocessor] Highlight multiple <word> and nested [...] in CLI switches Mar 13, 2026
@ntrel ntrel marked this pull request as ready for review March 13, 2026 11:26
@ntrel
Copy link
Copy Markdown
Contributor Author

ntrel commented Mar 13, 2026

Before a space was added before the ] ... so I removed that.

Let me know if you'd rather I do that in a separate PR

Comment on lines -484 to -487
.map!((w){
auto wPlain = w.filter!(c => !c.among('<', '>', '`', '\'')).to!string;
return wPlain == specialWord ? wPlain.italic: w;
})
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

BTW removing the filtering is fine because:

  • Italicizing <foo> is not dependent on using <foo> in the flag string.
  • 'foo' is not actually used for the HTML docs - only for the man page (even though short help is copied sometimes)
  • ` is not needed as matching <foo> is now by regex, not by space splitting

Copy link
Copy Markdown
Contributor

@dkorpel dkorpel left a comment

Choose a reason for hiding this comment

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

Looks good as a bug fix, but eventually I want to minimize the amount of special cases and magic transformations used to build the website. I prefer to just write the desired ddoc plainly in the dmd CLI documentation.

@dkorpel dkorpel merged commit 7a26b86 into dlang:master Mar 14, 2026
2 checks passed
@ntrel
Copy link
Copy Markdown
Contributor Author

ntrel commented Mar 14, 2026

@dkorpel

  • I agree that replacing foo in help text when <foo> is in the flag string is bug-prone, I might look at removing that.
  • We need some kind of common format e.g. <foo> because this is used to highlight option parameters for the man file. Unless it's possible to make a man.ddoc output target which is compatible with man syntax, but I doubt that would be easy.
  • I've just realized I need to fix the man file generation to be consistent with this PR

ntrel added a commit to ntrel/dmd that referenced this pull request Mar 15, 2026
`man` counterpart to HTML fix dlang/dlang.org#4422.

Also remove matching of `'foo'` and `foo` in help text when `<foo>` is
in flag string. This requires dlang#22741 to be merged first.
thewilsonator pushed a commit to dlang/dmd that referenced this pull request Mar 16, 2026
`man` counterpart to HTML fix dlang/dlang.org#4422.

Also remove matching of `'foo'` and `foo` in help text when `<foo>` is
in flag string. This requires #22741 to be merged first.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ddoc preprocessor misses every <word> after first from compiler flags HTML

3 participants