jayduhon / inferno-os

Automatically exported from code.google.com/p/inferno-os
2 stars 0 forks source link

man pages: update/fix /man/*/INDEX #287

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I've re-generate man INDEX files from current man pages using this script:

  cd /man/2
  perl -0777 -ne '
    next if $ARGV eq "INDEX";
    s/\A.*?^\.SH\s+NAME\s*\n(.*?)^\.SH\s.*/$1/ms;
    s/(?:\s|\\)-.*//ms;
    $f=$ARGV;
    $f=~s/0intro/intro/ms;
    print "$_ $ARGV\n" for sort map {lc} $f, /([\w\/!~.-]+)/msg;
    ' * | uniq

I think it should be implemented in sh or limbo, because current scripts which 
should do this (located in /man/lib/) require Plan9 (rc, sed, etc.). Anyway, 
right now we can just use attached patch to fix INDEX files.

P.S. I think it make sense to update titles of some man pages in section 2 with 
names of adt provided by these modules, to avoid errors like this:
; man Timer
man: no manual page

Original issue reported on code.google.com by powerman...@gmail.com on 2 Dec 2012 at 4:49

Attachments:

GoogleCodeExporter commented 9 years ago
#!/dis/sh
# /man/*/INDEX generator by Pete Elmore
load std regex
for f in * {
    if {~ $f INDEX} {raise continue}
    ws := ${re sg '0intro' 'intro' $f}

    h := ()
    getlines {
        (s n rest) := ${split ' ' $line}
        if {~ $s .SH}   {h = $n; raise continue}
        if {no $h}  {raise continue}
        if {~ $h NAME}  {ws = $ws $line}    {raise break}
    } < $f

    ws = `{echo ${re sg '( |\\)-.*' '' $"ws} | tr A-Z a-z | tr -dc 'a-z0-9_/!~. -'}
    for w in $ws {echo $w $f} | sort
} | uniq > INDEX

Original comment by powerman...@gmail.com on 6 Dec 2012 at 12:01