Bug 9474 – Ddoc'd unittests should work correctly with interspersed version(none)
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-02-07T15:35:00Z
Last change time
2013-03-22T18:21:07Z
Keywords
ddoc, pull
Assigned to
nobody
Creator
hsteoh
Comments
Comment #0 by hsteoh — 2013-02-07T15:35:25Z
Code:
----------
/**
* Documented function
*/
void documentedFunction() { doSomething(); }
/// Documented unittest
unittest
{
...
}
/// ditto
void documentedFunction(int a) {
// This is an overload of the no-args documentedFunction.
}
--------------
Currently, the ddoc for the unittest will fail to appear. Removing the ditto comment makes the problem go away. Ideally, this needs to do the Right Thing (the unittest should appear in the Example section in the ditto'd docs).
Comment #1 by andrej.mitrovich — 2013-02-07T15:43:48Z
I'm not sure what you mean exactly. When I test this:
/**
* Documented function
*/
void documentedFunction() { }
/// Documented unittest
unittest
{
documentedFunction();
}
/// ditto
void documentedFunction(int a) {
// This is an overload of the no-args documentedFunction.
}
$ dmd -D -o- test.d
The output I get is:
void documentedFunction();
void documentedFunction(int a);
Documented function
Example:
documentedFunction();
What should the output be?
Comment #2 by hsteoh — 2013-02-07T15:49:24Z
Hmm, I may need to reduce my actual failing test case, then. I thought it was just because of the /// ditto, but seems it may be something else.
Comment #3 by hsteoh — 2013-02-07T16:01:10Z
OK, found the real cause of failure:
--------------------
/**
* Documentation
*/
void func() {}
version(none) unittest { ... }
/// Example
unittest { ... }
---------------------
Removing the version line makes the problem go away. Note that ditto works when placed after the version line, so IMO the unittest ddocs should, too.
Comment #4 by andrej.mitrovich — 2013-02-08T10:01:34Z