Phobos runnable examples - ideas request

2013-03-27 Thread nazriel
Greetings. I would like to finish Phobos runnable examples case. But I need help in picking one strategy for implementation details. Current state of things is rather bad. Apart from the fact that lots of examples are not valid examples per se (first example in std.algorithm: --- in

Re: Phobos runnable examples - ideas request

2013-03-28 Thread Jacob Carlborg
On 2013-03-27 22:54, nazriel wrote: Requesting user to edit code first, add main(){} block or fix invalid D code and then run example itself is unacceptable. RDMD already has a --main flag and DMD will soon too. -- /Jacob Carlborg

Re: Phobos runnable examples - ideas request

2013-03-28 Thread Timothee Cour
I think it's too fragile to require examples inside docs to be runnable. A better way would be to expose those examples in the code (ie outside of comments). That way, they'll be guaranteed to have correct syntax, be properly syntax highlighted, and stay in sync with code. here's a simple possibil

Re: Phobos runnable examples - ideas request

2013-03-28 Thread 1100110
On 03/27/2013 04:54 PM, nazriel wrote: [snip] The options I've gathered so far: 1) Make all examples valid D code by hand. Make JavaScript assume that all code examples in Phobos documentation should be wrapped in void main() {} blocks. Add default set of includes + the module we are on. Explicit

Re: Phobos runnable examples - ideas request

2013-03-28 Thread nazriel
On 03/28/2013 07:18 AM, Jacob Carlborg wrote: On 2013-03-27 22:54, nazriel wrote: Requesting user to edit code first, add main(){} block or fix invalid D code and then run example itself is unacceptable. RDMD already has a --main flag and DMD will soon too. Yes, DMD trunk already does that

Re: Phobos runnable examples - ideas request

2013-03-28 Thread nazriel
On 03/28/2013 07:46 AM, Timothee Cour wrote: I think it's too fragile to require examples inside docs to be runnable. A better way would be to expose those examples in the code (ie outside of comments). That way, they'll be guaranteed to have correct syntax, be properly syntax highlighted, and st

Re: Phobos runnable examples - ideas request

2013-03-28 Thread nazriel
On 03/28/2013 09:53 AM, 1100110 wrote: I'll work on 1. and see if we can't come up with something better! The code snippets are pretty much necessary IMO. They just need to be fixed. int[] a = ...; static bool greater(int a, int b) { return a > b; } sort!(greater)(a); // predicate a

Re: Phobos runnable examples - ideas request

2013-03-28 Thread 1100110
On 03/28/2013 12:09 PM, nazriel wrote: On 03/28/2013 09:53 AM, 1100110 wrote: I'll work on 1. and see if we can't come up with something better! The code snippets are pretty much necessary IMO. They just need to be fixed. int[] a = ...; static bool greater(int a, int b) { return a > b; }

Re: Phobos runnable examples - ideas request

2013-03-28 Thread Johannes Pfau
Am Wed, 27 Mar 2013 22:54:21 +0100 schrieb "nazriel" : > Greetings. > > I would like to finish Phobos runnable examples case. But I need > help in picking one strategy for implementation details. > With the recent unittest-as-example changes I'd say make runnable examples work with those and p

Re: Phobos runnable examples - ideas request

2013-03-28 Thread H. S. Teoh
On Thu, Mar 28, 2013 at 07:25:07PM +0100, Johannes Pfau wrote: > Am Wed, 27 Mar 2013 22:54:21 +0100 > schrieb "nazriel" : > > > Greetings. > > > > I would like to finish Phobos runnable examples case. But I need > > help in picking one strategy for implementation details. > > > > With the rece

Re: Phobos runnable examples - ideas request

2013-03-28 Thread 1100110
On 03/28/2013 01:25 PM, Johannes Pfau wrote: > Greetings. > > I would like to finish Phobos runnable examples case. But I need > help in picking one strategy for implementation details. > Good point, I forgot about that.

Re: Phobos runnable examples - ideas request

2013-03-29 Thread Andrei Alexandrescu
On 3/27/13 5:54 PM, nazriel wrote: Greetings. I would like to finish Phobos runnable examples case. But I need help in picking one strategy for implementation details. Current state of things is rather bad. Apart from the fact that lots of examples are not valid examples per se (first example