www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Generate docs for generated code?

reply wjoe <invalid example.com> writes:
Is there a way for the compiler to consider doc comments in auto 
generated, mixed in code?
E.g.
```D
string fooImpl = q{
    /// Bar does fancy things.
    const void bar() { /*do something fancy*/ }
};

/// This is Foo
struct Foo(A, B, C) {
   mixin(fooImpl);
}
```

So that the documentation for ```struct Foo``` has that of the 
member ```bar()``` ?
Jul 23 2021
next sibling parent reply user1234 <user1234 12.de> writes:
On Friday, 23 July 2021 at 10:04:55 UTC, wjoe wrote:
 Is there a way for the compiler to consider doc comments in 
 auto generated, mixed in code?
 E.g.
 ```D
 string fooImpl = q{
    /// Bar does fancy things.
    const void bar() { /*do something fancy*/ }
 };

 /// This is Foo
 struct Foo(A, B, C) {
   mixin(fooImpl);
 }
 ```

 So that the documentation for ```struct Foo``` has that of the 
 member ```bar()``` ?
unfortunately no and this is considered as a [bug](https://issues.dlang.org/show_bug.cgi?id=2420)
Jul 23 2021
parent wjoe <invalid example.com> writes:
On Friday, 23 July 2021 at 10:42:22 UTC, user1234 wrote:
 On Friday, 23 July 2021 at 10:04:55 UTC, wjoe wrote:
 Is there a way for the compiler to consider doc comments in 
 auto generated, mixed in code?
 E.g.
 ```D
 string fooImpl = q{
    /// Bar does fancy things.
    const void bar() { /*do something fancy*/ }
 };

 /// This is Foo
 struct Foo(A, B, C) {
   mixin(fooImpl);
 }
 ```

 So that the documentation for ```struct Foo``` has that of the 
 member ```bar()``` ?
unfortunately no and this is considered as a [bug](https://issues.dlang.org/show_bug.cgi?id=2420)
bummer but thanks for the link.
Jul 23 2021
prev sibling parent reply Adam D Ruppe <destructionator gmail.com> writes:
On Friday, 23 July 2021 at 10:04:55 UTC, wjoe wrote:
 Is there a way for the compiler to consider doc comments in 
 auto generated, mixed in code?
If you use my adrdox generator (which runs on the dpldocs.info website), it handles mixin templates. See http://dpldocs.info/experimental-docs/std.net.curl.HTTP.html#mixed-in-members for example. Mine also actually handles mixin(q{ /// code void foo() {} }); as if it was direct. But my generator only handles mixin templates and mixin string literals, not actually generated code returned from a function.
Jul 23 2021
parent wjoe <invalid example.com> writes:
On Friday, 23 July 2021 at 10:54:33 UTC, Adam D Ruppe wrote:
 On Friday, 23 July 2021 at 10:04:55 UTC, wjoe wrote:
 Is there a way for the compiler to consider doc comments in 
 auto generated, mixed in code?
If you use my adrdox generator (which runs on the dpldocs.info website), it handles mixin templates. See http://dpldocs.info/experimental-docs/std.net.curl.HTTP.html#mixed-in-members for example. Mine also actually handles mixin(q{ /// code void foo() {} }); as if it was direct. But my generator only handles mixin templates and mixin string literals, not actually generated code returned from a function.
Cool! I take it. Thanks for making adrdox :)
Jul 23 2021