D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 1117 - ddoc generates corrupted docs if code examples contain attributes with colons
Summary: ddoc generates corrupted docs if code examples contain attributes with colons
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: x86 All
: P2 normal
Assignee: No Owner
URL:
Keywords: ddoc, patch
: 1652 (view as issue list)
Depends on:
Blocks:
 
Reported: 2007-04-09 13:30 UTC by Max Samukha
Modified: 2020-05-19 05:43 UTC (History)
5 users (show)

See Also:


Attachments
Ddoc output (576 bytes, text/html)
2007-09-29 07:12 UTC, Stewart Gordon
Details

Note You need to log in before you can comment on or make changes to this issue.
Description Max Samukha 2007-04-09 13:30:21 UTC
Corrupted documentation is generated by ddoc for code examples having attributes with colons:

/**
Example:
---
private:
    int i = 0;
---
*/
void main()
{
}

Generated html:
<html><head>
	<META http-equiv="content-type" content="text/html; charset=utf-8">
	<title>hello</title>
	</head><body>
	<h1>hello</h1>
	<!-- Generated by Ddoc from hello.d -->
<br><br>
$(DDOC_MODULE_MEMBERS 
<dt><big>void <u>main</u>();

</big></dt>
$(DDOC_DECL_DD <b>Example:</b><br>
<pre class="d_code"></pre>
<b>private:</b><br>
int i = 0;
<pre class="d_code"></pre>
<br><br>
<br><br>


	<hr><small>Page generated by <a href="http://www.digitalmars.com/d/ddoc.html">Ddoc</a>. </small>

	</body></html>
Comment 1 Stewart Gordon 2007-09-29 07:12:17 UTC
Created attachment 186 [details]
Ddoc output

Attached for testing convenience.
Comment 2 Don 2009-10-28 00:57:35 UTC
CAUSE: when splitting into sections, identifiers inside code sections should be ignored.
(In the code below, note that "--foo:" is not a section).
This patch also fixes bug 195.

PATCH:
doc.c, parseSections() line 965 (DMD2.035)

	/* Find end of section, which is ended by one of:
-	 *	'identifier:'
+	 *	'identifier:' (but not inside a code section)
	 *	'\0'
	 */
	idlen = 0;
+	bool inCode = false;
	while (1)
	{
+	    if (*p=='-') { // check for start/end of a code section
+		int numdash=0;
+	        while(*p=='-') {
+	            ++numdash;
+	            p++;
+	        }
+		if (!*p || *p=='\r' || *p=='\n' && numdash>=3)
+			inCode = !inCode;
+	    }
-	    if (isalpha(*p) || *p == '_')
+	    else if (!inCode && (isalpha(*p) || *p == '_'))
	    {
		q = p + 1;
		while (isalnum(*q) || *q == '_')
Comment 3 Leandro Lucarella 2009-10-29 14:37:02 UTC
Related SVN revision: http://www.dsource.org/projects/dmd/changeset/227
Comment 4 Walter Bright 2009-11-06 11:29:22 UTC
Fixed dmd 1.051 and 2.036
Comment 5 Don 2010-01-15 07:23:24 UTC
*** Issue 1652 has been marked as a duplicate of this issue. ***
Comment 6 Dlang Bot 2020-05-19 05:43:06 UTC
dlang/dub pull request #1946 "Make the testsuite re-runnable on OSX" was merged into master:

- ad164ef26ce226e269352fe828727632c4f4b40e by Geod24:
  testsuite: Make issue1117 test re-runnable
  
  It's the little things in life, like being able to re-run your test-suite
  on your own machine, that makes the greatest joy.

https://github.com/dlang/dub/pull/1946