On Thursday, 20 August 2015 at 06:28:44 UTC, Jacob Carlborg wrote:
On 2015-08-20 01:41, Laeeth Isharc wrote:
Should this be done?  How?

Just use a documented unit tests block:

///
unittest
{
    // code goes here
}

It will be run as part of the unit tests and it will be included when generating the documentation.

Although I don't have a good solution for the code in dlang.org that's not part of the Phobos/druntime documentation.

It think it would be a positive for dlang.org's code to be unit tested, but it might also be tricky if that were the only option for including code in dlang.org.

For instance, suppose the dlang.org page looks something like
text
code block
text
code block that depends on above code block

I actually see this rather often. If you change the code blocks to unit tests, then the second code block would not compile by itself. I see two options: 1) make one big unit test and have the second piece of text be a comment in it, 2) include the original unit test in the second code block (messy and has its own set of problems).

Maybe there is a solution to this, but I think it would require some sort of change. Maybe one solution is to improve the way text comments can be used with unit tests. Alternately, it might be interesting to have a way to refer/import other unit tests.

Reply via email to