dlang-community / libddoc

D implementation of the DDoc macro system
Boost Software License 1.0
7 stars 9 forks source link

[Bug] Embedded code is not part of examples #24

Open Geod24 opened 9 years ago

Geod24 commented 9 years ago

I took a fresh look at the docs and what DMD is doing. We currently make embedded code (aka code within ---) as belonging to the examples section where they really aren't (I've no idea why I implemented it this way to start with).

DMD is really doing the right thing here. I tried with the command dmd -c -Dffoo.html test.d debug.ddoc debug.ddoc:

DDOC=$(BODY)
DDOC_SUMMARY=[SUMMARY $0]
DDOC_DESCRIPTION=[DESCRIPTION $0]
DDOC_THROWS=[THROWS $0]

test.d:

/**
 * Module title
 *
 * This is the description
 * ----
 * // This really is part of the description
 * ----
 * Moar description
 *
 * Throws:
 * Exception obviously
 * ---
 * auto exception = new Exception("This is part of Throws too");
 * ---
 */
module doc.test;

Output:

<!-- Generated by Ddoc from test.d -->
[SUMMARY Module title
]
[DESCRIPTION  This is the description
<pre class="d_code"><font color=green>// This really is part of the description
</font></pre>
 Moar description

]
[THROWS  Exception obviously
<pre class="d_code"><font color=blue>auto</font> exception = <font color=blue>new</font> Exception(<font color=red>"This is part of Throws too"</font>);
</pre>
]

This should hopefully simplify section parsing quite a bit. Will it have a big impact on harbored ?