1008: Moved the definition of the big_files_offset to the form.c.
[elinks.git] / doc / tools / help2doc
blob864f6622204c8298d6f6c9c3859ab1cf2daf67a5
1 #! /usr/bin/perl
2 use strict;
3 use warnings;
5 my ($elinks, $option) = @ARGV;
7 if ($option =~ /command/) {
8 open my $pipe, "-|", $elinks, "--long-help" or die;
9 my $version = <$pipe>;
10 chomp $version;
11 $version =~ s/^ELinks ([-.\w]+).*$/$1/ or die "unusual version: $version";
12 my $blank = 1;
13 while (<$pipe>) {
14 if (/^ {4}(-.*?) *$/) {
15 # ' -anonymous [0|1] (default: 0)'
16 # ' -config-dir <str> (default: "")'
17 $_ = $1;
18 s/ {2,}/ /g;
19 print "${_}::\n";
20 } elsif (/^ {12}\t(-eval .*)$/) {
21 print "\n\t$1\n";
22 } elsif (/^ {12}\t(\w+\(.*\)) +: (.*)$/) {
23 # ' openURL(URL, new-tab) : open URL in new tab'
24 print "\t- `$1`: $2\n";
25 } elsif (/^ {12}\t(\d+) (means .+)$/) {
26 # ' 0 means only show serious errors'
27 print "\t- $1:\t$2\n";
28 } elsif (s/^ {12}//) {
29 s/'([^']+)'/\\'$1\\'/g;
30 s((~/\.elinks|-dump|-default-mime-type|text/html|-touch-files|-no-connect|-session-ring))(`$1`)g;
31 s/(ELinks|HOME)/'$1'/g;
32 print "\t$_";
33 } else {
34 print "\n" unless $blank;
35 $blank = 2;
37 $blank = ($blank == 2);
39 print "Generated using output from ELinks version $version.\n";
40 } elsif ($option =~ /config/) {
41 open my $pipe, "-|", $elinks, "--config-help" or die;
42 my $version = <$pipe>;
43 chomp $version;
44 $version =~ s/^ELinks ([-.\w]+).*$/$1/ or die "unusual version: $version";
45 my $blank = 1;
46 my $continued = 0;
47 while (<$pipe>) {
48 if (/^ {2}[^ ].*: \(([-.\w]+)\)$/) {
49 # ' Active link: (document.browse.links.active_link)'
50 print "$1::\n";
51 } elsif (/^ {4}([^ ].*?)$/) {
52 # ' bookmarks.file_format <num> (default: 0)'
53 print "$1::\n";
54 } elsif (/^ {12,}$/) {
55 print "+\n";
56 $continued = 1;
57 } elsif (s/^ {12,}//) {
58 # escape things that might look like AsciiDoc markup
59 s/'(.*?)'/\\'$1\\'/g;
60 s/\{(.*?)\}/\\{$1\\}/g;
61 # add the actual AsciiDoc markup
62 s/(ELinks|WWW_HOME)/'$1'/g;
63 s((~/\.elinks))(`$1`)g;
64 if (/^(-?\d[-+\d]*?) +(.*)$/) {
65 # ' 1+ is use cookie's expiration date, but limit age to the given'
66 print "\t- $1:\t$2\n";
67 } elsif ($continued) {
68 print "$_";
69 } else {
70 print "\t$_";
72 } else {
73 print "\n" unless $blank;
74 $blank = 2;
75 $continued = 0;
77 $blank = ($blank == 2);
79 print "Generated using output from ELinks version $version.\n";
80 } else {
81 die "usage: $0 ELINKS-EXECUTABLE option-command.txt\n"
82 . " or: $0 ELINKS-EXECUTABLE option-config.txt\n";