Jump to page: 1 2
Thread overview
literate programming in D
Aug 26, 2014
nikki
Aug 26, 2014
bearophile
Aug 26, 2014
nikki
Aug 26, 2014
bachmeier
Aug 26, 2014
nikki
Aug 29, 2014
nikki
Aug 29, 2014
bearophile
Aug 29, 2014
nikki
Aug 30, 2014
Philippe Sigaud
Sep 04, 2014
nikki
Sep 04, 2014
nikki
Sep 04, 2014
nikki
Sep 04, 2014
Philippe Sigaud
Aug 29, 2014
Chris Cain
Aug 30, 2014
Philippe Sigaud
Aug 30, 2014
Chris Cain
August 26, 2014
I've been googling without luck, is there a way to do literate programming in D?, similar to how it's done in Coffeescript ?

http://www.coffeescriptlove.com/2013/02/literate-coffeescript.html

basically me writing comments around code and some parser that creates styled documents from that (with highlighted source code), the current documentation system doesn't export the source code.

anybody done this before?
August 26, 2014
nikki:

> I've been googling without luck, is there a way to do literate programming in D?

D1 had built-in support for literate programming, but it was removed from D2 because it was regarded as not useful enough:
http://digitalmars.com/d/1.0/html.html

I find literate Haskell programs all the time:
gist.github.com/nooodl/e23337d0175ad66ea5f0

Or F# ones:
http://tomasp.net/blog/2014/puzzling-fsharp/

Bye,
bearophile
August 26, 2014
Aha, then It's quite safe to assume it won't be coming back I guess, then I might need to cook up some homebrew alternative.

thanks for the info
August 26, 2014
On Tuesday, 26 August 2014 at 14:55:08 UTC, nikki wrote:
> I've been googling without luck, is there a way to do literate programming in D?, similar to how it's done in Coffeescript ?
>
> http://www.coffeescriptlove.com/2013/02/literate-coffeescript.html
>
> basically me writing comments around code and some parser that creates styled documents from that (with highlighted source code), the current documentation system doesn't export the source code.
>
> anybody done this before?

Would org-mode in Emacs work for you? That's what I use.

http://orgmode.org/worg/org-contrib/babel/intro.html
August 26, 2014
That would work very fine, thanks sir!
August 29, 2014
I wasn't too happy about it and I wrote my own little parse thingie and have a literate version nice and meta and small and sloppy ;)

http://nikkikoole.github.io/docs/dokidokDOC.html

I use it to change my d sourcefile slightly (into valid markdown)
then I use a node module (ghmd) to make sortof sexy html from that.



August 29, 2014
nikki:

> I use it to change my d sourcefile slightly (into valid markdown)
> then I use a node module (ghmd) to make sortof sexy html from that.

Are you going to add popups of the types as in the F# page I have linked?

Bye,
bearophile
August 29, 2014
On Friday, 29 August 2014 at 23:41:00 UTC, bearophile wrote:
> nikki:

> Are you going to add popups of the types as in the F# page I have linked?
>
> Bye,
> bearophile

Now then you could remove the sortof from that sexy

August 29, 2014
On Tuesday, 26 August 2014 at 14:55:08 UTC, nikki wrote:
> I've been googling without luck, is there a way to do literate programming in D?, similar to how it's done in Coffeescript ?
>
> http://www.coffeescriptlove.com/2013/02/literate-coffeescript.html
>
> basically me writing comments around code and some parser that creates styled documents from that (with highlighted source code), the current documentation system doesn't export the source code.
>
> anybody done this before?

I used https://www.npmjs.org/package/literate-programming (+ pandoc) to do this when writing https://dl.dropboxusercontent.com/u/2206555/uniformUpgrade.pdf in markdown (which transformed to both a .d source file and a pdf document as shown in the link). literate-programming has since been improved since the last time I used it (before, I had to do a few tricks to get the pandoc flavored markdown to work well, but from what I can see, those tricks aren't necessary anymore).
August 30, 2014
On Sat, Aug 30, 2014 at 1:37 AM, nikki wrote:
> I wasn't too happy about it and I wrote my own little parse thingie and have
> a literate version nice and meta and small and sloppy ;)
>
> http://nikkikoole.github.io/docs/dokidokDOC.html
>
> I use it to change my d sourcefile slightly (into valid markdown)
> then I use a node module (ghmd) to make sortof sexy html from that.

Nice. Maybe you could strip the initial whitespaces in the code parts: due to blocks, your code lines are shifting to the right. If you document something that's inside a method inside a class, you're bound to have problems :)


Right now, you're documenting your code in a linear way. That's good, but for me, most of LP is based around the idea of naming snippets and referring to them in code, to be explained elsewhere:

```
Here is the main loop:

<Main>=
void main() {
    <Initialize Variables>
    <Precompute State>
    foreach(i; 0..max) {
        <Do Computation>
    }
}

Before doing all this, we need to initialize the variables:

<Initialize Variables>= ...
```

Of course, snippets can refer to other snippets, recursively.

Do you have any plan to go there?
« First   ‹ Prev
1 2