Bug 15475 – Ddoc code sample with unbalanced paren comes out as macro
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2015-12-24T15:37:48Z
Last change time
2018-05-19T11:11:34Z
Keywords
pull
Assigned to
No Owner
Creator
Adam D. Ruppe
Comments
Comment #0 by destructionator — 2015-12-24T15:37:48Z
/**
---
// code sample with unbalanced (
---
*/
module t2;
Spits out:
<pre class="d_code"><font color=green>// code sample with unbalanced $(LPAREN)
</font></pre>
in the final code.
Comment #1 by hsteoh — 2016-03-08T18:25:14Z
Bumping this up to importance normal, because it's messing up std.random docs where there are a lot of unbalanced parens.
This is really ridiculous. Ddoc should not touch stuff inside code blocks; the code should come out verbatim.
Comment #2 by destructionator — 2016-03-08T18:31:07Z
my doc generator handles this correctly
just saying
(my doc gen even handles `---` inside comments in the samples! it is fancy.)
Comment #3 by hsteoh — 2016-03-08T18:35:33Z
The problem is the doc.d right now is a fragile tangle of spaghetti code, full of special cases and unexpected gotchas, and changing one small thing may cause unrelated breakage elsewhere. It really needs to be refactored into something more maintainable. But it's so complex that such a refactoring would have to be done piecemeal, otherwise it would cause even more breakage.
Comment #4 by hsteoh — 2016-03-08T19:23:20Z
Found that the problem is that the ')' is doubly-escaped: by the time it gets to highlightText(), it's already escaped, but highlightText doesn't know that, and when it calls highlightCode2() it escapes it a second time, turning `$(RPAREN)` (which would have correctly expanded into ')') into `$(DOLLAR)$(LPAREN)RPAREN$(RPAREN)`, so it expands back to `$(PAREN)` instead.