Skip to content

Commit

Permalink
Merge pull request #4660 from 9rnsr/fix14594
Browse files Browse the repository at this point in the history
[REG2.068a] Issue 14594 - DDoc for template functions and structs has disappeared
  • Loading branch information
andralex committed May 17, 2015
2 parents ae0c87f + b65066f commit 191fee6
Show file tree
Hide file tree
Showing 3 changed files with 139 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/doc.c
Expand Up @@ -620,6 +620,9 @@ static size_t getCodeIndent(const char *src)

void emitUnittestComment(OutBuffer *buf, Scope *sc, Dsymbol *s, size_t ofs)
{
if (Dsymbol *td = getEponymousParent(s))
s = td;

for (UnitTestDeclaration *utd = s->ddocUnittest; utd; utd = utd->ddocUnittest)
{
if (utd->protection.kind == PROTprivate || !utd->comment || !utd->fbody)
Expand Down Expand Up @@ -680,11 +683,7 @@ void emitDitto(Dsymbol *s, OutBuffer *buf, Scope *sc)
sc->lastoffset += b.offset;
sc->lastoffset2 += b.offset;

Dsymbol *p = s;
if (!s->ddocUnittest && s->parent)
p = s->parent->isTemplateDeclaration();
if (p)
emitUnittestComment(buf, sc, p, sc->lastoffset2);
emitUnittestComment(buf, sc, s, sc->lastoffset2);
}

/** Recursively expand template mixin member docs into the scope. */
Expand Down Expand Up @@ -1541,8 +1540,7 @@ void DocComment::writeSections(Scope *sc, Dsymbol *s, OutBuffer *buf)
else
sec->write(loc, this, sc, s, buf);
}
if (s->ddocUnittest)
emitUnittestComment(buf, sc, s, buf->offset);
emitUnittestComment(buf, sc, s, buf->offset);

if (buf->offset == offset2)
{
Expand Down
73 changes: 73 additions & 0 deletions test/compilable/ddocunittest.d
Expand Up @@ -418,6 +418,79 @@ unittest
int[] arr;
}

// ------------------------------------
// 14594

/*******************
* testA
*/
void fun14594a()() {}
///
unittest { fun14594a(); }

/*******************
* testB
*/
void fun14594b()() {}
/// ditto
void fun14594b(T)(T) {}
///
unittest { fun14594b(); fun14594b(1); }

/*******************
* testC
*/
void fun14594c()() {}
///
unittest { fun14594c(); fun14594c(1); }
/// ditto
void fun14594c(T)(T) {}

/*******************
* testD
*/
void fun14594d()() {}
///
unittest { fun14594d(); }
/// ditto
void fun14594d(T)(T) {}
///
unittest { fun14594d(1); }

/*******************
* testE
*/
template fun14594e()
{
/// concatenated doc-comment fun14594e
void fun14594e() {}
/// ignored-unittest fun14594e
unittest { fun14594e(); }
}
/// doc-unittest fun14594e
unittest { fun14594e(); }

/*******************
* testF
*/
template fun14594f()
{
/// concatenated doc-comment fun14594f
void fun14594f() {}
/// ignored-unittest fun14594f
unittest { fun14594f(); }
}
/// ditto
template fun14594f(T)
{
/// ignored doc-comment fun14594f
void fun14594f(T) {}
/// ignored-unittest fun14594f
unittest { fun14594f(1); }
}
/// doc-unittest fun14594f
unittest { fun14594f(); }

// ------------------------------------

void main() { }
61 changes: 61 additions & 0 deletions test/compilable/extra-files/ddocunittest.html
Expand Up @@ -332,6 +332,67 @@ <h1>ddocunittest</h1>
</dd>
</dl>
</dd>
<dt><big><a name="fun14594a"></a>void <u>fun14594a</u>()();
</big></dt>
<dd>testA<br><br>
<b>Examples:</b><br>
<pre class="d_code"><u>fun14594a</u>();
</pre>
<br><br>
</dd>
<dt><big><a name="fun14594b"></a>void <u>fun14594b</u>()();
<br>void <u>fun14594b</u>(T)(T);
</big></dt>
<dd>testB<br><br>
<b>Examples:</b><br>
<pre class="d_code"><u>fun14594b</u>(); <u>fun14594b</u>(1);
</pre>
<br><br>
</dd>
<dt><big><a name="fun14594c"></a>void <u>fun14594c</u>()();
<br>void <u>fun14594c</u>(T)(T);
</big></dt>
<dd>testC<br><br>
<b>Examples:</b><br>
<pre class="d_code"><u>fun14594c</u>(); <u>fun14594c</u>(1);
</pre>
<br><br>
</dd>
<dt><big><a name="fun14594d"></a>void <u>fun14594d</u>()();
<br>void <u>fun14594d</u>(T)(T);
</big></dt>
<dd>testD<br><br>
<b>Examples:</b><br>
<pre class="d_code"><u>fun14594d</u>();
</pre>
<br><br><b>Examples:</b><br>
<pre class="d_code"><u>fun14594d</u>(1);
</pre>
<br><br>
</dd>
<dt><big><a name="fun14594e"></a>void <u>fun14594e</u>()();
</big></dt>
<dd>testE
<br><br>
concatenated doc-comment <u>fun14594e</u><br><br>
<b>Examples:</b><br>
doc-unittest <u>fun14594e</u>
<pre class="d_code"><u>fun14594e</u>();
</pre>
<br><br>
</dd>
<dt><big><a name="fun14594f"></a>void <u>fun14594f</u>()();
<br>void <u>fun14594f</u>(T)(T);
</big></dt>
<dd>testF
<br><br>
concatenated doc-comment <u>fun14594f</u><br><br>
<b>Examples:</b><br>
doc-unittest <u>fun14594f</u>
<pre class="d_code"><u>fun14594f</u>();
</pre>
<br><br>
</dd>
</dl>

<hr><small>Page generated by <a href="http://dlang.org/ddoc.html">Ddoc</a>. </small>
Expand Down

0 comments on commit 191fee6

Please sign in to comment.