From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcelo de Moraes Serpa Subject: Re: Literate Programming with Org mode Date: Tue, 28 Jul 2009 11:46:45 -0500 Message-ID: <1e5bcefd0907280946r7b2eb7b9lac80ddc813fa9809@mail.gmail.com> References: <87my6ordhh.fsf@mundaneum.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MVppB-0005ns-M4 for emacs-orgmode@gnu.org; Tue, 28 Jul 2009 12:46:49 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MVppB-0005nF-3A for emacs-orgmode@gnu.org; Tue, 28 Jul 2009 12:46:49 -0400 Received: from [199.232.76.173] (port=38991 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MVppA-0005n0-PH for emacs-orgmode@gnu.org; Tue, 28 Jul 2009 12:46:48 -0400 Received: from mx20.gnu.org ([199.232.41.8]:53266) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MVppA-0004ix-8O for emacs-orgmode@gnu.org; Tue, 28 Jul 2009 12:46:48 -0400 Received: from mail-yx0-f172.google.com ([209.85.210.172]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MVpp9-00038h-Ds for emacs-orgmode@gnu.org; Tue, 28 Jul 2009 12:46:47 -0400 Received: by yxe2 with SMTP id 2so244165yxe.14 for ; Tue, 28 Jul 2009 09:46:46 -0700 (PDT) In-Reply-To: <87my6ordhh.fsf@mundaneum.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: =?ISO-8859-1?Q?S=E9bastien_Vauban?= Cc: emacs-orgmode@gnu.org Hmm, this seems interesting and something I'm looking for, but I'm not entirely sure what you mean by "literate programming" (I haven't googled yet either, I'm about to do it once I answer this message). Anyway, I have a project I'm working on right now that requires me to set up a "publishing environment", in the sense that I might have source files (maybe in XML or whatever format makes sense) and be able to convert them to LaTeX (for pdf), html or whatever format I could think of, using XSLT, something like the "pragmatic programmers" publishing toolchain. Not sure if literate programming has anything to do with that :) 2009/7/28 S=E9bastien Vauban : > Hi Eric and all, > > Here some promised description of how I'm using Literate Programming with > LaTeX (up to now -- soon directly from Org mode?). > > I write an "enhanced LaTeX" file ([1], having the `.nw' -- for Nuweb -- > extension). It is enhanced as I can put blocks of code in there (SQL bloc= ks, > for example), and give them a name for further referencing. > > Then, at some point in the file, I say how I want the code files to look = like, > by assembling the blocks in a certain order, with some glue. > > For example: > > --8<---------------cut here---------------start------------->8--- > <>=3D > <> > SELECT abcID, etpID, etpAssurATPolNum > FROM enterprise JOIN record > =A0 =A0ON (etpAbcID_fk =3D abcID) > WHERE etpAbcID_fk > <> > @ %def > --8<---------------cut here---------------end--------------->8--- > > The above file is made up of two defined blocks (`sql-init' and `sql-cond= ') > plus some glue in between. > > The good thing is I can reuse the same blocks in other context, completel= y > avoiding copy/paste of code: > > --8<---------------cut here---------------start------------->8--- > <>=3D > <> > SELECT abcID, lesAlternNbrSem, lesNbrSem, > =A0 =A0 =A0 CONVERT(varchar(10), lesDateDeb, @dateFmtStyleOut) AS lesDate= Deb, > =A0 =A0 =A0 CONVERT(varchar(10), lesDateFin, @dateFmtStyleOut) AS lesDate= Fin > FROM lessons JOIN record > =A0 =A0ON (lesAbcID_fk =3D abcID) > WHERE lesAbcID_fk > <> > @ %def > --8<---------------cut here---------------end--------------->8--- > > OK. So, my `org-lit-prog.nw' file is ready, and committed under Subversio= n > (this is the only one I'm committing as it contains both the documentatio= n of > the code, and the source code itself). > > Then, I just type (in a terminal): > > --8<---------------cut here---------------start------------->8--- > noweb org-lit-prog.nw > --8<---------------cut here---------------end--------------->8--- > > to extract both: > > =A0 =A0o =A0 the LaTeX file [2] to be compiled into a PDF [3], > =A0 =A0o =A0 the different source code files (Enterprise.sql [4], Lessons= .sql [5], > =A0 =A0 =A0 =A0[6] and [7]) > > Just that easy to keep code and doc in sync, and get a very nice-to-read > documentation of the code. > > Sometimes, I play an extra trick is made in the noweb file: I put blocks = of > static code (for which I don't especially need any noweb feature) after t= he > end of the LaTeX document. That way, it gets outputted by noweb as a sour= ce > file during the Tangle process, and included in my LaTeX document via the > listings package. > > Why that trick? =A0I could directly put the code in the body of the docum= ent! > Yes, but I want the code to be highlighted via listings. Otherwise, it's = just > black and white display of the code... > > For easy access, I've put all the above files on a my Web space: > > [1] http://www.mygooglest.com/sva/org-lit-prog.nw > [2] http://www.mygooglest.com/sva/org-lit-prog.tex > [3] http://www.mygooglest.com/sva/org-lit-prog.pdf > [4] http://www.mygooglest.com/sva/Enterprise.sql > [5] http://www.mygooglest.com/sva/Lessons.sql > [6] http://www.mygooglest.com/sva/Payment.sql > [7] http://www.mygooglest.com/sva/prsNumNat.awk > > From what I understand, what we both wanna reach is writing all of the `.= nw' > file as an Org file directly, and let Org-babel extracts the source code = files > and the documentation out of it. > > What should be good in the future, when it will be ready for prime time, = is > that this becomes complete part of the export process: no tangle operatio= n > needed. > > Is the above description worth for you? =A0Do you understand how I work w= hen > documenting code? =A0Pay attention: I'm *the* expert in literate programm= ing. > Just an amateur being seduced by some of its features. > > Best regards, > =A0Seb > > -- > S=E9bastien=A0Vauban > > > > _______________________________________________ > Emacs-orgmode mailing list > Remember: use `Reply All' to send replies to the list. > Emacs-orgmode@gnu.org > http://lists.gnu.org/mailman/listinfo/emacs-orgmode >