Allow runnable examples anywhere#1709
Conversation
67d31fb to
44cbc93
Compare
|
Update: As explained in #1711 (comment), there's absolutely no need for the MD5 hashing - saving STDIN next to the example is a lot friendlier to the user, |
|
For the lazy - a link to the modified module spec: http://dtest.dlang.io/artifact/website-a4153fc60f57d597ed0ef253643679077b7374af-6e5e8ea6c097cbc8c88dba65ceeb3f89/web/spec/module.html CC @andralex - you might like this ;-) |
Indeed, the implementation looks much better now. |
|
And it's online: http://dlang.org/spec/module.html It looks that most of the spec examples actually don't compile, because they explicitly trigger errors. Any good idea how we could mitigate this? |
|
Oh, I see. Well I'd say in the cases where the error is part of the very point of the code, leave it in. For example: import io = std.stdio;
void main()
{
io.writeln("hello!"); // ok, calls std.stdio.writeln
std.stdio.writeln("hello!"); // error, std is undefined
writeln("hello!"); // error, writeln is undefined
}I suppose part of the impetus to edit and run that example is to mess with it and see what fails and what works, starting under the assumption it's not buildable as is. |
With this addition the D specification could be made runnable as it's then a simple question of going through it once and adding
$(RUNNABLE_EXAMPLE )around everything all code blocks that are runnable.As an example I have "runnified" spec/module.html
Of course, unlike for Phobos, we don't verify the run status yet.