[comp.sources.wanted] Wanted: tools for source code presentation

jonathan@cs.pitt.edu (Jonathan Eunice) (04/16/91)

I need to publish some source code soon, and I'd like it to be nicely
presented.  I'm already using indent and doing a goodly amount of 
manual tweaking, but I'm searching for some automatic assistance.

In particular, I'd like to have my comments italicized, just like the
Sun manuals do (to good effect).  This would require, at minimum,
some ?roff macros, plus a tool to scan the code and insert appropriate
formatting commands.  Not hard to do, but I've got little time to
do it.  Anyone have anything already cooked up?

Also, I am open to other code-beautifying tools, if such exist.

jonathan@cs.pitt.edu (Jonathan Eunice) (04/19/91)

I recently asked:

|  I need to publish some source code soon, and I'd like it to be nicely
|  presented.  I'm already using indent and doing a goodly amount of 
|  manual tweaking, but I'm searching for some automatic assistance.
|  
|  In particular, I'd like to have my comments italicized, just like the
|  Sun manuals do (to good effect).  This would require, at minimum,
|  some ?roff macros, plus a tool to scan the code and insert appropriate
|  formatting commands.  Not hard to do, but I've got little time to
|  do it.  Anyone have anything already cooked up?
|  
|  Also, I am open to other code-beautifying tools, if such exist.


I got the following (slightly edited) replies so far.   If more come in 
with good suggestions, I'll post an ammended summary.


----------
From: ornstein@tramp.Colorado.EDU (Jason Ornstein)

Well, I can tell you what I use to print my source code.  

soelim file1 | vgrind -f | groff -me -Tps > file2.ps

file1 is as follows
.vS
.so file.c
.vE

and that is it.  vgrind puts comments in italic, keywords in bold, and
some other nifty things.  There is a way to do this without soelim,
but many of use could not figure it out with groff (most likey vgrind
with plain troff will work)



---------
From: Jonathan I. Kamens <jik@pit-manager.MIT.EDU>

  If you can use PostScript, then the pps program in the comp.sources.unix
archive will do what you want.

  There's also the "vgrind" program, which is installed by default on many
Unix systems.  If it isn't installed on your system, you can get it from the
net; it is freely redistributable, and should be available in the 4.3BSD
sources on gatekeeper.dec.com or the 4.3reno sources on uunet.uu.net.

  If you use tex, there's also tgrind, which does the same thing as vgrind but
produces tex output instead of nroff output.



----------
From: cchwitz@kocb.astem.or.jp

If you can use LaTeX, why not try C++2LaTeX, which will surely fit
your purpose. This would convert c++ and c source codes to fancy LaTeX
sources.

I think you can ftp it from
tupac-amaru.informatik.twth-aachen.de[192.35.229.9]
or, maybe from ymir.claremont.edu .




----------
From: david@lta.lta.com (David B. Lewis)

> I need to publish some source code soon, and I'd like it to be nicely

I use an old copy off pps, which does most of this. It has some bad flaws
but is useful. Probably on uunet, which is where I think I got it.



----------
From: hapke@urbana.mcd.mot.com (Warren Hapke)

What you want, I think, is "vgrind," which is a tool distributed with
BSD UNIX.  It processes C code and italicizes comments, etc.  I think
it may also work on Pascal, but I'm not sure about that.  A special set
of macros are used to print the source.  vgrind, if I remember correctly,
is smart enough to know that a single backslash in C should be escaped
so it will print as a backslash when processed by troff.  vgrind does not
change indentation, etc., so you may still need to use indent.

Lots of people are now using constant-width fonts for presenting code.
This simplifies matters quite a bit, although it does not look as handsome
as the output of vgrind.



----------
From: diekema@jdbbs.mi.org (Jon Diekema)

You might look up the grind tools. I have used tgrind on a VAX
that enhanced my C source and produced TeX. SunOS has something
called vgrind. Here is the man page:

NAME
     vgrind - grind nice program listings

[...]

DESCRIPTION
     vgrind formats the	program	sources	 named	by  the	 filename
     arguments	in  a  nice  style  using troff(1).  Comments are
     placed in italics,	keywords in bold face, and as each  func-
     tion is encountered its name is listed on the page	margin.

[...]