automatic code examples in documentation

Tomek Sowiński just at ask.me
Fri Oct 15 16:00:31 PDT 2010


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?

-- 
Tomek


More information about the Digitalmars-d mailing list