Tools: Auto-generate the Doc and FAQ

Francois Gouget fgouget at free.fr
Tue Sep 9 13:36:26 CDT 2003


I merged make_winehq_template with make_winehq and tweaked wine_release
so that it invokes make_winehq from the tools repository. I could not
test wine_release itself because I don't have expect installed but
make_winehq seems to be doing the right thing.

I also modified make_winehq to parse URLs and remove the /html
extension. Also, with the patch I sent for using cascading stylesheets
in the docs, we don't need to use winehq.dsl anymore. On WineHQ, the CSS
file will be included by the PHP-generated code so the docs will
automatically inherit the WineHQ look and feel.

Once this is committed and known to work, we can remove
documentation/winehq.dsl and documentation/make_winehq from the Wine
CVS.

Let me know if anything needs changing.


Changelog:

 * wine_release,
   make_winehq

   Move make_winehq to the tools repository
   Process the DocBook HTML files to generate .template files suitable
for use on WineHQ.

-- 
Francois Gouget         fgouget at free.fr        http://fgouget.free.fr/
                              145 = 1! + 4! + 5!
-------------- next part --------------
Index: wine_release
===================================================================
RCS file: /home/wine/tools/wine_release,v
retrieving revision 1.1
diff -u -r1.1 wine_release
--- wine_release	8 Sep 2003 16:28:47 -0000	1.1
+++ wine_release	9 Sep 2003 17:33:21 -0000
@@ -88,7 +88,8 @@
 do make wine.man
 do nroff -man wine.man | ../../bin/man2html > ../../wine-man.html
 do nroff -man wine.conf.man | ../../bin/man2html > ../../wine-conf-man.html 
-do sh make_winehq
+do chmod u+x ../../make_winehq
+do ../../make_winehq
 cd www.winehq.com
 do mv winedoc-html.tgz /home/winehq/www/Docs/
 do mv winedoc-pdf.tgz /home/winehq/www/Docs/
--- /dev/null	2003-09-08 21:59:07.000000000 +0200
+++ make_winehq	2003-09-09 19:50:47.000000000 +0200
@@ -0,0 +1,187 @@
+#!/usr/bin/perl -w
+# John R. Sheets <jsheets at codeweavers.com>
+# Francois Gouget <fgouget at codeweavers.com>
+use strict;
+use File::Copy;
+use File::Path;
+
+my $name0=$0;
+$name0=~ s+^.*/++;
+
+# This is a convenience script for building the website docs for
+# www.winehq.com. WineHQ is a template based website so that the
+# generated files must have a slightly special format:
+#  * everything outside the <body> tag must be stripped
+#  * the title is specified using a special tag on the first line
+#  * the filenames don't end in '.html'
+#
+# This script was written to take care of these differences and
+# to make it easier to set up an automated website update system.
+#
+# This is a standalone script swhich means there is no need to
+# invoke the Wine make system just for web updates. For example,
+# one can just grab the documentation subdirectory, without
+# having to pull the entire Wine tree:
+#
+# $ cvs co wine/documentation
+# $ cd wine/documentation
+# $ ./make_winehq
+# $ rsync ...
+
+# Put the generated files in this directory for easier maintenance
+my $winehq_dir="www.winehq.com";
+
+# The book list
+my @books=qw(wine-user wine-devel winelib-user wine-faq);
+
+sub psystem(@)
+{
+    print "@_\n";
+    return system(@_);
+}
+
+sub skip_to_gt($)
+{
+    my $line=$_[0];
+    while (defined $line)
+    {
+        return $line if ($line =~ s/^[^>]*>//i);
+        $line=<FILEI>;
+    }
+    return undef;
+}
+
+sub grab_cdata($)
+{
+    my $line=$_[0];
+    my $cdata;
+    while (defined $line)
+    {
+        if ($line =~ s/^([^<]*)<.*$/$1/i)
+        {
+            chomp $line;
+            $cdata=(defined $cdata?"$cdata $line":$line);
+            return ($cdata,$line);
+        }
+        chomp $line;
+        $cdata=(defined $cdata?"$cdata $line":$line);
+        $line=<FILEI>;
+    }
+    return ($cdata,$line);
+}
+
+sub convert_to_template($$)
+{
+    my $file_in=$_[0];
+    my $file_out=$_[1];
+
+    if (!open(FILEI,"$file_in"))
+    {
+        print STDERR "error: unable to open $file_in for reading:\n";
+        print STDERR "       $!\n";
+        return;
+    }
+    if (!open(FILEO,">$file_out"))
+    {
+        print STDERR "error: unable to open $file_out for writing:\n";
+        print STDERR "       $!\n";
+        return;
+    }
+
+    my $line;
+    while ($line=<FILEI>)
+    {
+        if ($line =~ s/^.*<title\s*//i)
+        {
+            $line=skip_to_gt($line);
+            my ($title,$line)=grab_cdata($line);
+            print FILEO "<!--TITLE:[$title]-->\n";
+        }
+        elsif ($line =~ s/^.*<body//i)
+        {
+            $line=skip_to_gt($line);
+            last;
+        }
+    }
+
+    my $exit;
+    do
+    {
+        $exit=($line =~ s/<\/body.*$//i);
+        $line=~s/(href=\"[^.\/]*).html([^\"]*\")/$1$2/gi;
+        print FILEO $line;
+    }
+    while (!$exit and $line=<FILEI>);
+
+    close FILEI;
+    close FILEO;
+}
+
+
+###
+#
+# Main
+#
+###
+
+if (-e $winehq_dir)
+{
+    if (-e $winehq_dir)
+    {
+        if (-e "$winehq_dir.old" and !rmtree "$winehq_dir.old")
+        {
+            print STDERR "$name0:warning: unable to delete $winehq_dir.old: $!\n";
+            exit 1;
+        }
+    }
+    if (!rename("$winehq_dir","$winehq_dir.old"))
+    {
+        print STDERR "$name0:warning: unable to rename $winehq_dir to $winehq_dir.old: $!\n";
+        exit 1;
+    }
+}
+if (!mkdir $winehq_dir)
+{
+    print STDERR "$name0:warning: unable to create $winehq_dir: $!\n";
+    exit 1;
+}
+
+# Generate the user HTML, PS and PDF documentation
+print "Generating the user documentation:\n";
+foreach my $book (@books)
+{
+    print "* $book\n";
+    psystem("db2html -d default.dsl $book.sgml");
+    copy("winedoc.css","$book");
+    psystem("db2pdf  -d print.dsl $book.sgml >/dev/null 2>&1");
+    psystem("db2ps   -d print.dsl $book.sgml >/dev/null 2>&1");
+    print "\n";
+}
+
+# Create the tar files for download
+psystem("tar cfz $winehq_dir/winedoc-sgml.tgz *.sgml *.css *.dsl *.ent");
+psystem("tar","cfz","$winehq_dir/winedoc-html.tgz", at books);
+psystem("tar","cfz","$winehq_dir/winedoc-pdf.tgz", map { "$_.pdf" } @books);
+psystem("tar","cfz","$winehq_dir/winedoc-ps.tgz",  map { "$_.ps" } @books);
+
+# And Generate the WineHQ documentation
+print "\nGenerating the WineHQ documentation:\n";
+foreach my $book (@books)
+{
+    print "* $book\n";
+    if (!mkdir "$winehq_dir/$book")
+    {
+        print STDERR "$name0:warning: unable to create $winehq_dir/$book: $!\n";
+        exit 1;
+    }
+    foreach my $file (<$book/*.html>)
+    {
+        my $template=$file;
+        $template=~s%^.*/(.*)\.html%$1%i;
+        convert_to_template("$file","$winehq_dir/$book/$template.template")
+    }
+}
+psystem("tar","cfz","$winehq_dir/winehq-templates.tgz","-C","$winehq_dir", at books);
+
+
+exit 0;


More information about the wine-patches mailing list