Bug 11133 – ddoc: documented unittest outside of version scope

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-09-27T19:53:05Z
Last change time
2024-12-13T18:12:09Z
Assigned to
No Owner
Creator
Martin Nowak
Moved to GitHub: dmd#18684 →

Comments

Comment #0 by code — 2013-09-27T19:53:05Z
I have the following case where I want to split implementations and documentation. The following unittest should also be used as example in the docs but that doesn't work. version (D_Ddoc) { /// Library docs struct Library { /// foo void foo(); } // unittests docs only work here, but here they don't run } else version (Windows) { // Library impls struct Library { void foo() {} } } else version (Posix) { // Library impls struct Library { void foo() {} } } /// unittest { // shared unittest used as example and for testing Library lib; }
Comment #1 by code — 2013-09-27T20:00:32Z
Ah I forgot to mention. The following case works. It seems like it's the else branch that break the unittest docs. version (D_Ddoc) { /// struct Library {} } /// version (all) unittest { }
Comment #2 by issues.dlang — 2017-12-14T01:22:30Z
Similarly, the unit tests don't end up in the docs in this code, and version(D_Ddoc) isn't even involved: ============== /// struct S { /// Something about foo. version(Posix) alias Foo = int; else version(Windows) alias Foo = int; /// unittest { Foo foo; } } ============== Or at least, the unit test doesn't show up in the docs if you compile on a POSIX system. I assume that it will show up if you compile on Windows, since if I flip the versions, the unit test does show up. So, I guess that it considers the unit test to go with the symbol in the else block and will only put the test in the docs if it's the last version that's taken. I have a similar problem in my code with static ifs, so I think that this problem applies to them too.
Comment #3 by issues.dlang — 2017-12-14T01:29:01Z
Here's an example that has the problem with static if: /// struct S(R) { /// Some docs static if(is(R == string)) alias S = R; else alias S = int; /// unittest { S s; } }
Comment #4 by issues.dlang — 2017-12-14T01:38:02Z
Comment #5 by robert.schadek — 2024-12-13T18:12:09Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18684 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB