-
-
Notifications
You must be signed in to change notification settings - Fork 667
Fix issue 18361: [ddoc] redirect automatically highlighted text in re… #7834
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
9b439af
Fix issue 18361: [ddoc] redirect automatically highlighted text in re…
548e047
Add DDOC_AUTO_PSYMBOL_SUPPRESS to ease removal of `_` suppressions.
24c627e
Add changelog.
d932f32
Add test case.
463e506
Remove first empty line in changelog/fix18361.dd
wilzbach File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| Fix issue 18361 - Ddoc ability to opt-out of automatic keyword highlighting in running text | ||
|
|
||
| Currently, ddoc automatically highlights all occurrences of words in running | ||
| text that coincide with the symbol or module being documented, or a parameter | ||
| name of a function being documented. While convenient, it often caused | ||
| unintended highlighting of normal words in text when module, function, or | ||
| parameter identifiers coincide with normal words. This led to a proliferation | ||
| of prefixing words with `_` in order to suppress this behaviour. | ||
|
|
||
| Now a better solution has been implemented to completely opt-out of this | ||
| feature via the `DDOC_AUTO_PSYMBOL`, `DDOC_AUTO_KEYWORD`, and `DDOC_AUTO_PARAM` | ||
| macros, which are used for all such automatically-highlighted words in running | ||
| text. Occurrences of module, function, or parameter names inside code blocks | ||
| are not included. By default, these macros simply redirect to `DDOC_PSYMBOL`, | ||
| `DDOC_KEYWORD`, and `DDOC_PARAM`, but the user can now redefine these macros so | ||
| that they simply expand to the word itself without any highlighting: | ||
|
|
||
| ---- | ||
| DDOC_AUTO_PSYMBOL = $0 | ||
| DDOC_AUTO_KEYWORD = $0 | ||
| DDOC_AUTO_PARAM = $0 | ||
| ---- | ||
|
|
||
| Furthermore, whenever a word is prefixed with `_` to suppress automatic | ||
| highlighting, it is now wrapped in the `DDOC_AUTO_PSYMBOL_SUPPRESS` macro. This | ||
| is to provide users who wish to opt out of automatic highlighting an easy way | ||
| to find all occurrences of these underscore prefixes so that they can be | ||
| removed from the text. For example, they can redefine this macro to something | ||
| highly-visible and easily searched for, such as: | ||
|
|
||
| ---- | ||
| DDOC_AUTO_PSYMBOL_SUPPRESS = FIXME_UNDERSCORE_PREFIX $0 | ||
| ---- | ||
|
|
||
| and then search the generated documentation for the string | ||
| `FIXME_UNDERSCORE_PREFIX` and delete the `_` prefix from all corresponding | ||
| parts of the documentation comment text. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| // PERMUTE_ARGS: | ||
| // REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o- | ||
| // POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh 18361 | ||
| // REQUIRED_ARGS: -d | ||
|
|
||
| // Test notes: 'main' is the symbol being documented (DDOC_AUTO_PSYMBOL), | ||
| // 'arguments' is a parameter (DDOC_AUTO_PARAM), and 'false' is a keyword | ||
| // (DDOC_AUTO_KEYWORD). | ||
| /** | ||
| * The main thing this program does is nothing, and I do _not want to hear any | ||
| * false arguments about that! | ||
| * | ||
| * Macros: | ||
| * DDOC_AUTO_PSYMBOL = $0 | ||
| * DDOC_AUTO_KEYWORD = $0 | ||
| * DDOC_AUTO_PARAM = $0 | ||
| * DDOC_AUTO_PSYMBOL_SUPPRESS = HALPIMBEINGSUPPRESSED $0 | ||
| * | ||
| * DDOC = $(BODY) | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These overrides are to reduce the scope of the test so that the output HTML does not depend on the styling of the outer elements, that are unrelated to this PR. So that later ddoc PRs won't necessitate updating the test output file unnecessarily. |
||
| * DDOC_DECL = $0 | ||
| * DDOC_MEMBER_HEADER = | ||
| * DDOC_MODULE_MEMBERS = $0 | ||
| * DDOC_MEMBER = $0 | ||
| */ | ||
| void main(string[] arguments) | ||
| { | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
|
|
||
| <span class="ddoc_anchor" id="main"></span>void <code class="code">main</code>(string[] <code class="code">arguments</code>); | ||
|
|
||
| <div class="ddoc_decl"> | ||
| <section class="section ddoc_sections"> | ||
| <div class="ddoc_summary"> | ||
| <p class="para"> | ||
| The main thing this program does is nothing, and I do HALPIMBEINGSUPPRESSED not want to hear any | ||
| false arguments about that! | ||
|
|
||
| </p> | ||
| </div> | ||
|
|
||
| </section> | ||
|
|
||
| </div> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
help?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
repressed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, it was intended as a joke. The misspelling is intentional. It's basically supposed to be any string that's hard to accidentally reproduce or coincide with anything else, that stands out in the output so that we know for certain that the code is working as expected.