comp.lang.ada
 help / color / mirror / Atom feed
From: Andre <avsaway@hotmail.com>
Subject: Re: Literate Programming in Ada, AdaDoc, AdaBrowse
Date: Sun, 10 Oct 2004 11:34:15 +0200
Date: 2004-10-10T11:34:15+02:00	[thread overview]
Message-ID: <ckavmo$2v3$1@news6.zwoll1.ov.home.nl> (raw)
In-Reply-To: <2sqmccF1oit5sU1@uni-berlin.de>

Nick Roberts wrote:
> Time for the latest hairbrained scheme from your uncle Nicky.
> 
> I've been struggling with the question of how best to do the 
> documentation accompanying open source Ada projects. It is especially 
> important that the maintenance (as well as user) documentation is 
> present, usable, and itself continuously maintainable, for this kind of 
> project.
> 
> I've tinkered with DocBook, Texinfo, and other systems (even trying to 
> invent one of my own). I've attempted to add 'literate programming' 
> functionality to these systems.
> 
> Literate programming is a fancy way of documenting source code. The 
> basic idea is that you break up the source code into fragments, and 
> intersperse appropriate documentation with the fragments. The fragments 
> can be reordered, and referentially contain other fragments (to form a 
> hierarchy). This technique is capable of producing superbly documentated 
> source code, since you can introduce concepts in the order which best 
> fits explication, and show just the source code that needs to be 
> described as you go along.
> 
> However, LP has problems. The classic mechanism requires that orignal 
> program and document source text be intermixed in a single or set of 
> physical text files, called 'web' files (nothing to do with the WWW). A 
> 'tangle' tool must be run to generate the actual source code files 
> (which can be submitted to the compiler). This adds a new step, 
> potentially a big and slow one, to the program development cycle. An 
> alternate approach has been the idea of a mechanism to update the web 
> files from changes made directly in the source code files, but this 
> technique does not seem to have got very far.
> 
> Up to now, I've been opposed to the idea of putting the main 
> (maintenance) documentation directly into the Ada source files 
> (particularly the package specifications), on the grounds that this 
> prevents the use of existing document preparation systems.
> 
> However, I'm now coming around to the idea. My latest hairbrained scheme 
> is to write a program that will do a little bit of work reformatting 
> comments in an Ada source file. I'm fairly sure it's not an original 
> idea, but I cannot actually find references (on the WWW) to such a tool. 
> Can emacs Ada Mode do something like this? My favourite editor is PFE 
> (for Windows). It has a limited macro capability, but it's too limited 
> for something like this.
> 
> Besides which, different people have differrent editors and document 
> preparation systems (as a matter of availability or choice), and so an 
> open source project ideally needs to be as agnostic on these things as 
> possible.
> 
> So I propose to write a simple Ada program that will perform the 
> following transformations on an Ada source file:
> 
> * If a line begins with "-- " (not indented), it and any immediately 
> following non-blank lines are word-filled. Before word-filling, any "-- 
> " at the beginning of a line is removed. After word-filling, every 
> output line is prefixed by "-- ". Words are simply delimited by 
> whitespace (there's no hyphenation or other fancy stuff).
> 
> * If a line begins with "--+", the remainder of the line is taken to be 
> a pathname of a text file, whose contents are read. All following lines 
> up to (but not including) a line beginning with "---" are deleted. The 
> lines read from the text file are inserted, after having macro 
> substitutions performed (as described next).
> 
> * Any occurrance of "${" followed by a name-string and then "}" is 
> replaced by another string according to the name-string, iff the 
> name-string is recognised.
> 
> Recognised name-strings are:
> 
> * "LINE", which is replaced by the current line number in the source file;
> 
> * "FILE", which is replaced by the full pathname of the source file;
> 
> * "DATE", which is replaced by the current date and time.
> 
> I also propose writing another quite simple Ada program which will 
> generate an HTML rendition of an Ada source file. Features that could be 
> incrementally added to this program could be:
> 
> * colour-code the Ada source text (highlighting reserved words, 
> literals, etc.);
> 
> * simple formatting of the text in unindented comments (e.g. embolden 
> !never!, italicise /always/, <code>-tag text between {} braces, etc.);
> 
> * index the identifiers, including identifiers within braces within 
> unindented comments.
> 
> Also being able to generate an Texinfo rendition might be very handy, as 
> well as XML (DocBook), TeX, or other formats.
> 
> These ideas lead us to the existing AdaDoc and AdaBrowse projects, both 
> hosted on SourceForge. These seem to be very relevant to what I'm trying 
> to achieve. However: development on AdaDoc seems to have stopped (since 
> 2002); AdaBrowse relies on ASIS.
> 
> AdaDoc is written substantially in French (by Frenchmen). I don't 
> personally have any objection to developing software in French, but it 
> might seem less than ideal to some people. (Does it?) Is AdaDoc a dead 
> project?
> 
> There are two reasons why I have an objection to the use of ASIS: 
> AdaBrowse cannot be used on a source file which cannot be compiled (e.g. 
> because it is still in an early state of development, or it has an 
> unresolved error in it); a compiler which supports ASIS must be 
> available. It does seem almost like using a sledgehammer to crack a nut.
> 
> Comments welcome.
> 

I think you need to keep it simple (as many of the replies also state)
Here a sample of how I write down my comment in the source code.

    --  .Operation: Put a date-time in a string
    --  .Preconditions:
    --   .in: FTime, the date-time
    --  .Semantics:
    --   Format the date-time in yyyy-mm-dd hh:mm:ss.mmm
    --  .Postconditions:
    --   .return: a string with the date-time
    function Date_As_Str
       (SysTime : SYSTEMTIME)
       return String;

I have written a small program which takes the main ada source file as 
input and browses all 'with's to parse all source files. Each source 
file gets its onw HTML file with documentation.

I use '--  .<keyword>:' to detect if it is valid documentation.

Of course this can be extended with additional stuff to format the 
documentation, add images, hyperlinks and ....

When I finish a (re)design or want an update of my documentation, I just 
run my own program to create the HTML pages.
I also create a Microsoft help project with all the HTML files. Then I 
can create a Compiled Help file, which I can print to paper or to PDF 
using PDF Creator.




  parent reply	other threads:[~2004-10-10  9:34 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-09 17:44 Literate Programming in Ada, AdaDoc, AdaBrowse Nick Roberts
2004-10-09 18:39 ` Wes Groleau
2004-10-09 21:04   ` Nick Roberts
2004-10-09 21:39     ` stephane richard
2004-10-09 23:40     ` Wes Groleau
2004-10-10 16:39     ` Simon Wright
2004-10-12  0:42       ` Georg Bauhaus
2004-10-11  7:33     ` Ole-Hjalmar Kristensen
2004-10-09 19:21 ` Pascal Obry
2004-10-09 21:47   ` Nick Roberts
2004-10-09 23:20     ` Björn Persson
2004-10-10  8:28       ` Oliver Kellogg
2004-10-10 10:03         ` Björn Persson
2004-10-10 15:27           ` Stephen Leake
2004-10-09 23:49     ` Wes Groleau
2004-10-10 10:36     ` Pascal Obry
2004-10-10 11:26       ` Marius Amado Alves
2004-10-18  8:17         ` Jacob Sparre Andersen
2004-10-18 11:15           ` Marius Amado Alves
2004-10-18 12:46             ` Björn Persson
2004-10-18 15:39               ` Marius Amado Alves
2004-10-18 13:47             ` Jacob Sparre Andersen
2004-10-09 22:54 ` Lionel Draghi
2004-10-09 22:56 ` Björn Persson
2004-10-09 23:55   ` Wes Groleau
2004-10-10  1:02     ` Björn Persson
2004-10-10 14:02       ` Wes Groleau
2004-10-10  3:29 ` Steve
2004-10-10 14:08   ` Wes Groleau
2004-10-10 15:06     ` Steve
2004-10-10 15:20   ` Stephen Leake
     [not found]   ` <rlsfz4jdjuj.fsf@jacob.crs4.it>
2004-10-15 13:33     ` Marius Amado Alves
2004-10-16  1:50     ` Steve
2004-10-16 19:46       ` Jacob Sparre Andersen
2004-10-17  3:46         ` Steve
2004-10-10  8:21 ` Stephane Riviere
2004-10-11 23:02   ` Björn Persson
2004-10-11 23:31     ` Missing features in NaturalAdaBrowseDoc Lionel Draghi
2004-10-12  0:14       ` tmoran
2004-10-12 12:58       ` Marc A. Criley
2004-10-12 21:20         ` Lionel Draghi
2004-10-12 17:49       ` Stephane Riviere
     [not found]         ` <416c48a7$0$28918$636a15ce@news.free.fr>
2004-10-12 21:18           ` Lionel Draghi
2004-10-13 16:38           ` Stephane Riviere
2004-10-14 19:56             ` Lionel Draghi
2004-10-15 16:59               ` Stephane Riviere
2004-10-12 17:29     ` Literate Programming in Ada, AdaDoc, AdaBrowse Stephane Riviere
2004-10-10  9:34 ` Andre [this message]
2004-10-10 15:24   ` Stephen Leake
2004-10-10 18:04     ` Andre
2004-10-11 23:32     ` Lionel Draghi
2004-10-12  0:13       ` Björn Persson
2004-10-10 15:13 ` Stephen Leake
2004-10-11 20:28 ` Nick Roberts
2004-10-11 22:26   ` Björn Persson
2004-10-12 14:09     ` Nick Roberts
2004-10-13  5:01       ` Pylinius
2004-10-13 16:06         ` Nick Roberts
2004-10-13 17:17     ` Pascal Obry
2004-10-17 18:47   ` Bernhard Mulder
2004-10-18 18:06     ` Nick Roberts
2004-10-19  4:41       ` Bernhard Mulder
2004-10-19  9:52         ` Peter Hermann
2004-10-19 10:01         ` Nick Roberts
2004-10-23 21:39           ` Bernhard Mulder
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox