Develop and Download Open Source Software

Browse Subversion Repository

Annotation of /branches/4-stable/doc/htmlhelp_index_make.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6064 - (hide annotations) (download) (as text)
Mon Oct 26 23:29:25 2015 UTC (8 years, 5 months ago) by maya
Original Path: trunk/doc/htmlhelp_index_make.pl
File MIME type: text/x-perl
File size: 2139 byte(s)
Copyright 表記を調整
1 yutakapon 4405 #! /usr/bin/perl
2    
3     #
4     # HTMLヘルプのインデックスファイルを生成する
5     #
6     # Usage(ActivePerl):
7 yutakapon 4431 # perl htmlhelp_index_make.pl ja html > ja\Index.hhk
8 yutakapon 4405 #
9    
10     use Cwd;
11     @dirstack = ();
12    
13     do_main($ARGV[0], $ARGV[1]);
14    
15     exit(0);
16    
17     sub do_main {
18     my($path, $body) = @_;
19    
20     print << 'EOD';
21     <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
22     <HTML><HEAD>
23 maya 6064 <meta name="GENERATOR" content="TeraTerm Project">
24 yutakapon 4405 <!-- Sitemap 1.0 -->
25     </HEAD><BODY>
26     <UL>
27     EOD
28    
29     push @dirstack, getcwd;
30     chdir $path;
31     get_file_paths($body);
32     chdir pop @dirstack;
33    
34     print << 'EOD';
35     </UL>
36     </BODY></HTML>
37     EOD
38    
39     }
40    
41    
42     sub get_file_paths {
43     my ($top_dir)= @_;
44     my @paths=();
45     my @temp = ();
46    
47     #-- カレントの一覧を取得 --#
48     opendir(DIR, $top_dir);
49     @temp = readdir(DIR);
50     closedir(DIR);
51     foreach my $path (sort @temp) {
52     next if( $path =~ /^\.{1,2}$/ ); # '.' と '..' はスキップ
53     next if( $path =~ /^\.svn$/ ); # '.svn' はスキップ
54    
55     my $full_path = "$top_dir" . '/' . "$path";
56     next if (-B $full_path); # バイナリファイルはスキップ
57    
58     # print "$full_path\r\n"; # 表示だけなら全てを表示してくれる-------
59     push(@paths, $full_path); # データとして取り込んでも前の取り込みが初期化される
60     if( -d "$top_dir/$path" ){ #-- ディレクトリの場合は自分自身を呼び出す
61     &get_file_paths("$full_path");
62    
63     } else {
64     check_html_file($full_path);
65    
66     }
67     }
68     return \@paths;
69     }
70    
71     sub check_html_file {
72     my($filename) = shift;
73     local(*FP);
74 yutakapon 4431 my($line, $no, $val);
75 yutakapon 4405
76     if ($filename !~ /.html$/) {
77     return;
78     }
79    
80     open(FP, "<$filename") || return;
81     $no = 1;
82     while ($line = <FP>) {
83     # $line = chomp($line);
84     # print "$line\n";
85     if ($line =~ /<TITLE>(.+)<\/TITLE>/i) {
86     # print "$filename:$no: $1\n";
87     # print "$line\n";
88 yutakapon 4431 $val = $1;
89     $val =~ s/"/&#34;/g; # 二重引用符をエスケープする
90     write_add_index($filename, $val);
91 yutakapon 4405 last;
92     }
93    
94     $no++;
95     }
96     close(FP);
97     }
98    
99     sub write_add_index {
100     my($filename, $title) = @_;
101    
102     print << "EOD";
103     <LI><OBJECT type="text/sitemap">
104     <param name="Name" value="$title">
105     <param name="Local" value="$filename">
106     </OBJECT>
107     EOD
108    
109     }
110    

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26