[haiku] Re: GRRR! [was: Re: Man]

  • From: pete.goodeve@xxxxxxxxxxxx
  • To: haiku@xxxxxxxxxxxxx
  • Date: Wed, 1 Sep 2010 00:10:40 -0700

On Tue, Aug 31, 2010 at 05:14:17PM +0200, Oliver Tappe wrote:
> On 2010-08-31 at 07:51:13 [+0200], Siarzhuk Zharski <zharik@xxxxxx> wrote:
> 
> [ ... ]
> > 
> > What do you think about following:
> > a) Provide "man->html" data translator to let the GUI browsers to use
> > man pages directly from the Tracker;
> 
> The problem I see with the man->html step is that it only works well for 
> single-"page" documentation, but what you don't get is navigability across 
> pages. And for large documentation packages (gcc, perl), being able to 
> browse the documentation by activating links is highly desirable. 
> 
Of course 'man' itself doesn't navigate across pages either -- if you
see a reference to another you have to get at it with another command.
As I said in another post, there seems to be more than one level of
appropriate documentation, with a full hyperlinked manual at the top.

Maybe I'm just being silly, and I have no intention of stepping on
your toes Oliver, but I thought it would be fun to see what could be
done in a hour or so, and I ended up with a script that, at a basic
level, seems to do pretty much what we've been talking about.  And
the whole sequence is pretty near instantaneous.

It uses 'rman' ('polyglotman') to translate man->html, and calls
WebPositive on that.  I noticed that rman is in the Haiku source tree,
but I also found that the version there (3.2) won't run in either
Haiku or BeOS.  (Haven't tried to chase why.)  However, I've been
using v3.0.4 in BeOS for years, and it also compiles and runs fine
in Haiku.  I don't know where I got it originally, as I can't find it
on BeBits (Daniel Lundin ported it), so if you want to play, I've
put a copy at http://goodeveca.net/beos/rman-3.0.4-BeOS.zip

Anyway, here's the script "wpman" (also useable as a xicon script, where you
could drop an app on it to see if there's a man page):


#! /bin/sh
WPS="$(query '(BEOS:APP_SIG=="application/x-vnd.Haiku-WebPositive")')"
if [ "$(basename $WPS)" != "WebPositive" ]; then echo "Couldn't find WP"; exit; 
fi

if [ $# -eq 0 ]; then echo "Usage: $(basename $0) [<group>] <name>"; exit; fi
if [ $# -gt 2 ]; then echo "Can't handle more than one man page..."; exit; fi
if [ $# -eq 2 ]; then # assume a group number
  NAME=$2
  MAN=($(find /boot/common/man -name "$2.$1"))
else
  NAME=$(basename $1)   # might be a dropped app pathname (xicon), so trim it
  MAN=($(find /boot/common/man -name "$NAME.?"))
fi
MAN=${MAN[0]}   # can only handle one file
if [ "$MAN" == "" ]; then echo "No man page found"; exit; fi

echo man page: $MAN
rman -f html $MAN >/tmp/$NAME.html 2>/dev/null
$WPS /tmp/$NAME.html 2>/dev/null &


A quickie, and surely not idiot-proof, but you can do things like

  wpman cvs
or
  wpman 5 cvs

and have the page pop up immendiately.

Cheers,
        -- Pete --


Other related posts: