Proposal: __traits(getComment, symbol)

FeepingCreature feepingcreature at gmail.com
Wed Aug 28 10:29:24 UTC 2019


On Wednesday, 28 August 2019 at 09:55:47 UTC, Eugene Wissner 
wrote:
> On Wednesday, 28 August 2019 at 09:35:54 UTC, Sebastiaan Koppe 
> wrote:
>> Just create a Swagger struct (plus helper structs) and use 
>> like:
>>
>> ```
>> @Swagger(ApiResponses([
>>     ApiResponse(code = 200, message = "...", response = 
>> Entity),
>>     ApiResponse(code = 404, message = "listing not found")
>>   ]),
>>   Put("/entities/{id}"),
>>   Consumes([MediaType.APPLICATION_JSON_VALUE]),
>>   Produces([MediaType.APPLICATION_JSON_VALUE])
>> )
>> Entity endpoint(string id) { ... }
>> ```
>>
>> I think it beats parsing (or writing) comments...
>
> and provides some static typing, because structs can be used, 
> and probably better error messages than reinventing a Ddoc 
> parser.


Right but also UDAs look terrible as docs.

All this is info I already have. The only thing I can't get is 
the documentation comment on them.

How about this:

/**
  * Do a thing.
  *
  * Params:
  *  foo = A parameter
  */
void method();

would get converted by the compiler to

@(DDoc.Description("Do a thing"))
@(DDoc.Param!Foo(1, "foo", "A parameter"))
void method();

That'd give the best of both worlds.


More information about the Digitalmars-d mailing list