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 4405 - (hide annotations) (download) (as text)
Wed Mar 30 10:33:46 2011 UTC (13 years ago) by yutakapon
Original Path: trunk/doc/htmlhelp_index_make.pl
File MIME type: text/x-perl
File size: 2041 byte(s)
インデックスファイルは自動生成するようにしたので、Index.hhk はリポジトリ管理対象外とする。

1 yutakapon 4405 #! /usr/bin/perl
2    
3     #
4     # HTMLヘルプのインデックスファイルを生成する
5     #
6     # Usage(ActivePerl):
7     # perl htmlhelp_index_make.pl
8     #
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     <meta name="GENERATOR" content="Tera Term Project">
24     <!-- 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     my($line, $no);
75    
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     write_add_index($filename, $1);
89     last;
90     }
91    
92     $no++;
93     }
94     close(FP);
95     }
96    
97     sub write_add_index {
98     my($filename, $title) = @_;
99    
100     print << "EOD";
101     <LI><OBJECT type="text/sitemap">
102     <param name="Name" value="$title">
103     <param name="Local" value="$filename">
104     </OBJECT>
105     EOD
106    
107     }
108    

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