A new trait to retrieve doc comments (if available).

Mason McGill via Digitalmars-d digitalmars-d at puremagic.com
Tue May 6 16:02:11 PDT 2014


Thanks for the feedback!

On Tuesday, 6 May 2014 at 07:41:20 UTC, bearophile wrote:
> Mason McGill:
>
>> Other implementations can choose to always evaluate it to "".
>
> Other implementations have to give the ddostring as well.

Good to know! This will simplify the entry in the "Traits" 
documentation page.

> In D modules too have a ddoc string.
>
> Regarding comments on single variables, like this, I think they 
> can be ignored for the moment, and added later with the same 
> API if needed:
>
> int foo = 5; /// Not a string.

It appears DMD already extracts module and variable comments.  
The JSON output for the following code associates all 3 comments 
with the appropriate symbols (compiled with "dmd -D -X -o- 
test.d").

     /**
      * This is the test module.
      */
     module test;

     const x = 5; /// This is x.

     /**
      * This is the main function.
      */
     void main() {}

So, it seems `__traits(comment, symbol)` should work for any 
symbol, at least the way I plan to implement it. This seems like 
the most useful behavior.


More information about the Digitalmars-d mailing list