__traits(documentation, X)

Laeeth Isharc laeeth at laeeth.com
Wed Jan 17 03:23:07 UTC 2018


On Wednesday, 17 January 2018 at 02:19:11 UTC, Seb wrote:
> What
> ----
>
> ```
> /// my fancy string
> enum documentedEnum = 1;
> enum funcDoc = __traits(documentation, documentedFunc);
> assert(funcDoc == "my fancy string")
> ```
>
> See https://github.com/dlang/dmd/pull/6872 for better examples
>
>
> Status
> -------
>
> The naive implementation leads to a small, but noticeable 
> increase of DMD's compilation time.
>
> Andrei's words:
>
>> I'd say keep it on the back burner until we find a couple of 
>> good ideas for using it. Discussing it in the forum may help.
>
> So do you have a good use cases for this?
> If this is a useful feature, the implementation can be improved 
> to be zero-cost for normal runs.
>
> Post here or at https://github.com/dlang/dmd/pull/6872

In my case might be useful for generating foreign doc strings for 
automatically generated wrappers in other languages and for D 
functions intended for use directly but also mounted into an 
interpreted DSL.. You could duplicate docstring with attributes 
but hardly pretty.




More information about the Digitalmars-d mailing list