D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 10325 - ddoc: template constraints inconsistently shown in generated html
Summary: ddoc: template constraints inconsistently shown in generated html
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: Andrej Mitrovic
URL:
Keywords: ddoc, pull
Depends on:
Blocks:
 
Reported: 2013-06-10 14:32 UTC by thelastmammoth
Modified: 2013-06-11 09:28 UTC (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description thelastmammoth 2013-06-10 14:32:13 UTC
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/mailman.1006.1370836279.13711.digitalmars-d@puremagic.com.
In that link I also suggested a concise way to write those template constraints.
Comment 1 bearophile_hugs 2013-06-10 14:54:24 UTC
(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 Jonathan M Davis 2013-06-10 15:00:38 UTC
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 Andrej Mitrovic 2013-06-11 07:31:41 UTC
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 Andrej Mitrovic 2013-06-11 07:51:07 UTC
https://github.com/D-Programming-Language/dmd/pull/2161
Comment 5 github-bugzilla 2013-06-11 09:27:45 UTC
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/3f9d50b12f9d1d7d7149d4bc2692322754e3c5d0
Fixes Issue 10325 - Constraints should be emitted for templated declarations.

https://github.com/D-Programming-Language/dmd/commit/4bbef4f21141c6b21f35d133f348a3b215ad6513
Merge pull request #2161 from AndrejMitrovic/Fix10325

 Issue 10325 - Constraints should be emitted for templated declarations