#!/usr/bin/perl -w # Copyright © 2002-2014 Jamie Zawinski # # Permission to use, copy, modify, distribute, and sell this software and its # documentation for any purpose is hereby granted without fee, provided that # the above copyright notice appear in all copies and that both that # copyright notice and this permission notice appear in supporting # documentation. No representations are made about the suitability of this # software for any purpose. It is provided "as is" without express or # implied warranty. # # Created: 30-May-2002. # # This creates man pages from the XML program descriptions in # xscreensaver/hacks/config/. # # They aren't necessarily the most accurate or well-written man pages, # but at least they exist. require 5; use diagnostics; use strict; use Text::Wrap; my $progname = $0; $progname =~ s@.*/@@g; my ($version) = ('$Revision: 1.7 $' =~ m/\s(\d[.\d]+)\s/s); my $verbose = 0; my $default_args = ("[\\-display \\fIhost:display.screen\\fP]\n" . "[\\-visual \\fIvisual\\fP]\n" . "[\\-window]\n" . "[\\-root]\n"); my $default_options = (".TP 8\n" . ".B \\-visual \\fIvisual\\fP\n" . "Specify which visual to use. Legal values " . "are the name of a visual class,\n" . "or the id number (decimal or hex) of a " . "specific visual.\n" . ".TP 8\n" . ".B \\-window\n" . "Draw on a newly-created window. " . "This is the default.\n" . ".TP 8\n" . ".B \\-root\n" . "Draw on the root window.\n"); my $man_suffix = (".SH ENVIRONMENT\n" . ".PP\n" . ".TP 8\n" . ".B DISPLAY\n" . "to get the default host and display number.\n" . ".TP 8\n" . ".B XENVIRONMENT\n" . "to get the name of a resource file that overrides " . "the global resources\n" . "stored in the RESOURCE_MANAGER property.\n" . ".SH SEE ALSO\n" . ".BR X (1),\n" . ".BR xscreensaver (1)\n" . ".SH COPYRIGHT\n" . "Copyright \\(co %YEAR% by %AUTHOR%. " . "Permission to use, copy, modify, \n" . "distribute, and sell this software and its " . "documentation for any purpose is \n" . "hereby granted without fee, provided that " . "the above copyright notice appear \n" . "in all copies and that both that copyright " . "notice and this permission notice\n" . "appear in supporting documentation. No " . "representations are made about the \n" . "suitability of this software for any purpose. " . "It is provided \"as is\" without\n" . "express or implied warranty.\n" . ".SH AUTHOR\n" . "%AUTHOR%.\n"); sub xml2man($) { my ($exe) = @_; $exe =~ s/\.xml$//s; my $cfgdir = (-d "config" ? "config" : "../config"); my $xml = "$cfgdir/$exe.xml"; my $man = "$exe.man"; error ("$exe does not exist") if (! -f $exe); error ("$xml does not exist") if (! -f $xml); error ("$man already exists") if (-f $man); local *IN; open (IN, "<$xml") || error ("$xml: $!"); my $xmltxt = ""; while () { $xmltxt .= $_; } close IN; my $args = ""; my $body = ""; my $desc; $xmltxt =~ s/\s+/ /gs; $xmltxt =~ s///g; $xmltxt =~ s@(<[^/])@\n$1@gs; foreach (split ('\n', $xmltxt)) { next if m/^$/; next if m/^<\?xml\b/; next if m/^= 10000) { $label = "Per-frame delay, in microseconds."; $def = sprintf ("%d (%0.2f seconds)", $def, ($def/1000000.0)); $low = $hi = undef; } elsif ($carg eq '-speed \fInumber\fP') { $label = "Animation speed. 2.0 means twice as fast, " . "0.5 means half as fast."; $novalsp = 1; } elsif ($boolp) { $label .= ". Boolean."; } elsif ($label) { $label .= "."; } if (m/^<(number|boolean|option)/) { next if (!$arg && m/