Skip to content

Commit ab9958e

Browse files
committed
fix #184 - template value specialization is missing
1 parent 97c394d commit ab9958e

File tree

9 files changed

+242
-1
lines changed

9 files changed

+242
-1
lines changed

source/ddox/api.d

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,10 @@ void renderTemplateArgs(R)(ref R output, Declaration decl, scope string delegate
380380
output.put(' ');
381381
}
382382
output.put(arg.name);
383+
if (arg.specValue.length) {
384+
output.highlightDCode(" : ");
385+
output.highlightDCode(arg.specValue);
386+
}
383387
if (arg.defaultValue.length) {
384388
output.highlightDCode(" = ");
385389
output.highlightDCode(arg.defaultValue);

source/ddox/entities.d

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ final class TemplateDeclaration : Declaration {
507507
}
508508

509509
final class TemplateParameterDeclaration : TypedDeclaration {
510-
string defaultValue;
510+
string defaultValue, specValue;
511511

512512
override @property string kindCaption() const { return "Template parameter"; }
513513
override @property TemplateParameterDeclaration dup() { auto ret = new TemplateParameterDeclaration(parent, name); ret.copyFrom(this); ret.type = type; return ret; }

source/ddox/parsers/jsonparser.d

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ private struct Parser
315315
foreach (arg; json["parameters"].opt!(Json[])) {
316316
string pname = arg["name"].get!string;
317317
string defvalue = arg["defaultValue"].opt!string;
318+
string specvalue = arg["specValue"].opt!string;
318319
bool needs_type_parse = false;
319320

320321
switch (arg["kind"].get!string) {
@@ -332,6 +333,7 @@ private struct Parser
332333

333334
auto pdecl = new TemplateParameterDeclaration(ret, pname);
334335
pdecl.defaultValue = defvalue;
336+
pdecl.specValue = specvalue;
335337
ret.templateArgs ~= pdecl;
336338
ret.templateConstraint = json["constraint"].opt!string;
337339

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="UTF-8"/>
5+
<title>API documentation</title>
6+
<link rel="stylesheet" type="text/css" href="./styles/ddox.css"/>
7+
<link rel="stylesheet" href="./prettify/prettify.css" type="text/css"/>
8+
<script type="text/javascript" src="./scripts/jquery.js">/**/</script><script type="text/javascript" src="./scripts/ddox.js">/**/</script>
9+
</head>
10+
<body onload="setupDdox();">
11+
<nav id="main-nav">
12+
<noscript>
13+
<p style="color: red">The search functionality needs JavaScript enabled</p>
14+
</noscript>
15+
<div id="symbolSearchPane" style="display: none">
16+
<form action="#" method="GET">
17+
<input id="symbolSearch" type="text" name="q" placeholder="Search for symbols" autocomplete="off" onchange="performSymbolSearch(40);" onkeypress="this.onchange();" onpaste="this.onchange();" oninput="this.onchange();"/>
18+
</form>
19+
<ul id="symbolSearchResults" class="symbolList" style="display: none"></ul><script type="application/javascript" src="./symbols.js"></script><script type="application/javascript">var symbolSearchRootDir = "./";
20+
$('#symbolSearchPane').show();</script>
21+
</div>
22+
<ul class="tree-view">
23+
<li>
24+
<div class="module ">
25+
<a href="./test.html">test</a>
26+
</div>
27+
</li>
28+
</ul>
29+
</nav>
30+
<div id="main-contents">
31+
<h1>API documentation</h1>
32+
<table>
33+
<col class="caption"/>
34+
<tr>
35+
<th>Module</th><th>Description</th>
36+
</tr>
37+
<tr>
38+
<td>
39+
<a href="./test.html">test</a>
40+
</td>
41+
<td>
42+
43+
</td>
44+
</tr>
45+
</table>
46+
<footer>
47+
<p class="faint">Generated using the DDOX documentation generator</p>
48+
</footer>
49+
</div>
50+
</body>
51+
</html>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
3+
<url><loc>http://127.0.0.1/index.html</loc></url>
4+
<url><loc>http://127.0.0.1/test.html</loc></url>
5+
<url><loc>http://127.0.0.1/test/Type.html</loc></url>
6+
<url><loc>http://127.0.0.1/test/Type.html</loc></url>
7+
<url><loc>http://127.0.0.1/test/Type.html</loc></url>
8+
<url><loc>http://127.0.0.1/test/Type.html</loc></url>
9+
</urlset>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// symbol index generated by DDOX - do not edit
2+
var symbols = [
3+
{name: 'test', kind: "module", path: './test.html', attributes: []},
4+
{name: 'test.Type', kind: "aliasdeclaration", path: './test/Type.html', attributes: []},
5+
];
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="UTF-8"/>
5+
<title>Module test</title>
6+
<link rel="stylesheet" type="text/css" href="./styles/ddox.css"/>
7+
<link rel="stylesheet" href="./prettify/prettify.css" type="text/css"/>
8+
<script type="text/javascript" src="./scripts/jquery.js">/**/</script><script type="text/javascript" src="./scripts/ddox.js">/**/</script>
9+
</head>
10+
<body onload="setupDdox();">
11+
<nav id="main-nav">
12+
<noscript>
13+
<p style="color: red">The search functionality needs JavaScript enabled</p>
14+
</noscript>
15+
<div id="symbolSearchPane" style="display: none">
16+
<form action="#" method="GET">
17+
<input id="symbolSearch" type="text" name="q" placeholder="Search for symbols" autocomplete="off" onchange="performSymbolSearch(40);" onkeypress="this.onchange();" onpaste="this.onchange();" oninput="this.onchange();"/>
18+
</form>
19+
<ul id="symbolSearchResults" class="symbolList" style="display: none"></ul><script type="application/javascript" src="./symbols.js"></script><script type="application/javascript">var symbolSearchRootDir = "./";
20+
$('#symbolSearchPane').show();</script>
21+
</div>
22+
<ul class="tree-view">
23+
<li>
24+
<div class="module selected">
25+
<a href="./test.html">test</a>
26+
</div>
27+
</li>
28+
</ul>
29+
</nav>
30+
<div id="main-contents">
31+
<h1>Module test</h1><p></p>
32+
<section></section>
33+
<section>
34+
<h2>Aliases</h2>
35+
<table>
36+
<col class="caption"/>
37+
<tr>
38+
<th>Name</th><th>Type</th><th>Description</th>
39+
</tr>
40+
<tr>
41+
<td>
42+
<a id="Type" class="[&quot;public&quot;]" href="./test/Type.html">
43+
<code>Type</code>
44+
</a>
45+
</td>
46+
<td>
47+
<code class="prettyprint lang-d"><span class="typ">int</span></code>
48+
</td>
49+
<td>templates with specialization and default values
50+
</td>
51+
</tr>
52+
</table>
53+
</section>
54+
<footer>
55+
<table class="license-info">
56+
<tr>
57+
<th>Authors</th>
58+
<td>
59+
60+
</td>
61+
</tr>
62+
<tr>
63+
<th>Copyright</th>
64+
<td>
65+
66+
</td>
67+
</tr>
68+
<tr>
69+
<th>License</th>
70+
<td>
71+
72+
</td>
73+
</tr>
74+
</table>
75+
<p class="faint">Generated using the DDOX documentation generator</p>
76+
</footer>
77+
</div>
78+
</body>
79+
</html>
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="UTF-8"/>
5+
<title>Alias Type</title>
6+
<link rel="stylesheet" type="text/css" href="../styles/ddox.css"/>
7+
<link rel="stylesheet" href="../prettify/prettify.css" type="text/css"/>
8+
<script type="text/javascript" src="../scripts/jquery.js">/**/</script><script type="text/javascript" src="../scripts/ddox.js">/**/</script>
9+
</head>
10+
<body onload="setupDdox();">
11+
<nav id="main-nav">
12+
<noscript>
13+
<p style="color: red">The search functionality needs JavaScript enabled</p>
14+
</noscript>
15+
<div id="symbolSearchPane" style="display: none">
16+
<form action="#" method="GET">
17+
<input id="symbolSearch" type="text" name="q" placeholder="Search for symbols" autocomplete="off" onchange="performSymbolSearch(40);" onkeypress="this.onchange();" onpaste="this.onchange();" oninput="this.onchange();"/>
18+
</form>
19+
<ul id="symbolSearchResults" class="symbolList" style="display: none"></ul><script type="application/javascript" src="../symbols.js"></script><script type="application/javascript">var symbolSearchRootDir = "../";
20+
$('#symbolSearchPane').show();</script>
21+
</div>
22+
<ul class="tree-view">
23+
<li>
24+
<div class="module selected">
25+
<a href="../test.html">test</a>
26+
</div>
27+
</li>
28+
</ul>
29+
</nav>
30+
<div id="main-contents">
31+
<h1>Alias Type</h1><p>templates with specialization and default values
32+
</p>
33+
<div class="prototype">
34+
<code class="lang-d">
35+
<div class="single-prototype">
36+
<span class="kwd">alias</span> <span class="pln">Type</span>(<span class="typ">int</span> val)
37+
<span class="pun">=</span> <span class="typ">int</span><span class="pun">;</span>
38+
</div>
39+
<div class="single-prototype">
40+
<span class="kwd">alias</span> <span class="pln">Type</span>(<span class="typ">int</span> val<span class="pln"> </span><span class="pun">: </span><span class="lit">1</span>)
41+
<span class="pun">=</span> <span class="typ">float</span><span class="pun">;</span>
42+
</div>
43+
<div class="single-prototype">
44+
<span class="kwd">alias</span> <span class="pln">Type</span>(<span class="typ">int</span> val<span class="pln"> </span><span class="pun">: </span><span class="lit">2</span><span class="pln"> </span><span class="pun">= </span><span class="lit">2</span>)
45+
<span class="pun">=</span> <span class="typ">double</span><span class="pun">;</span>
46+
</div>
47+
<div class="single-prototype">
48+
<span class="kwd">alias</span> <span class="pln">Type</span>(<span class="typ">int</span> val<span class="pln"> </span><span class="pun">: </span><span class="lit">3</span>)
49+
<span class="pun">=</span> <span class="typ">byte</span><span class="pun">;</span>
50+
</div>
51+
</code>
52+
</div>
53+
54+
55+
<footer>
56+
<table class="license-info">
57+
<tr>
58+
<th>Authors</th>
59+
<td>
60+
61+
</td>
62+
</tr>
63+
<tr>
64+
<th>Copyright</th>
65+
<td>
66+
67+
</td>
68+
</tr>
69+
<tr>
70+
<th>License</th>
71+
<td>
72+
73+
</td>
74+
</tr>
75+
</table>
76+
<p class="faint">Generated using the DDOX documentation generator</p>
77+
</footer>
78+
</div>
79+
</body>
80+
</html>

tests/issue184_tmplt_spec_val/test.d

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
///
2+
module test;
3+
4+
/// templates with specialization and default values
5+
alias Type(int val) = int;
6+
/// ditto
7+
alias Type(int val : 1) = float;
8+
/// ditto
9+
alias Type(int val : 2 = 2) = double;
10+
/// ditto
11+
alias Type(int val : 3) = byte;

0 commit comments

Comments
 (0)