Bug 10325 – ddoc: template constraints inconsistently shown in generated html
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-06-10T14:32:00Z
Last change time
2013-06-11T09:28:07Z
Keywords
ddoc, pull
Assigned to
andrej.mitrovich
Creator
thelastmammoth
Comments
Comment #0 by thelastmammoth — 2013-06-10T14:32:13Z
ddoc doesn't generate template constraints or does so very inconsistently :
in http://dlang.org/phobos/std_algorithm.html we have:
template map(fun...) if (fun.length >= 1);
but all other template constraints are omitted, eg:
void fill(Range, Value)(Range range, Value filler); // template constraint omitted.
I originally reported this in http://forum.dlang.org/post/[email protected].
In that link I also suggested a concise way to write those template constraints.
Comment #1 by bearophile_hugs — 2013-06-10T14:54:24Z
(In reply to comment #0)
> ddoc doesn't generate template constraints or does so very inconsistently :
> in http://dlang.org/phobos/std_algorithm.html we have:
> template map(fun...) if (fun.length >= 1);
> but all other template constraints are omitted, eg:
> void fill(Range, Value)(Range range, Value filler); // template constraint
> omitted.
I suggest you to write here a little test case program that imports nothing from Phobos, usable as test case. It should cover various cases, to make it usable as test case for the person that will write the patch that fixes the bug.
Comment #2 by issues.dlang — 2013-06-10T15:00:38Z
It's my understanding that template constraints are never supposed to show up in the docs, but right now, it does look they show up some of the time when it's specifically a template in the docs rather than a function, and templated functions do indeed not have template constraints on them in the docs. Regardless, what's currently showing up in the docs is indeed inconsistent.
Comment #3 by andrej.mitrovich — 2013-06-11T07:31:41Z
Test-case:
-----
module ddoc10325;
/** */
template templ(T...)
if (someConstraint!T)
{
}
/** */
void foo(T)(T t)
if (someConstraint!T)
{
}
void main() { }
-----
The constraints for 'foo' are not shown.
Constraints should be part of the documentation, they form part of the interface.
When a user gets an error about instantiating a template, he will get the name of the template and its constraints, it only makes sense to also include the constraints in the documentation.
Comment #4 by andrej.mitrovich — 2013-06-11T07:51:07Z