Debian Codegraph @

inc/my_pod2html

raw
1 #!/usr/bin/perl
2
3 # my_pod2html -- convert POD to HTML, with some mangling
4
5 # Copyright 2009, 2010, 2011, 2013 Kevin Ryde
6
7 # my_pod2html is shared by several distributions.
8 #
9 # my_pod2html is free software; you can redistribute it and/or modify it
10 # under the terms of the GNU General Public License as published by the Free
11 # Software Foundation; either version 3, or (at your option) any later
12 # version.
13 #
14 # my_pod2html is distributed in the hope that it will be useful, but WITHOUT
15 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
17 # more details.
18 #
19 # You should have received a copy of the GNU General Public License along
20 # with this file. If not, see <http://www.gnu.org/licenses/>.
21
22 use strict;
23 use warnings;
24
25 #use Smart::Comments;
26
27
28 my $pod2html = MyPod2HTML->new;
29
30 # <h1> and <h2> both too big, in mozilla at least
31 $pod2html->html_h_level(3);
32
33 $pod2html->parse_from_file(@ARGV);
34 exit 0;
35
36
37
38 package MyPod2HTML;
39 use base 'Pod::Simple::HTML';
40
41 our $VERSION = 1;
42
43 use constant DEBUG => 0;
44
45 my %table =
46 ('apt-file' => 'http://packages.debian.org/apt-file',
47 'apt-cache' => 'http://packages.debian.org/apt',
48 'apt-rdepends' => 'http://packages.debian.org/apt-rdepends',
49 'gtk-options' => 'http://manpages.ubuntu.com/manpages/jaunty/man7/gtk-options.7.html',
50 'xsetroot' => 'http://www.x.org/archive/X1'.'1R7.5/doc/man/man1/xsetroot.1.html',
51 'leafnode' => 'http://leafnode.sourceforge.net',
52 'lynx' => 'http://lynx.isc.org/',
53 'feed2imap' => 'http://home.gna.org/feed2imap',
54 # disguise from grep
55 'rss'.'2email' => 'http://rss'.'2email.infogami.com',
56 'rssdrop' => 'http://search.cpan.org/dist/rssdrop/',
57 'toursst' => 'http://packages.debian.org/etch/toursst',
58 'netrc' => 'http://linux.die.net/man/5/netrc',
59
60 # no online man pages apparently at http://man-db.nongnu.org/
61 'man' => 'http://ftp.parisc-linux.org/cgi-bin/man/man2html?man+1',
62 'lexgrog' => 'http://ftp.parisc-linux.org/cgi-bin/man/man2html?lexgrog+1',
63 'apropos' => 'http://ftp.parisc-linux.org/cgi-bin/man/man2html?apropos+1',
64 );
65
66 sub resolve_man_page_link {
67 my ($self, $to, $frag) = @_;
68 $to = "$to"; # Pod::Simple::LinkSection object
69 ### $to
70 if (my ($page, $section) = ($to =~ /(.*)\(\d+\)$/)) {
71 ### $page
72 if (my $url = $table{$page}) {
73 return $url;
74 }
75 }
76 return shift->SUPER::resolve_man_page_link (@_);
77 }
78
79 sub resolve_pod_link_by_table {
80 my ($self, $to, $section) = @_;
81
82 my $url;
83 if (defined $to) {
84 if ($to eq 'AptPkg') {
85 $url = 'http://packages.debian.org/libapt-pkg-perl';
86 }
87 if ($to =~ /^Glib::Ex::(SourceIds|SignalIds|FreezeNotify|TieProperties)/) {
88 $url = "http://user42.tuxfamily.org/glib-ex-ob"."jectbits/$1.html";
89 }
90 if ($to eq 'Gtk2::Ex::Widget'.'Cursor') {
91 $url = 'http://user42.tuxfamily.org/gtk2-ex-widget'.'cursor/Widget'.'Cursor.html';
92 }
93 if ($to eq 'Ti'.'e:'.':TZ') {
94 $url = 'http://user42.tuxfamily.org/ti'.'e-'.'tz/TZ.html';
95 }
96 if ($to eq 'Time:'.':TZ') {
97 $url = 'http://user42.tuxfamily.org/ti'.'e-'.'tz/Time-'.'TZ.html';
98 }
99
100 if ($to =~ /^(Glib|Gtk2)($|::(?!Ex::))/) {
101 $to =~ s{::}{/};
102 $url = "http://gtk2-perl.sourceforge.net/doc/pod/$to.html"
103 }
104
105 if (defined $url) {
106 return ($url . (defined $section && $section ne '' ? "#$section" : ''));
107 }
108 }
109 return $self->SUPER::resolve_pod_link_by_table($to, $section);
110 }
111
112
113 # sub do_pod_link {
114 # my($self, $link) = @_;
115 # if (DEBUG) {
116 # print "\nlink tag=",$link->tagname," type=",$link->attr('type'),"\n";
117 # print " to=",$link->attr('to')||'[none]',"\n";
118 # print " section=",$link->attr('section')||'[none]',"\n";
119 # }
120 #
121 # my $to = $link->attr('to') || ''; # undef if internal link
122 #
123 # return $self->SUPER::do_pod_link($link);
124 # }