automatic code examples in documentation

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Fri Oct 15 16:12:47 PDT 2010


On 10/15/10 18:00 CDT, Tomek Sowiński wrote:
> Andrei Alexandrescu napisał:
>
>> I'm happy with a much more modest change that doesn't add anything to
>> the syntax. Simply prefixing a unittest with a documentation comment
>> makes it an example:
>>
>> /**
>> The example below illustrates how D gets a basic arithmetic operation
>> totally right.
>> */
>> unittest
>> {
>> assert(1 + 1 == 2);
>> }
>>
>> The documentation generator simply plops the comment and then formats
>> the code as an example code.
>
> Let's drill down on this:
>
> /// The ultimate foo.
> void foo();
>
> /// The test.
> unittest { ... }
>
> What would be the<dl><dt><dd>  outline of the above snippet?

 From a ddoc perspective this should be the same as:

/** The ultimate foo.

The test.
----
...
----
*/
void foo();


Andrei


More information about the Digitalmars-d mailing list