-
-
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
Conversation
…placeable macros. Basically, this is to give the user the ability to opt out of automatic keyword highlighting in doc text, in the cases where a proliferation of `_`s would be needed to suppress this behaviour. The default behaviour is not changed; the default ddoc theme will still redirect the new macros to the old DDOC_PSYMBOL, DDOC_KEYWORD, DDOC_PARAM.
|
Honestly, I think that we'd be better off just killing the auto-highlighting entirely. It may have sounded like a good idea, but all in all, it's caused us nothing but grief. And if we leave it as opt-out, then it's still going to be causing us grief, much as I agree that being able to opt-out is an improvement over the status quo. |
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.
Could come with a short changelog explaining how to opt-out.
I think we should merge this directly and put the discussion of whether or not to turn the trigger by default on a separate PR. @quickfur it would need a simple PR to https://dlang.org/spec/ddoc.html#macros before it can be merged. Also I would add a few lines to changelog to show users how they can opt-out. The single line bug fixes get easily lost in the changelog.
Agreed (I also vote for killing it with 🔥), but that would require approval from @WalterBright and/or @andralex. |
|
the thing is you can opt out right now by defining The tricky thing with migrating to sanity is removing the excess _ from existing code. Good news is that by "tricky" I mean "trivial": just make the compiler tell you when it detects those and remove them all. Then we can kill it. And it isn't strictly wrong to leave them there for now but we'd want to remove them before long. But regardless anything that gets us closer to killing this once and for all is good. |
|
@jmdavis I agree, but this way is less controversial and at least gives us the worst-case scenario where we can opt out even if everything else gets vetoed. @wilzbach OK, I'll add a dlang.org PR. Yeah, I'd also vote for killing this with fire... or, like the beginning of the movie Outbreak, send an airplane over to drop a "package"... :-D @adamdruppe The problem with nulling out But anyway, killing it off is not hard at all; you don't even need any special addition to the compiler. Just redefine |
That's the opposite of what to fix. To fix the source code, you aren't concerned about the places where DDOC_AUTO_PSYMBOL is triggered but rather the places where it is suppressed by the leading underscore. The compiler knows these places though, and it could also be defined to a macro or whatever. It is this line slightly higher than your diff: that indicates source code to change. So once you defined DDOC_AUTO_PSYMBOL=$0, then you will want to search your code and remove the leading _, triggered by the code in the above link. That will clean up the source from the misfeature and ultimately provide a path to remove the whole highlight thing entirely. (if it is removed entirely, those leading _ will be rendered in the final output if not cleaned up) |
|
We should define the macro |
Companion PR to dlang/dmd#7834.
|
dlang.org PR: dlang/dlang.org#2168 |
|
@quickfur i think you have to i-- on the new set of the diff before you bracket to fix the autotester. (I used to know this code quite well back when I was enthusiastic about fixing ddoc but that was years ago) |
|
Hmm. Actually, with this PR, even if you redefine However, I still added |
|
@adamdruppe Hmm, lemme run some tests to see what the code does. I just copied-n-pasted the bracketing code from below, but you're right, it may not quite work correctly because of the P.S. Well, I really should be adding test cases to ensure nothing breaks in the future. But I'll have to work on that tomorrow or Monday... going to be busy now. |
608519b to
b3336b3
Compare
| * DDOC_AUTO_PARAM = $0 | ||
| * DDOC_AUTO_PSYMBOL_SUPPRESS = HALPIMBEINGSUPPRESSED $0 | ||
| * | ||
| * DDOC = $(BODY) |
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.
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.
|
OK I lied, managed to squeeze in the time to add a test case. Destroy! |
|
It's ok with me if the _ highlighting is removed. All I can say is it seemed like a good idea at the time. |
I can totally understand it seeming like a good idea at the time, but I do think that experience has shown that it ultimately wasn't a good idea. We've all made mistakes like that though. |
| * DDOC_AUTO_PSYMBOL = $0 | ||
| * DDOC_AUTO_KEYWORD = $0 | ||
| * DDOC_AUTO_PARAM = $0 | ||
| * DDOC_AUTO_PSYMBOL_SUPPRESS = HALPIMBEINGSUPPRESSED $0 |
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.
|
I think the big mistake with the original thing was that it was opt in instead of opt out. So it would hit a LOT of false positives as variable names and English text coincided. But if it was opt in, it could have been the basis of a nice cross reference thing like mine http://dpldocs.info/experimental-docs/adrdox.syntax.html#cross-referencing Perhaps once we remove the automatic thing, ddoc can use the symbol lookup code later for a reference thing. |
|
@WalterBright It's no one's fault; hindsight is always 20/20. But at the time, it was probably not so easy to anticipate the problems that would arise later. |
b3336b3 to
8c61e18
Compare
|
Fixed bug in test case that's causing autotester failure. |
|
@quickfur it's still segfaulting: |
|
Ahh, it's a different test that's segfaulting. I was wondering why the autotester segfaults when running my test locally doesn't. I'll look into it. |
8c61e18 to
d932f32
Compare
|
@adamdruppe was right: there's an off-by-one error that's causing the segfault. Should be fixed now. |
| @@ -0,0 +1,38 @@ | |||
|
|
|||
| Fix issue 18361 - Ddoc ability to opt-out of automatic keyword highlighting in running text | |||
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.
object.Exception@../tools/changed.d(210): Changelog entries should consist of one title line, a blank separator line, and a description.
----------------
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.
(fixed it myself)
|
So DAutoTest complains correctly that there are two undefined macros now: -> we need to fix Phobos first: dlang/phobos#6149 |
19aa50c to
463e506
Compare
…placeable macros.
Basically, this is to give the user the ability to opt out of automatic
keyword highlighting in doc text, in the cases where a proliferation of
_s would be needed to suppress this behaviour.The default behaviour is not changed; the default ddoc theme will still
redirect the new macros to the old DDOC_PSYMBOL, DDOC_KEYWORD,
DDOC_PARAM.