Another use case for __traits(docComment)
Adam D. Ruppe
destructionator at gmail.com
Wed Nov 13 15:40:34 UTC 2019
On Wednesday, 13 November 2019 at 15:22:23 UTC, Dennis wrote:
> UDA's use string literals, so the rules of what string you get
> are exactly clear and a formatter won't touch it. How does
> __traits(docComment) behave on these two comments:
This is actually defined in the D language specification
https://dlang.org/spec/ddoc.html
"The extra *'s and +'s on the comment opening, closing and left
margin are ignored and are not part of the embedded
documentation. Comments not following one of those forms are not
documentation comments. "
It is a little bit ambiguous to get
/**
Word
* word
*/
Is that "* word" supposed to ignore the star? dmd ignores it
which is probably most consistent with the spec. My adrdox does
NOT ignore that and can use it for markdown-style lists...
But regardless, the __trait thing should do what the compiler
already does for ddoc.
Though I would NOT parse the ddoc, just give the string as the
compiler read it.
> ```
> /** Word
> * Word
> */
>
> /******************
> Word
> Word
> */
> ```
>
> What strings do they produce?
" Word\n Word\n "
and
"Word\nWord\n"
So not identical, but this is well defined by the D language spec!
More information about the Digitalmars-d
mailing list