I have crafted this script that somewhat converts the gl2.1 docbook files to 
mdoc.
The equations look horrible, but the rest is similar to the current gl* files.

I do not know the reason, but running mandoc -T lint glDrawPixels.3 gives me 
several
errors for the equations. I do not have much experience with mdoc pages.

$ ./build.sh OpenGL-Refpages/gl2.1/

The files go into a directory called compiled that is newly created.

Here is the script (needs docbook2mdoc):

#!/bin/ksh

function usage {
        echo "usage: build.sh xmldir"
        exit 1
}

[[ ! -d $1 ]] && usage

dir=$1
curdir=$(pwd)
outd=$curdir/compiled/
errf=$curdir/errlog

mkdir -p $outd

cd $dir

find . -maxdepth 1 -type f | while read inf
# DBG: echo "glBegin.xml" | while read inf
do
        echo "$inf" | grep "xml" || continue

        outf=$(echo "$inf" | sed "s/xml/3/")
        echo "$inf -> $outd/$outf"

        echo "$outf" >> $errf

        cat $inf | docbook2mdoc -s 3G 2>>$errf | \
        # Xr xxx 1 is the default, change it to 3G
        sed "s/^\.Xr \([A-Za-z]*\) 1\(.*\)/.Xr \1 3G\2/" | \
        # Dv -> Sy for better readability
        sed "s/\<Dv\>/Sy/" | \
        # SYNOPSIS -> SPECIFICATION
        sed "s/SYNOPSIS/C SPECIFICATION/" | \
        # Copyright section misses the An prefix
        sed "s/^Copyright/.An Copyright/" | \
        sed "s/^Silicon/.An Silicon/" | \
        # Remove names to put them in later (see below)
        sed "s/^\.Nm.*/.Nm /" | \
        # Remove parenthesis around single-char items in equations.
        sed "s/{ \(.\) }/\1/" | \
        # Replace all cross references with highlights up to SEE ALSO
        awk '
                BEGIN { end=0 }
                {
                if (end == 1) {
                        print
                } else {
                        if ($1 == ".Xr") {
                                print ".Sy", $2, $4, $5, $6, $7, $8, $9
                        } else {
                                print
                        }
                }

                if (($1 == ".Sh") && ($2 == "SEE")) {
                        end=1
                }
                }
                END {}
        ' > $outd/$outf


        # search for names (they are the ones with .Fo)
        names=$(cat $outd/$outf | grep "\.Fo " | sed "s/\.Fo //" | tr "\n" " ")
        # the names are interleaved with commas
        commas=$(echo $names | sed "s/ \([A-Za-z]\)/, \1/")

        # insert missing names
        sed -i "s/^\.Nm.*$/.Nm $commas/" $outd/$outf

        # Replace the Sy's for the page functions with Fn
        for fn in $names
        do
                sed -i "s/^\.Sy $fn\(.*\)$/.Fn $fn \1/" $outd/$outf
        done
done


On Sunday, July 7th, 2024 at 12:17 PM, Matthieu Herrb <matth...@herrb.eu> wrote:

> On Sun, Jul 07, 2024 at 07:51:28PM +1000, Jonathan Gray wrote:
> 
> > doc/gl-docs is outdated and should either be removed or replaced with
> > the newer docbook pages converted. I'm not sure how viable that is
> > with docbook2mdoc.
> > 
> > https://github.com/KhronosGroup/OpenGL-Refpages
> > https://mandoc.bsd.lv/docbook2mdoc/
> > 
> > https://registry.khronos.org/OpenGL-Refpages/gl2.1/
> > https://registry.khronos.org/OpenGL-Refpages/gl4/
> 
> 
> I'll probably start by removing the old gl-docs files. It was an
> attempt by me to keep it from XFree86 days. Afaict Xorg never had
> gl-docs in their modular tree.
> 
> If someone beats me at trying to convert newers available docs to
> mdoc, please do. I'll look at this when I've some available time.
> 
> > On Sun, Jul 07, 2024 at 09:17:56AM +0000, ZenitDS wrote:
> > 
> > > Index: drawpixels.3gl
> > > ===================================================================
> > > RCS file: /cvs/xenocara/doc/gl-docs/GL/gl/drawpixels.3gl,v
> > > retrieving revision 1.1.1.1
> > > diff -u -p -r1.1.1.1 drawpixels.3gl
> > > --- drawpixels.3gl 29 Nov 2006 17:00:40 -0000 1.1.1.1
> > > +++ drawpixels.3gl 7 Jul 2024 09:15:55 -0000
> > > @@ -33,7 +33,7 @@ Specify the dimensions of the pixel rect
> > > into the frame buffer.
> > > .TP
> > > \f2format\fP
> > > -Specifies the of the pixel data.
> > > +Specifies the format of the pixel data.
> > > Symbolic constants
> > > \%\f3GL_COLOR_INDEX\fP,
> > > \%\f3GL_STENCIL_INDEX\fP,
> 
> 
> --
> Matthieu Herrb

Reply via email to