2022-02-19 18:54:01 +00:00
|
|
|
#!/usr/bin/perl
|
|
|
|
|
2022-02-23 20:19:12 +00:00
|
|
|
# Copyright (C) 2007-2022 Ole Tange, http://ole.tange.dk and 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
|
|
|
|
# the Free Software Foundation; either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program 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 <https://www.gnu.org/licenses/>
|
|
|
|
# or write to the Free Software Foundation, Inc., 51 Franklin St,
|
|
|
|
# Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
#
|
|
|
|
# SPDX-FileCopyrightText: 2021-2022 Ole Tange, http://ole.tange.dk and Free Software and Foundation, Inc.
|
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2022-02-19 18:54:01 +00:00
|
|
|
# Convert .pod file containing:
|
|
|
|
#
|
|
|
|
# =item --option
|
|
|
|
#
|
|
|
|
# See also: --other-option
|
|
|
|
#
|
|
|
|
# to a graph.pdf with link between --option and --other-option
|
|
|
|
|
|
|
|
$pod=join("",<>);
|
|
|
|
$pod=~s/^.*=head1 OPTIONS//s;
|
|
|
|
$pod=~s/=head1 EXAMPLES.*//s;
|
|
|
|
$pod=~s/^.*?=over//s;
|
|
|
|
$pod=~s/=back\s*$//s;
|
|
|
|
$pod=~s/=over.*?=back//sg;
|
|
|
|
|
|
|
|
$in_text = 0;
|
|
|
|
$in_item = 0;
|
|
|
|
$in_see_also = 0;
|
|
|
|
|
|
|
|
|
|
|
|
for(split(/\n\n+/,$pod)) {
|
|
|
|
if(/^See also:\s+(\S.*)/s) {
|
|
|
|
$lex = "seealso";
|
|
|
|
$in_text = 0;
|
|
|
|
$in_item = 0;
|
|
|
|
$in_see_only = 1;
|
|
|
|
} elsif(/^=item\s+(B<[{]=.*?perl expression.*?=[}]>|[IB]<.*?>)(\s|$)/s) {
|
|
|
|
$lex = "item";
|
|
|
|
$in_text = 0;
|
|
|
|
$in_item = 1;
|
|
|
|
$in_see_only = 0;
|
|
|
|
} elsif(/\S/) {
|
|
|
|
$lex = "text";
|
|
|
|
$in_text = 1;
|
|
|
|
$in_item = 0;
|
|
|
|
$in_see_only = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if($lex eq "seealso") {
|
|
|
|
if($lastlex eq "item") {
|
|
|
|
@saveditems = @items;
|
|
|
|
@items = ();
|
|
|
|
}
|
|
|
|
my $to = $1;
|
|
|
|
my $from = (join "/",
|
|
|
|
map {
|
|
|
|
s/I<(.*?)>/$1/g;
|
|
|
|
s/B<(.*?)>/$1/g;
|
|
|
|
$_ }
|
|
|
|
@saveditems[0]);
|
|
|
|
my @to;
|
|
|
|
while($to =~ s/(B<[{]=.*?perl expression.*?=[}]>|[BI]<.*?>)(\s|$)//) {
|
|
|
|
my $v = $1;
|
|
|
|
push @to, map {
|
|
|
|
s/I<(.*?)>/$1/g;
|
|
|
|
s/B<(.*?)>/$1/g;
|
|
|
|
$_;
|
|
|
|
} $v;
|
|
|
|
}
|
|
|
|
map {
|
|
|
|
if(not $seen{$from,$_}++
|
|
|
|
and
|
|
|
|
not $seen{$_,$from}++) {
|
|
|
|
push @nodelines, "\"$from\" -- \"$_\"\n"
|
|
|
|
}
|
|
|
|
} @to;
|
|
|
|
|
|
|
|
} elsif($lex eq "text") {
|
|
|
|
if($lastlex eq "item") {
|
|
|
|
@saveditems = @items;
|
|
|
|
@items = ();
|
|
|
|
}
|
|
|
|
} elsif($lex eq "item") {
|
|
|
|
push(@items,$1);
|
|
|
|
}
|
|
|
|
$lastlex=$lex;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sub header() {
|
|
|
|
return q[
|
|
|
|
graph test123 {
|
2022-02-22 21:55:41 +00:00
|
|
|
graph [splines=true; overlap=false;];
|
2022-02-19 18:54:01 +00:00
|
|
|
labelloc="t";
|
2022-02-22 21:55:41 +00:00
|
|
|
label="Related map for options for GNU Parallel\nFind the options you use and learn about the options related to it";fontsize=33;
|
2022-02-19 18:54:01 +00:00
|
|
|
|
|
|
|
"{}"[margin=0.3;]
|
2022-02-22 21:55:41 +00:00
|
|
|
"--sshlogin"[margin=0.3;]
|
2022-02-19 18:54:01 +00:00
|
|
|
"--pipe"[margin=0.3;]
|
|
|
|
":::"[margin=0.3;]
|
2022-02-22 21:55:41 +00:00
|
|
|
"-X"[margin=0.3;]
|
2022-02-19 18:54:01 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2022-02-22 21:55:41 +00:00
|
|
|
open(GRAPHVIZ,"|-","tee foo.dot |neato -Gepsilon=.000000001 -Tpdf") || die;
|
2022-02-19 18:54:01 +00:00
|
|
|
print GRAPHVIZ header(), (sort { rand()*3 -1 } @nodelines), "}";
|
|
|
|
close GRAPHVIZ;
|
|
|
|
|