man: improve typesetting and prepare for html output
* src/bin/man/autfilt.x, src/bin/man/dstar2tgba.x, src/bin/man/ltl2tgba.x, src/bin/man/ltlcross.x, src/bin/man/ltlgrind.x, src/bin/man/randltl.x, src/bin/man/spot-x.x: Improve typesetting and cross-references. * tools/help2man: Adjust to better detect the optional arguments. Detect options that are not separated from their description by two spaces. Argp output some of those. * tools/man2html.pl: New file. * Makefile.am: Distribute it. * src/bin/ltlfilt.cc: Fix description of --define. * src/bin/ltlgrind.cc: Fix duplicate description for --help and --version. Reorder --help output slightly. * NEWS: Mention the few fixes.
This commit is contained in:
parent
5b75ad5abd
commit
f7b65001e9
13 changed files with 290 additions and 159 deletions
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
# Generate a short man page from --help and --version output.
|
||||
# Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2009,
|
||||
# 2010, 2011, 2012 Free Software Foundation, Inc.
|
||||
# 2010, 2011, 2012, 2015 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -485,7 +485,14 @@ while (length)
|
|||
my $content = '';
|
||||
|
||||
# Option with description.
|
||||
if (s/^( {1,10}([+-]\S.*?))(?:( +(?!-))|\n( {20,}))(\S.*)\n//)
|
||||
my $descrpat2 = '(?:( +(?!-))|\n( {20,}))(\S.*)\n';
|
||||
my $descrpat1 = '(?:( (?!-))|\n( {20,}))(\S.*)\n';
|
||||
if (s/^( {1,10}([+-]\S.*?))$descrpat2//o ||
|
||||
# Cases where "-x, --option" or "--option" is separated from
|
||||
# "description" by a single space, because "description" then
|
||||
# starts on column 29. This is output by argp.
|
||||
s/^( {2}([+-]\S.{24}))$descrpat1//o ||
|
||||
s/^( {6}([+-]\S.{20}))$descrpat1//o)
|
||||
{
|
||||
$matched .= $& if %append;
|
||||
$indent = length ($4 || "$1$3");
|
||||
|
|
@ -548,7 +555,8 @@ while (length)
|
|||
s/\x84//g;
|
||||
|
||||
# Convert options.
|
||||
s/(^| |\()(-[][\w=-]+)/$1 . convert_option $2/mge;
|
||||
s/(^| )(-[][\w-]+(?:=[][\w=\/|()'"-]*)?)/$1 . convert_option $2/mge;
|
||||
s/\((-[][\w-]+(?:=[][\w=\/|()'"-]*)?)\)/"(" . convert_option $1 . ")"/mge;
|
||||
|
||||
# Escape remaining hyphens
|
||||
s/-/\x83/g;
|
||||
|
|
@ -682,10 +690,15 @@ sub convert_option
|
|||
local $_ = '\fB' . shift;
|
||||
|
||||
s/-/\x83/g;
|
||||
unless (s/\[=(.*)\]$/\\fR[=\\fI$1\\fR]/)
|
||||
if (s/\[=(.*)\]$/\\fR[=\\fI$1\\fR]/)
|
||||
{
|
||||
s/\|/\\fR|\\fI/g;
|
||||
}
|
||||
else
|
||||
{
|
||||
s/=(.)/\\fR=\\fI$1/;
|
||||
s/ (.)/ \\fI$1/;
|
||||
s/[\[\|\]]/\\fR$&\\fI/g;
|
||||
$_ .= '\fR';
|
||||
}
|
||||
|
||||
|
|
|
|||
64
tools/man2html.pl
Executable file
64
tools/man2html.pl
Executable file
|
|
@ -0,0 +1,64 @@
|
|||
#!/usr/bin/perl
|
||||
## -*- coding: utf-8 -*-
|
||||
## Copyright (C) 2015 Laboratoire de Recherche et Développement de
|
||||
## l'Epita (LRDE).
|
||||
## Copyright (C) 2003, 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
|
||||
## département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
||||
## et Marie Curie.
|
||||
##
|
||||
## This file is part of Spot, a model checking library.
|
||||
##
|
||||
## Spot is free software; you can redistribute it and/or modify it
|
||||
## under the terms of the GNU General Public License as published by
|
||||
## the Free Software Foundation; either version 3 of the License, or
|
||||
## (at your option) any later version.
|
||||
##
|
||||
## Spot is distributed in the hope that it will be useful, but WITHOUT
|
||||
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
## License for more details.
|
||||
##
|
||||
## You should have received a copy of the GNU General Public License
|
||||
## along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use strict;
|
||||
|
||||
sub error($)
|
||||
{
|
||||
print "$0: ", @_;
|
||||
exit 1;
|
||||
}
|
||||
|
||||
error "Specify a directory with man pages\n" if @ARGV != 1;
|
||||
|
||||
my $dir = @ARGV[0];
|
||||
|
||||
opendir(DIR, $dir) or die $!;
|
||||
while (my $file = readdir(DIR))
|
||||
{
|
||||
next unless $file =~ m/\.\d$/;
|
||||
$file = "$dir/$file";
|
||||
print "converting $file to $file.html with groff\n";
|
||||
my $html = `(echo '.HEAD <LINK REL="stylesheet" TYPE="text/css" HREF="https://spot.lrde.epita.fr/spot.css">'
|
||||
echo '.HEAD <meta name="viewport" content="width=device-width, initial-scale=1">'
|
||||
cat $file) | groff -Kutf8 -mandoc -Thtml - -P -r`;
|
||||
$html =~ s|GNU GPL version 3 or later.*http://gnu.org/licenses/gpl.html>|<a href="http://gnu.org/licenses/gpl.html">GNU GPL version 3 or later</a>|s;
|
||||
$html =~ s|<h2>.*?</h2>|<div class="outline-2">$&</div>|smg;
|
||||
$html =~ s|(<a href="#.*?">.*?</a><br>\n)+|<div id="table-of-contents"><h2>Table of Contents</h2><div id="text-table-of-contents"><ul>\n$&</ul></div></div>|sm;
|
||||
$html =~ s|(<a href="#.*?">.*?</a>)<br>|<li>$1</li>|g;
|
||||
$html =~ s|<p(.*?)>•</p></td>.<td width="10%"></td>.<td width="78%">|<p$1>•</p></td>\n<td width="88%">|smg;
|
||||
$html =~ s|<spot\@lrde.epita.fr>|<<a href="mailto:spot\@lrde.epita.fr">spot\@lrde.epita.fr</a>>|;
|
||||
$html =~ s|<(https?://.*)>|<<a href="$1">$1</a>>|;
|
||||
$html =~ s|<p style="margin-left:11%; margin-top: 1em"><b>([^<>]*?:)\s*<br>|<h3 style="margin-left:11%">$1</h3><p style="margin-left:11%"><b>|smg;
|
||||
$html =~ s|<p style="margin-left:11%; margin-top: 1em"><b>([^<>]*?:)\s*</b>\s*<br>|<h3 style="margin-left:11%">$1</h3><p style="margin-left:11%">|smg;
|
||||
$html =~ s|<p style="margin-left:11%; margin-top: 1em"><b>([^<>]*?:)\s*</b></p>|<h3 style="margin-left:11%">$1</h3>|smg;
|
||||
$html =~ s@<body>@<body class="man"><div id="org-div-home-and-up"><a accesskey="h" href="https://spot.lrde.epita.fr/tools.html"> UP </a>| <a accesskey="H" href="https://spot.lrde.epita.fr/index.html"> HOME </a></div>@;
|
||||
$html =~ s{<b>([\w-]+)</b>\((\d+)\)}{
|
||||
(-f "$1.$2") ? "<a href=\"$1.$2.html\"><b>$1</b></a>($2)" : $&;
|
||||
}xge;
|
||||
open(FILE, ">$file.html");
|
||||
print FILE $html;
|
||||
close(FILE);
|
||||
}
|
||||
closedir(DIR);
|
||||
exit 0;
|
||||
Loading…
Add table
Add a link
Reference in a new issue