Hi Sam!

This sounds interesting, though a bit to technical for me. My work regarding 
the literate programming
with LyX was with R - statistical package that provides tangle and weave 
commands that extract R code
and replace code with results, respectively. Based upon previous work I used 
literate classes since
this has been proposed earlier. However, Jean-Marc has been working on another 
approach with modules,
which make literate classes for R-LyX obsolete. Right Jean-Marc? Can this 
approach also be used for noweb
and work of Sam?

Regards, gg
________________________________________
From: Sam Liddicott [...@liddicott.com]
Sent: Tuesday, August 11, 2009 7:01 PM
To: LyX Users List
Cc: Gorjanc Gregor; landronim...@gmail.com; phgrosj...@sciviews.org
Subject: New literate programming with Lyx

At the suggestion of kayvan, I posted this message that was originally
sent to lyx-users. I hope I got the right addresses for Cc:


I've posted on http://www.lyx.org/trac/attachment/ticket/6137/
my alternative literate programming style with Lyx. I put this together
because literate programming with noweb and Lyx has been absolutely
painful in so many ways - if I wasn't a sed wizard I'd have given up.

I encourage people to try this and to give feedback.

A literate class is no longer used, you can have any document class and
add the "Newfangle Literate Listings" module to your document.

Your document will no longer be the "literate" format, so you add a
build script as a conversion from "Latex" to "Program"

Noweave is not needed, but is (mostly) implemented as Latex macros. I'm
working on getting "<<includes>>" to format properly.

The excellent lstlistings package is used for format the listings; it
has good support for syntax highlighting, line-numbering and so forth.

Because lstlistings is used instead of a passthrough scrap,
server-goto-file-row almost works, so compile errors bring you to the
correct lstlistings at least - but not the actual line number, though
this may be easily possible, (See final comments at
http://www.lyx.org/trac/ticket/6100).

notangle (which was buggy) is not used to generate the source, instead
an awk script, newfangle, is used, fixing various notangle bugs; such as:
-L broke indents
-L broke multi-line C macros

A new style "Chunk" is defined which can be used to easily name your
next lstlisting (as right-clicking and using advanced is a bit
long winded and you can't see the name you give it once you clicked OK).

Tomorrow I hope to post the chapter that produces a Makefile.inc which
automatically extracts all file sources, and can also glue into another
build system using recursive make (if you are writing literate modules
for an existing project).

Future:
I'm planning to add markup conversions between chunks; so that (for
instance) a shell-script fragment when included into a makefile will
automatically have $ converted to $$, and line endings with a \ for
multi-line shell script. This works nicely with lstlistings language
support.

There's already basic support for including fragments into some comment
contexts:

# <<frag>>
will cause each line of frag to being with #

<<frag>> \
causes each line of frag to end with \, ideal when C code is being
included into a mutli-line C macro. (This is of course not really the
correct way to do it, it should be based on the previous line ending with \)

Sam

Reply via email to