~ubuntu-branches/ubuntu/saucy/dhelp/saucy-proposed

« back to all changes in this revision

Viewing changes to tmp/dhelp-ruby/debian/dhelp/usr/share/doc/dhelp/sgml2dhelp.pl

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson
  • Date: 2008-06-19 01:25:07 UTC
  • Revision ID: james.westby@ubuntu.com-20080619012507-adt75omul1shucde
Tags: 0.6.9ubuntu1
* Resynchronise with Debian. Remaining changes:
  - Recommends: firefox-3.0.
  - Exit zero if the bdb module is not available; this usually indicates
    that dhelp is not configured yet.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/perl -w
2
 
 
3
 
# Copyright (c) 1998 by Marco Budde (Budde@tu-harburg.de)
4
 
# GNU General Public License
5
 
 
6
 
##############################################################
7
 
#   sgmltools -> dhelp, dwww, index.html                     #
8
 
#                                                            # 
9
 
#       usage:  sgml2dhelp <dhelp section> <dwww section>    #
10
 
##############################################################
11
 
 
12
 
# you
13
 
$maintainer = 'Marco Budde (Budde@tu-harburg.de)';
14
 
 
15
 
# regexp to find the root html file of a document
16
 
$file_expr = '^(.+)[^0-9]\.html$';
17
 
 
18
 
# regexp to produce a link name from the file name
19
 
$title_expr = '^(.+)\.html$';
20
 
 
21
 
 
22
 
##############################
23
 
#  get abstract of document  #
24
 
##############################
25
 
 
26
 
sub get_abstract
27
 
{
28
 
  my $zw;
29
 
 
30
 
  open (IN, "< $filename") or die "can't open $filename!\n";
31
 
  $abstract = '';
32
 
  while ($zw = <IN>)
33
 
  {
34
 
    if ($zw =~ /<P><HR><EM>(.*)/)
35
 
    {
36
 
      $abstract = $1;
37
 
      while ($zw !~ /<\/EM><HR><\/P>/)
38
 
      {
39
 
        $zw = <IN>;
40
 
        $abstract .= ' ' . $zw;
41
 
      } 
42
 
    }
43
 
  }
44
 
  $abstract =~ s/<\/EM><HR><\/P>//;
45
 
  close (IN);
46
 
}
47
 
 
48
 
 
49
 
##################
50
 
#  write .dhelp  #
51
 
##################
52
 
 
53
 
sub write_dhelp
54
 
{
55
 
  print DHELP "<item>\n";
56
 
  print DHELP "<directory>$ARGV[0]\n";
57
 
  print DHELP "<linkname>$linkname\n";
58
 
  print DHELP "<filename>$filename\n";
59
 
  print DHELP "<description>\n$abstract\n</description>\n";
60
 
  print DHELP "</item>\n\n";  
61
 
}
62
 
 
63
 
 
64
 
#########################
65
 
#  .dwww-index support  #
66
 
#########################
67
 
 
68
 
sub dwww_pwd
69
 
{
70
 
  $pwd = `pwd`;
71
 
  $pwd =~ /.*?\/usr\/doc\/*(.*)/;
72
 
  $pwd = $1;
73
 
}
74
 
 
75
 
sub write_dwww
76
 
{
77
 
  print DWWW "#section $ARGV[1]\n";
78
 
  print DWWW "<dt><a href=\"$pwd/$filename\">$linkname</a>\n";
79
 
  print DWWW "<dd>$abstract\n\n";
80
 
}
81
 
 
82
 
########################
83
 
#  index.html support  #
84
 
########################
85
 
 
86
 
sub write_index
87
 
{
88
 
  print INDEX "<DT><A HREF=\"$filename\">$linkname</A>\n";
89
 
  print INDEX "<DD>$abstract\n\n";
90
 
}
91
 
 
92
 
 
93
 
################
94
 
#     main     #
95
 
################
96
 
 
97
 
opendir (DIRHANDLE, '.');
98
 
@dircontent = readdir (DIRHANDLE);
99
 
closedir (DIRHANDLE);
100
 
 
101
 
open (DHELP, "> .dhelp");
102
 
open (INDEX, "> index.html");
103
 
print INDEX "<HTML>\n<BODY>\n<DL>\n";
104
 
open (DWWW, "> .dwww-index");
105
 
&dwww_pwd;
106
 
 
107
 
foreach $filename (sort @dircontent)
108
 
{
109
 
  if ($filename =~ /$file_expr/)
110
 
  {
111
 
    $filename =~ /$title_expr/;
112
 
    $linkname = $1;
113
 
    print "$filename\n";
114
 
    &get_abstract;
115
 
    &write_dhelp;
116
 
    &write_index;
117
 
    &write_dwww;
118
 
  }
119
 
}
120
 
 
121
 
close (DHELP);
122
 
print INDEX "</DL>\n<HR>\n<ADDRESS><SMALL>\n";
123
 
print INDEX "Please send comments to $maintainer.\n";
124
 
$time = gmtime (time);
125
 
print INDEX "<BR>This page was created $time GMT.</SMALL></ADDRESS>\n";
126
 
print INDEX "</BODY>\n</HTML>\n";
127
 
close (INDEX);
128
 
close (DWWW);
129