Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2048 lines
61 KiB

  1. #####################################################################
  2. # Library HtmlHelp.pm
  3. # Title HtmlHelp.pm
  4. # Version 1.0.2
  5. # Author David Grove (pete) [[email protected]]
  6. # Company ActiveState Tool Corp. -
  7. # Professional Tools for Perl Developers
  8. #####################################################################
  9. # Description Miscelaneous routines for working with Microsoft's
  10. # HtmlHelp system.
  11. #####################################################################
  12. # REVISION HISTORY
  13. #
  14. # 1.0.0 First final release, went out with 502
  15. # 1.0.1 Temporary, removed CSS insertion in favor of just
  16. # adding a link to the css, since it's being built
  17. # on the user's machine now; and temporarily added
  18. # the hardcoded contents of the main toc to the
  19. # built toc until I have time to build it codewise.
  20. # 1.0.2 gsar Fixed much brokenness. Much ugliness remains.
  21. =head1 TITLE
  22. HtmlHelp.pm
  23. =head1 SYNOPSIS
  24. Routines to create HtmlHelp from HTML or POD source (including the
  25. Pod in PM library files) using Microsoft's HtmlHelp compiler. This
  26. creates the intermediate project files and from those creates the
  27. htmlhelp windows 32-bit help files.
  28. Along with this libaray comes a set of programs that can be used
  29. either as-is or as examples for perl development. Each of the public
  30. functions in this libray is represented by one such script.
  31. =head1 USAGE
  32. There are two "builds" of perl help, the core build (build for core
  33. Perl and it's packages), and the packages build (build from a devel
  34. directory of directories which contain blib directories to draw
  35. upon). These are run by different people on different machines at
  36. different times in different situations, so they are mostly separate
  37. until the time comes within this module to actuall build the helpfiles.
  38. There is also a build (html index) that works on the user's computer
  39. after installing a new module.
  40. For the core build
  41. perl makehelp.pl
  42. for the package build
  43. perl makepackages.pl
  44. for the html index build
  45. perl makehtmlindex.pl
  46. The functions in this module can also be called programmatically
  47. =head1 FUNCTIONS
  48. The individual functions that were designed with working with
  49. html help files rather than the Perl htmlhelp documentation are
  50. deprecated in favor of doing things with a single command. Some
  51. of them need work in order to work again.
  52. =over 4
  53. =item MakeHelp
  54. Turns a single html page into htmlhelp document.
  55. =item MakeHelpFromDir
  56. Turns a directory's worth of html pages into a single htmlhelp document.
  57. =item MakeHelpFromTree
  58. Turns a tree's worth of html pages into a single htmlhelp document.
  59. =item MakeHelpFromHash
  60. Creates an htmlhelp document where the labels on the folders are passed
  61. into the program. Useful for labels like Tk::Whatsis::Gizmo to replace
  62. the default ones looking like c:/perl/lib/site/Tk/Whatsis/Gizmo.
  63. =item MakeHelpFromPod
  64. Turns a single Pod or pm document into htmlhelp document.
  65. =item MakeHelpFromPodDir
  66. Turns a dir's worth of Pod or pm into a single htmlhelp document.
  67. =item MakeHelpFromPodTree
  68. Turns a tree's worth of Pod or pm into a single htmlhelp document.
  69. =item MakeHelpFromPodHash
  70. Like MaheHelpFromHash() but for Pod instead of html.
  71. =item MakePerlHtmlIndex
  72. Creates an HTML version of an index or TOC for perl help.
  73. =item MakePerlHtml
  74. Does everything for perl HTML works.
  75. =back
  76. =head1 CONFIG.PM
  77. This library makes use of Config.pm to know where to get its stuff.
  78. =head1 HHC.EXE
  79. This library makes use of the HtmlHelp compiler by microsoft.
  80. =head1 VARIABLES
  81. =over4
  82. =item $HtmlHelp::CSS
  83. Determines the stylesheet to be used for the htmlhelp files. Default
  84. is the ActiveState common stylesheet. This variable can be set to
  85. an empty string to allow for just plain old HTML with nothing fancy.
  86. Default is perl.css.
  87. =item $HtmlHelp::COMPILER
  88. Complete path and file name of the HtmlHelp compiler from Microsoft.
  89. This is REQUIRED for this library to run. It defaults to it's install
  90. directory within <lib>/HtmlHelp. Feel free to move this in $COMPILER
  91. if you have the HtmlHelp workshop from Microsoft and you want to
  92. use the compiler from a different location.
  93. =item $HtmlHelp::FULLTEXTSEARCH
  94. Whether to create full text search. Defaults to true.
  95. =item $HtmlHelp::CLEANUP
  96. Whether to clean up temporary files (and html files if building
  97. from raw Pod) after building the htmlhelp. This can be useful,
  98. for example, when you need to keep the intermediate files created
  99. by the process for inclusion into a collective help file.
  100. =back
  101. =head1 TARGET AUDIENCE
  102. Mostly this module is created for internal use for ActiveState Tool
  103. Corp., but since it is a part of the standard distrib for Win32 Perl
  104. then I expect it to be used or tried by the general public. However,
  105. no support for this module is available for the public; and it may
  106. be changed at any time.
  107. =head1 INSTALLATION
  108. First of all, this is designed for use with the Perl Resource
  109. Kit. Use with other versions of perl should be considered
  110. unsupported. Perl should be fully installed and configured to
  111. use this thing
  112. Next, Config.pm must be fully configured. Using Config.pm allows
  113. me to program remotely for tools at ActiveState corporate office.
  114. There were some early problems with Config.pm with the PRK and
  115. build 500 of Perl for Win32. These need to be corrected to use
  116. this library.
  117. Perl needs to have $Config{privlib}/../Html and also
  118. $Config{privlib}/../HtmlHelp to use this library. These should be
  119. created before doing anything. Copy the html files and gif
  120. files from this library to the Html directory. All other
  121. files will be created during run.
  122. Finally, copy all the files to $Config{privlib}/HtmlHelp, and the
  123. file HtmlHelp.pm to $Config{privlib}. The former is the normal site
  124. for the htmlhelp compiler (hhc.exe), and it is expected there.
  125. To use this tool, you need to have the compiler's dll's installed
  126. on your system. You should install the htmlhelp workshop from
  127. microsoft for these. Otherwise you should get these dll's from
  128. someone who has them. I think there's only one or two.
  129. =head1 USAGE
  130. =head2 Building HtmlHelp
  131. Building HtmlHelp for main perl is done using the script
  132. makehelp.pl. It requires no command line arguments because it
  133. gets all its information from Config.pm.
  134. Individual files are created as follows:
  135. =over4
  136. =item file2hhelp.pl for .html to .chm
  137. =item dir2hhelp.pl for dir of .html to .chm
  138. =item tree2hhelp.pl for tree of .html to .chm(s)
  139. =item Pod2hhelp.pl for .Pod or .pm to .chm
  140. =item Podd2hhelp.pl for dir of .Pod or .pm to .chm
  141. =item Podt2hhelp.pl for tree of .Pod or .pm to .chm(s)
  142. =back
  143. If your forget the command line arguments for one of the
  144. above, type:
  145. perl <scriptfile>
  146. and it will tell you what command line arguments are needed.
  147. =head2 Building HTML
  148. Building HTML for main perl is doine using the script
  149. makehtml.pl. It requires no command line arguemtns because it
  150. gets all its information from Config.pm.
  151. Individual html files can be built using the normal pod2html
  152. script by Tom Christiansen. Building html from directories
  153. and trees is not otherwise supported.
  154. =head1 AUTHOR
  155. David (pete) Grove
  156. email: pete@ActiveState.com
  157. =head1 FIRM
  158. ActiveState Tool Corp.
  159. Professional Tools for Perl Programmers
  160. =cut
  161. #####################################################################
  162. package HtmlHelp;
  163. #####################################################################
  164. use Pod::WinHtml; # My hack of TC's Pod::Html
  165. use Config;
  166. use File::Copy;
  167. use File::Basename;
  168. use File::Path;
  169. #####################################################################
  170. # Variables
  171. my $CLEANUP = 1;
  172. my $MAKE_HTML_FOR_HHELP = 0;
  173. my $FULLTEXTSEARCH = 1;
  174. my $LIB = $Config{'privlib'};
  175. $LIB =~ s{\\}{/}g;
  176. my $SITELIB = $Config{'sitelib'};
  177. my $HTMLHELP = $LIB; $HTMLHELP =~ s{(\\|/)lib}{/HtmlHelp}i;
  178. my $COMPILER = "$LIB/HtmlHelp/hhc.exe";
  179. my $HTML = $LIB; $HTML =~ s{(\\|/)lib}{/Html}i;
  180. my $TEMP = "$HTMLHELP/Temp";
  181. my $MERGE_PACKAGES = 0;
  182. #####################################################################
  183. # Function PreDeclarations
  184. sub RunCompiler;
  185. sub MakeHelpFromPod;
  186. sub MakeHelpFromPodDir;
  187. sub MakeHelpFromDir;
  188. sub MakePerlHtml;
  189. sub MakePerlHtmlIndexCaller;
  190. sub MakePerlHtmlIndex;
  191. sub GetHtmlFilesFromTree;
  192. sub MakePerlHelp;
  193. sub MakePerlHelpMain;
  194. sub MakeHelpFromPodTree;
  195. sub MakeHtmlTree;
  196. sub MakeHelpFromTree;
  197. sub GetHtmlFileTreeList;
  198. sub MakeHelpFromHash;
  199. sub MakeModuleTreeHelp;
  200. sub MakeHelp;
  201. sub BackSlash;
  202. sub ExtractFileName;
  203. sub ExtractFilePath;
  204. sub MakePackageMainFromSingleDir;
  205. sub MakePackageMain;
  206. sub MakePackages;
  207. sub CopyDirStructure;
  208. sub GetFileListForPackage;
  209. sub CreateHHP;
  210. sub CreateHHC;
  211. sub CreateHHCFromHash;
  212. sub InsertMainToc_Temporary;
  213. #####################################################################
  214. # FUNCTION RunCompiler
  215. # RECEIVES Project file to compile
  216. # RETURNS None
  217. # SETS None
  218. # EXPECTS $COMPILER, hhc and hhp files should be there
  219. # PURPOSE Runs the HtmlHelp compiler to create a chm file
  220. sub RunCompiler {
  221. my $projfile = BackSlash(shift);
  222. my $compiler = BackSlash($COMPILER);
  223. print "Trying \"$compiler $projfile\"\n";
  224. qx($compiler $projfile);
  225. }
  226. #####################################################################
  227. # FUNCTION MakeHelpFromPod
  228. # RECEIVES Helpfile (no path), Working directory, Output
  229. # directory (path for chm file), Files to include
  230. # RETURNS Results from running MakeHelp
  231. # SETS None
  232. # EXPECTS None
  233. # PURPOSE Takes pod/pm files, turns them into html, and then
  234. # into Htmlhelp files.
  235. sub MakeHelpFromPod {
  236. my ($helpfile, $workdir, $outdir, @podfiles) = @_;
  237. my $htmlfiles;
  238. my $htmlfile;
  239. my $podfile;
  240. foreach $podfile (@podfiles) {
  241. $podfile =~ s{\\}{/}g;
  242. $htmlfile = $podfile;
  243. $htmlfile =~ s{(^/]*)\....?$}{$1\.html};
  244. push(@htmlfiles, $htmlfile);
  245. pod2html("--infile=$podfile", "--outfile=$htmlfile");
  246. }
  247. @htmlfiles = grep{-e $_} @htmlfiles;
  248. unless(@htmlfiles) {
  249. $! = "No html files were created";
  250. return 0;
  251. }
  252. return MakeHelp($helpfile, $workdir, $outdir, @htmlfiles);
  253. }
  254. #####################################################################
  255. # FUNCTION MakeHelpFromPodDir
  256. # RECEIVES Helpfile (no extension), Working directory, Output
  257. # directory (for the Helpfile), Directory to translate
  258. # RETURNS 1|0
  259. # SETS None
  260. # EXPECTS None
  261. # PURPOSE Takes a directory's worth of pod/pm files and turns
  262. # them into html and then a single chm file
  263. sub MakeHelpFromPodDir {
  264. my ($helpfile, $workdir, $outdir, $fromdir) = @_;
  265. my @podfiles;
  266. my $htmlfile;
  267. my @htmlfiles;
  268. if(opendir(DIR,$fromdir)) {
  269. @podfiles = grep {/(\.pod)|(\.pm)/i} readdir(DIR);
  270. if(@podfiles) {
  271. foreach $podfile (@podfiles) {
  272. $htmlfile = $podfile;
  273. $htmlfile =~ s{(\.pm)|(\.pod)$}{\.html}i;
  274. $htmlfile = "$workdir/$htmlfile";
  275. push(@htmlfiles, $htmlfile);
  276. pod2html("--infile=$fromdir/$podfile", "--outfile=$htmlfile");
  277. }
  278. @htmlfiles = grep {-e $_} @htmlfiles;
  279. MakeHelp($helpfile, $workdir, $outdir, @htmlfiles);
  280. } else {
  281. $! = "No files to be made from $fromdir";
  282. return 0;
  283. }
  284. } else {
  285. $! = "Could not open directory $fromdir";
  286. return 0;
  287. }
  288. unlink @htmlfiles if $CLEANUP;
  289. 1;
  290. }
  291. #####################################################################
  292. # FUNCTION MakeHelpFromDir
  293. # RECEIVES Helpfile (no extension), Working directory, Output
  294. # directory (for Helpfile), Dir of html files for input
  295. # RETURNS 1|0
  296. # SETS None
  297. # EXPECTS None
  298. # PURPOSE Takes a directory's worth of html files and binds
  299. # them all into a chm file
  300. sub MakeHelpFromDir {
  301. my ($helpfile, $workdir, $outdir, $fromdir) = @_;
  302. my @files;
  303. if(opendir(DIR,$fromdir)) {
  304. @files = map {"$fromdir/$_"} sort(grep {/\.html?/i} readdir(DIR));
  305. closedir(DIR);
  306. if(@files) {
  307. MakeHelp($helpfile, $workdir, $outdir, @files);
  308. } else {
  309. $! = "No files to be made from $fromdir";
  310. return 0;
  311. }
  312. } else {
  313. $! = "Could not open directory $fromdir";
  314. return 0;
  315. }
  316. 1;
  317. }
  318. #####################################################################
  319. # FUNCTION MakePerlHtml
  320. # RECEIVES None
  321. # RETURNS None
  322. # SETS None
  323. # EXPECTS $HTML, $LIB, $SITELIB
  324. # PURPOSE Creates html files from pod for the entire perl
  325. # system, and creates the main toc file.
  326. sub MakePerlHtml {
  327. MakeHtmlTree($LIB, "$HTML/lib", 1);
  328. MakeHtmlTree($SITELIB, "$HTML/lib/site", 2);
  329. MakePerlHtmlIndex("$HTML/lib", "$HTML/perltoc.html");
  330. }
  331. #####################################################################
  332. # FUNCTION MakePerlHtmlIndexCaller
  333. # RECEIVES None
  334. # RETURNS None
  335. # SETS None
  336. # EXPECTS $HTML
  337. # PURPOSE Caller for MakePerlHtmlIndex. Using this function
  338. # releases the caller from the responsibility of
  339. # feeding params to MakePerlHtmlIndex, which this
  340. # library gets automagically from Config.pm
  341. sub MakePerlHtmlIndexCaller {
  342. #
  343. # Changed this to reflect the "single index file" idea
  344. #
  345. return MakePerlHtmlIndex("$HTML/lib", "$HTML/perltoc.html");
  346. #return MakePerlHtmlIndex("$HTML/lib", "$HTML/maintoc.html");
  347. }
  348. #####################################################################
  349. # FUNCTION MakePerlHtmlIndex
  350. # RECEIVES Base directory to look in, $index file to create
  351. # RETURNS 1 | 0
  352. # SETS None
  353. # EXPECTS None
  354. # PURPOSE Creates the main html index for the perl system. This
  355. # is called by ppm after installing a package.
  356. sub MakePerlHtmlIndex {
  357. my ($basedir, $indexfile) = @_;
  358. my %files;
  359. my $file;
  360. my $file_cmp;
  361. my $dir;
  362. my $dir_cmp;
  363. my $dir_to_print;
  364. my $dir_html_root;
  365. my $counter;
  366. my $file_to_print;
  367. my $sitedir;
  368. my $libdir;
  369. my $temp;
  370. # Get a list of all the files in the tree, list refs keyed by dir.
  371. # These files are under c:/perl/html/lib because they have
  372. # already been generated.
  373. # normalize to forward slashes (NEVER use backslashes in URLs!)
  374. $basedir =~ s{\\}{/}g;
  375. unless(%files = GetHtmlFilesFromTree($basedir)) {
  376. return 0;
  377. }
  378. # Start the html document
  379. unless(open(HTML, ">$indexfile")) {
  380. $! = "Couldn't write to $indexfile\n";
  381. return 0;
  382. }
  383. print HTML <<'EOT';
  384. <HTML>
  385. <HEAD>
  386. <TITLE>Perl Help System Index</TITLE>
  387. <BASE TARGET="PerlDoc">
  388. </HEAD>
  389. <LINK REL="STYLESHEET" HREF="win32prk.css" TYPE="text/css">
  390. <STYLE>
  391. BODY {font-size : 8.5pt;}
  392. P {font-size : 8.5pt;}
  393. </STYLE>
  394. <BODY>
  395. EOT
  396. foreach $dir (keys %files) {
  397. foreach $file (@{$files{$dir}}) {
  398. $file_cmp = $file;
  399. $file_cmp =~ s/\.html?$//i;
  400. if(exists $files{"$dir/$file_cmp"}) {
  401. push(@{$files{"$dir/$file_cmp"}}, "$file_cmp/$file");
  402. @{$files{$dir}} = grep {$_ ne $file} @{$files{$dir}};
  403. }
  404. }
  405. }
  406. # Merge the different directories if duplicate directories
  407. # exist for lib and site. Effectively this removes lib/site
  408. # from existence, and prepends "site" onto the file name for
  409. # future reference. This way there is only one folder per
  410. # heading, but I can still tell when to use "site" in
  411. # making a html link.
  412. $libdir = "$HTML/lib";
  413. $sitedir = "$HTML/lib/site";
  414. push(@{$files{$libdir}}, map {"site/$_"} @{$files{$sitedir}});
  415. delete $files{$sitedir};
  416. foreach $dir (keys %files) {
  417. if($dir =~ m{/site/}i) {
  418. $dir_cmp = $dir;
  419. $dir_cmp =~ s{(/lib/)site/}{$1}i;
  420. push(@{$files{$dir_cmp}}, map {"site/$_"} @{$files{$dir}});
  421. delete $files{$dir};
  422. }
  423. }
  424. InsertMainToc_Temporary();
  425. print HTML <<EOT;
  426. <img id="Foldergif_63" src="folder.gif">&nbsp;
  427. <b><a name="CorePerlFAQ">Core Perl FAQ</a><BR>
  428. </b>
  429. EOT
  430. foreach $file (@{$files{"$libdir/Pod"}}) {
  431. $file_to_print = $file;
  432. $file_to_print =~ s{\.html$}{}i;
  433. next unless $file_to_print =~ m{^(perlfaq\d*)$};
  434. print HTML <<EOT;
  435. &nbsp;&nbsp;&nbsp;
  436. <img id="Pagegif_63" src="page.gif">&nbsp;
  437. <a href="./lib/Pod/$file_to_print.html">
  438. $file_to_print
  439. </a><BR>
  440. EOT
  441. }
  442. print HTML <<EOT;
  443. <img id="Foldergif_63" src="folder.gif">&nbsp;
  444. <b><a name="CorePerlDocs">Core Perl Docs</a><BR>
  445. </b>
  446. EOT
  447. foreach $file (@{$files{"$libdir/Pod"}}) {
  448. $file_to_print = $file;
  449. $file_to_print =~ s{\.html$}{}i;
  450. next unless $file_to_print =~ m{^(perl[a-z0-9]*)$};
  451. next if $file_to_print =~ /^perlfaq/;
  452. print HTML <<EOT;
  453. &nbsp;&nbsp;&nbsp;
  454. <img id="Pagegif_63" src="page.gif">&nbsp;
  455. <a href="./lib/Pod/$file_to_print.html">
  456. $file_to_print
  457. </a><BR>
  458. EOT
  459. }
  460. print HTML <<EOT;
  461. </p><hr>
  462. <h4><a name="ModuleDocs">Module Docs</a></h4>
  463. <p>
  464. EOT
  465. foreach $dir (sort { uc($a) cmp uc($b) } keys(%files)) {
  466. $counter++;
  467. $dir_to_print = $dir;
  468. # get just the directory starting with lib/
  469. $dir_to_print =~ s{.*/(lib/?.*$)}{$1}i;
  470. # change slashes to double colons
  471. $dir_to_print =~ s{/}{::}g;
  472. # kill extra stuff lib and site
  473. $dir_to_print =~ s{lib::}{}i;
  474. # Don't want to see lib:: and lib::site::
  475. $dir_to_print =~ s{(.*)(/|::)$}{$1};
  476. if($dir_to_print =~ m{^lib(/site)?$}i) {
  477. $dir_to_print = 'Root Libraries';
  478. }
  479. print HTML <<EOT;
  480. <!-- -------------------------------------------- $dir -->
  481. <SPAN
  482. id="Dir_${counter}"
  483. >
  484. <b>
  485. <img id="Foldergif_${counter}" src="folder.gif">&nbsp;
  486. $dir_to_print<BR>
  487. </b></SPAN>
  488. <SPAN
  489. id="Files_${counter}"
  490. >
  491. EOT
  492. if (@{$files{$dir}}) {
  493. foreach $file (sort { $c = $a;
  494. $d = $b;
  495. $c =~ s{^site/}{}i;
  496. $d =~ s{^site/}{}i;
  497. uc($c) cmp uc($d) } (@{$files{$dir}}))
  498. {
  499. $file_to_print = $file;
  500. $file_to_print =~ s{\.html?}{}i;
  501. # skip perlfunc.pod etc.
  502. next if $file_to_print =~ m{^perl[a-z0-9]*$};
  503. $dir_html_root = $dir;
  504. if ($file_to_print =~ m{^site/[^/]*$}i) {
  505. $dir_html_root =~ s{(lib/)}{$1site/}i;
  506. $dir_html_root =~ s{/lib$}{/lib/site}i;
  507. $file_to_print =~ s{^site/}{}i;
  508. $file =~ s{^site/}{}i;
  509. }
  510. elsif ($file_to_print =~ m{^site/(.*)/}i) {
  511. $temp = $1;
  512. # Get rid of the site
  513. $dir_html_root =~ s{(lib/)}{$1site/}i;
  514. $dir_html_root =~ s{/lib$}{/lib/site}i;
  515. $file_to_print =~ s{^site/}{}i;
  516. $file =~ s{^site/}{}i;
  517. # Get rid of the additional directory
  518. $file_to_print =~ s{^[^/]*/}{}i;
  519. $file =~ s{^[^/]*/}{}i;
  520. $dir_html_root =~ s{/$temp/?}{}i;
  521. }
  522. elsif ($file_to_print =~ m{^(.*)/}) {
  523. $temp = $1;
  524. # $file_to_print =~ s{^[^/]/?}{}i;
  525. # $file =~ s{^[^/]/?}{}i;
  526. $file_to_print =~ s{^.*?/}{}i;
  527. $file =~ s{^.*?/}{}i;
  528. $dir_html_root =~ s{/$temp/?}{}i;
  529. }
  530. $dir_html_root =~ s{.*/lib$}{lib}i;
  531. $dir_html_root =~ s{.*/(lib/.*)}{$1}i;
  532. $dir_html_root =~ s{lib/\.\./html/}{}i;
  533. print HTML <<EOT;
  534. &nbsp;&nbsp;&nbsp;
  535. <img id="Pagegif_${counter}" src="page.gif">&nbsp;
  536. <a href="$dir_html_root/$file">
  537. $file_to_print
  538. </a><BR>
  539. EOT
  540. }
  541. }
  542. else {
  543. print HTML "&nbsp;&nbsp;&nbsp;\n";
  544. print HTML "No pod / html<BR>\n";
  545. }
  546. print HTML "</SPAN>\n";
  547. }
  548. print HTML "</p>\n";
  549. # Close the file
  550. print HTML "</BODY>\n";
  551. print HTML "</HTML>\n";
  552. close HTML;
  553. return 1;
  554. }
  555. #####################################################################
  556. # FUNCTION InsertMainToc_Temporary
  557. # RECEIVES None
  558. # RETURNS None
  559. # SETS None
  560. # EXPECTS HTML must be an open file handls
  561. # PURPOSE Temporary (interim) function to hard code the content
  562. # of the main toc into a single, merged toc
  563. sub InsertMainToc_Temporary {
  564. print HTML <<'END_OF_MAIN_TOC';
  565. <p><a href="http://www.ActiveState.com"><img src="aslogo.gif" border="0"></a></p>
  566. <p><img src="pinkbullet.gif" width="10" height="10">&nbsp;<a href="#ActivePerlDocs" target="TOC"><b>ActivePerl Docs</b></a><br>
  567. <img src="pinkbullet.gif" width="10" height="10">&nbsp;<a href="#GettingStarted" target="TOC"><b>Getting
  568. Started</b></a><b><br>
  569. <img src="pinkbullet.gif" width="10" height="10">&nbsp;<a href="#ActivePerlComponents" target="TOC">ActivePerl
  570. Components</a><br>
  571. <img src="pinkbullet.gif" width="10" height="10">&nbsp;<a href="#ActivePerlFAQ" target="TOC">ActivePerl
  572. FAQ</a><br>
  573. <img src="pinkbullet.gif" width="10" height="10">&nbsp;<a href="#CorePerlFAQ" target="TOC">Core
  574. Perl FAQ</a><br>
  575. <img src="pinkbullet.gif" width="10" height="10">&nbsp;<a href="#CorePerlDocs" target="TOC">Core
  576. Perl Docs</a><br>
  577. <img src="pinkbullet.gif" width="10" height="10">&nbsp;<a href="#ModuleDocs" target="TOC">Module
  578. Docs</a></b></p>
  579. <hr>
  580. <h4><a name="ActivePerlDocs">ActivePerl Docs</a></h4>
  581. <p><b><img id="Foldergif_60" src="folder.gif">&nbsp; <a name="GettingStarted">Getting
  582. Started</a></b><BR>
  583. &nbsp;&nbsp;&nbsp; <img id="Pagegif_60" src="page.gif">&nbsp; <a href="perlmain.html">
  584. Welcome</a><BR>
  585. &nbsp;&nbsp;&nbsp; <img id="Pagegif_60" src="page.gif">&nbsp; <a href="./Perl-Win32/release.htm">
  586. Release Notes </a><BR>
  587. &nbsp;&nbsp;&nbsp; <img id="Pagegif_60" src="page.gif">&nbsp; <a href="./Perl-Win32/install.htm">
  588. Install Notes </a><BR>
  589. &nbsp;&nbsp;&nbsp; <img id="Pagegif_60" src="page.gif">&nbsp; <a href="./Perl-Win32/readme.htm">
  590. Readme<br>
  591. </a>&nbsp;&nbsp;&nbsp; <img id="Pagegif_60" src="page.gif">&nbsp; <a href="./Perl-Win32/dirstructure.html">
  592. Dir Structure</a><br>
  593. <b> <img id="Foldergif_61" src="folder.gif" alt="Instructions and sample scripts for using PerlScript">&nbsp;
  594. <a name="ActivePerlComponents">ActivePerl Components</a><BR>
  595. </b>
  596. &nbsp;&nbsp;&nbsp; <img id="Pagegif_61" src="page.gif">&nbsp; <a href="./Perl-Win32/description.html">
  597. Overview</a><BR>
  598. &nbsp;&nbsp;&nbsp; <img id="Pagegif_61" src="page.gif">&nbsp; <a href="PerlScript.html">
  599. Using PerlScript </a><BR>
  600. &nbsp;&nbsp;&nbsp; <img id="Pagegif_61" src="page.gif">&nbsp; <a href="../eg/ie3examples/index.htm">
  601. PerlScript Examples </a><BR>
  602. <b> </b>&nbsp;&nbsp;&nbsp; <img id="Pagegif_68" src="page.gif">&nbsp; <a href="PerlISAPI.html">
  603. Using Perl for ISAPI </a><BR>
  604. &nbsp;&nbsp;&nbsp; <img id="Pagegif_68" src="page.gif">&nbsp; <a href="./Perl-Win32/perlwin32faq2.html">
  605. Perl for ISAPI FAQ </a><BR>
  606. <b> </b>&nbsp;&nbsp;&nbsp; <img id="Pagegif_69" src="page.gif">&nbsp; <a href="./Perl-Win32/perlwin32faq11.html">
  607. Using PPM</a><br>
  608. &nbsp;&nbsp;&nbsp; <img id="Pagegif_68" src="page.gif">&nbsp; <a href="./lib/site/Pod/PerlEz.html">
  609. PerlEZ</a><BR>
  610. <b><img id="Foldergif_62" src="folder.gif" alt="FAQ for using Perl on Win95/NT">&nbsp;
  611. <a name="ActivePerlFAQ">ActivePerl FAQ</a><BR>
  612. </b> &nbsp;&nbsp;&nbsp; <img id="Pagegif_62" src="page.gif">&nbsp; <a href="./Perl-Win32/perlwin32faq.html">
  613. Introduction </a><BR>
  614. &nbsp;&nbsp;&nbsp; <img id="Pagegif_62" src="page.gif">&nbsp; <a href="./Perl-Win32/perlwin32faq1.html">
  615. Availability & Install </a><BR>
  616. &nbsp;&nbsp;&nbsp; <img id="Pagegif_62" src="page.gif">&nbsp; <a href="./Perl-Win32/perlwin32faq2.html">
  617. Perl for ISAPI</a><BR>
  618. &nbsp;&nbsp;&nbsp; <img id="Pagegif_62" src="page.gif">&nbsp; <a href="./Perl-Win32/perlwin32faq3.html">
  619. Docs & Support </a><BR>
  620. &nbsp;&nbsp;&nbsp; <img id="Pagegif_62" src="page.gif">&nbsp; <a href="./Perl-Win32/perlwin32faq4.html">
  621. Windows 95/NT </a><BR>
  622. &nbsp;&nbsp;&nbsp; <img id="Pagegif_62" src="page.gif">&nbsp; <a href="./Perl-Win32/perlwin32faq5.html">
  623. Quirks </a><BR>
  624. &nbsp;&nbsp;&nbsp; <img id="Pagegif_62" src="page.gif">&nbsp; <a href="./Perl-Win32/perlwin32faq6.html">
  625. Web Server Config</a><BR>
  626. &nbsp;&nbsp;&nbsp; <img id="Pagegif_62" src="page.gif">&nbsp; <a href="./Perl-Win32/perlwin32faq7.html">
  627. Web programming </a><BR>
  628. &nbsp;&nbsp;&nbsp; <img id="Pagegif_62" src="page.gif">&nbsp; <a href="./Perl-Win32/perlwin32faq8.html">
  629. Programming </a><BR>
  630. &nbsp;&nbsp;&nbsp; <img id="Pagegif_62" src="page.gif">&nbsp; <a href="./Perl-Win32/perlwin32faq9.html">
  631. Modules &amp; Samples</a><BR>
  632. &nbsp;&nbsp;&nbsp; <img id="Pagegif_62" src="page.gif">&nbsp; <a href="./Perl-Win32/perlwin32faq10.html">
  633. Embedding &amp; Extending</a><BR>
  634. &nbsp;&nbsp;&nbsp; <img id="Pagegif_62" src="page.gif">&nbsp; <a href="./Perl-Win32/perlwin32faq11.html">
  635. Using PPM</a><BR>
  636. &nbsp;&nbsp;&nbsp; <img id="Pagegif_62" src="page.gif">&nbsp; <a href="./Perl-Win32/perlwin32faq12.html">
  637. Using OLE with Perl</a><BR>
  638. END_OF_MAIN_TOC
  639. }
  640. #####################################################################
  641. # FUNCTION GetHtmlFilesFromTree (recursive)
  642. # RECEIVES Base directory to look in
  643. # RETURNS List of html files
  644. # SETS None
  645. # EXPECTS None
  646. # PURPOSE Searches an entire for html files, returns a list of
  647. # html files found including path information
  648. sub GetHtmlFilesFromTree {
  649. my $basedir = shift;
  650. my @dirs;
  651. my @htmlfiles;
  652. my %ret;
  653. unless(opendir(DIR, $basedir)) {
  654. $! = "Can't read from directory $basedir\n";
  655. return 0;
  656. }
  657. @files = readdir(DIR);
  658. closedir(DIR);
  659. @dirs = grep {-d "$basedir/$_" and /[^.]$/} @files;
  660. @htmlfiles = grep {/\.html?$/i} @files;
  661. foreach $dir (@dirs) {
  662. unless(%ret = (%ret, GetHtmlFilesFromTree("$basedir/$dir"))) {
  663. return 0;
  664. }
  665. }
  666. %ret = (%ret, $basedir => \@htmlfiles);
  667. }
  668. #####################################################################
  669. # FUNCTION MakePerlHelp
  670. # RECEIVES None
  671. # RETURNS 1 | 0
  672. # SETS None
  673. # EXPECTS None
  674. # PURPOSE Creates html help for the perl system. This is the
  675. # html help core build. If MAKE_HTML_FOR_HHELP is set
  676. # to a true vale, then it builds the help from POD,
  677. # otherwise it depends on the pod being there already.
  678. sub MakePerlHelp {
  679. if($MAKE_HTML_FOR_HHELP) {
  680. unless(MakeHelpFromPodTree($HTMLHELP, $HTMLHELP, $LIB, "$HTML/lib")) {
  681. return 0;
  682. }
  683. unless(MakeHelpFromPodTree($HTMLHELP, $HTMLHELP, $SITELIB,
  684. "$HTML/lib/site")) {
  685. return 0;
  686. }
  687. } else {
  688. unless(MakeHelpFromTree($HTMLHELP, $HTMLHELP, "$HTML/lib")) {
  689. return 0;
  690. }
  691. }
  692. unless(MakePerlHelpMain) {
  693. return 0;
  694. }
  695. # This handles MakePerlHtml too, since we've created all the html
  696. unless(MakePerlHtmlIndex("$HTML/lib", "$HTML/perltoc.html")) {
  697. return 0;
  698. }
  699. return 1;
  700. }
  701. #####################################################################
  702. # FUNCTION MakePerlHelpMain;
  703. # RECEIVES None
  704. # RETURNS None
  705. # SETS None
  706. # EXPECTS None
  707. # PURPOSE Creates the main perl helpfile from all the little
  708. # helpfiles already created.
  709. sub MakePerlHelpMain {
  710. my @files;
  711. print "Generating main library helpfile\n";
  712. unless(opendir(DIR, $HTMLHELP)) {
  713. $! = "Directory $HTMLHELP could not be read\n";
  714. return 0;
  715. }
  716. unless(-e "$HTMLHELP/default.htm") {
  717. copy("$HTML/libmain.html", "$HTMLHELP/default.htm");
  718. }
  719. @files = grep {/\.hhc/i} readdir(DIR);
  720. closedir(DIR);
  721. $CLEANUP=0;
  722. $MERGE_PACKAGES = 1;
  723. MakeHelp("libmain.chm", $HTMLHELP, $HTMLHELP, @files);
  724. $CLEANUP = 1;
  725. $MERGE_PACKAGES = 0;
  726. return 1;
  727. }
  728. #####################################################################
  729. # FUNCTION MakeHelpFromPodTree
  730. # RECEIVES Working directory, Output directory, Source Diretory,
  731. # HtmlOutput Directory
  732. # RETURNS 0 | 1
  733. # SETS None
  734. # EXPECTS None
  735. # PURPOSE Takes a tree's worth of pod and turns them first
  736. # into html and then into htmlhelp.
  737. sub MakeHelpFromPodTree {
  738. my ($workdir, $outdir, $fromdir, $htmldir) = @_;
  739. unless(MakeHtmlTree($fromdir, $htmldir)) {
  740. return 0;
  741. }
  742. unless(MakeHelpFromTree($workdir, $outdir, $htmldir)) {
  743. return 0;
  744. }
  745. # if(opendir(DIR, $outdir)) {
  746. # unlink(map {"$outdir/$_"} grep {/\.hhp/i} readdir(DIR));
  747. # closedir(DIR);
  748. # } else {
  749. # warn "Could not clean up project files in $outdir\n";
  750. # }
  751. return 1;
  752. }
  753. #####################################################################
  754. # FUNCTION MakeHtmlTree
  755. # RECEIVES Source Directory, Html Output Directory
  756. # RETURNS 0 | 1
  757. # SETS None
  758. # EXPECTS None
  759. # PURPOSE Makes a tree's worth of html from a tree's worth
  760. # of pod.
  761. sub MakeHtmlTree {
  762. my ($fromdir, $htmldir, $depth) = @_;
  763. my @files;
  764. my @podfiles;
  765. my @dirs;
  766. my $podfile;
  767. my $htmlfile;
  768. my $dir;
  769. my $css = '../' x$depth . 'win32prk.css';
  770. # Get list of files and directories to process
  771. $fromdir =~ s{\\}{/}g;
  772. if(!-d $fromdir) {
  773. $! = "Directory $fromdir does not exist\n";
  774. return 0;
  775. }
  776. unless(opendir(DIR, $fromdir)) {
  777. $! = "Directory $fromdir couldn't be read\n";
  778. return 0;
  779. }
  780. @files = readdir(DIR);
  781. closedir(DIR);
  782. @podfiles = map {"$fromdir/$_"} grep {/\.pod$|\.pm$/i} @files;
  783. @dirs = grep {-d "$fromdir/$_" and /[^.]$/} @files;
  784. if(@podfiles) {
  785. # Create the copy directory
  786. if(!-d $htmldir) {
  787. unless(mkpath($htmldir)) {
  788. $! = "Directory $htmldir could not be created\n";
  789. return 0;
  790. }
  791. }
  792. foreach $podfile (@podfiles) {
  793. $htmlfile = $podfile;
  794. $htmlfile =~ s{.*/(.*)}{$1};
  795. $htmlfile =~ s{\.pod|\.pm$}{.html}i;
  796. $htmlfile = "$htmldir/$htmlfile";
  797. unlink($htmlfile) if (-e $htmlfile);
  798. pod2html("--infile=$podfile", "--outfile=$htmlfile", "--css=$css");
  799. }
  800. }
  801. ++$depth;
  802. foreach $dir (@dirs) {
  803. MakeHtmlTree("$fromdir/$dir", "$htmldir/$dir", $depth);
  804. }
  805. return 1;
  806. }
  807. #####################################################################
  808. # FUNCTION MakeHelpFromTree
  809. # RECEIVES Working directory, Output directory, Source directory
  810. # RETURNS 0 | 1
  811. # SETS None
  812. # EXPECTS None
  813. # PURPOSE Creates html help from a tree's worth of html
  814. sub MakeHelpFromTree {
  815. my ($workdir, $outdir, $fromdir) = @_;
  816. my %files;
  817. my $file;
  818. my $key;
  819. my $file_root;
  820. $fromdir =~ s{\\}{/}g;
  821. unless(%files = GetHtmlFileTreeList($fromdir, $fromdir)) {
  822. return 0;
  823. }
  824. $file_root = $fromdir;
  825. $file_root =~ s{(.*)/$}{$1};
  826. foreach $key (sort(keys(%files))) {
  827. $file = $key;
  828. $file = substr($key, length($file_root));
  829. $file =~ s{^/}{};
  830. $file =~ s{/}{-}g;
  831. $file =~ s{ }{}g;
  832. if($file eq "") {
  833. if($file_root =~ /lib$/i) {
  834. $file = "lib";
  835. } else {
  836. $file = "lib-site";
  837. }
  838. } elsif ($file_root =~ /lib$/i) {
  839. $file = "lib-" . $file;
  840. } elsif ($file_root =~ /site$/i) {
  841. $file = "lib-site-" . $file;
  842. }
  843. $file .= ".chm";
  844. unless(MakeHelp("$file", $workdir, $outdir, map {"$key/$_"} @{$files{$key}})) {
  845. return 0;
  846. }
  847. }
  848. return 1;
  849. }
  850. #####################################################################
  851. # FUNCTION GetHtmlFileTreeList (recursive)
  852. # RECEIVES Original root (from first call), Root (successive)
  853. # RETURNS Hash of files
  854. # SETS None
  855. # EXPECTS None
  856. # PURPOSE Get a list of html files throughout a tree
  857. sub GetHtmlFileTreeList {
  858. my $origroot = shift;
  859. my $root = shift;
  860. my @files;
  861. my @htmlfiles;
  862. my @dirs;
  863. my $dir;
  864. my %ret;
  865. $origroot =~ s{\\}{/}g;
  866. $root =~ s{\\}{/}g;
  867. unless(opendir(DIR, $root)) {
  868. $! = "Can't open directory $root\n";
  869. return undef;
  870. }
  871. @files = readdir(DIR);
  872. @dirs = grep {-d "$root/$_" and /[^.]$/} @files;
  873. @htmlfiles = grep {/\.html?/i} @files;
  874. closedir(DIR);
  875. %ret = ($root => \@htmlfiles) if @htmlfiles;
  876. foreach $dir (@dirs) {
  877. unless(%ret = (%ret, GetHtmlFileTreeList($origroot, "$root/$dir"))) {
  878. return undef;
  879. }
  880. }
  881. return %ret;
  882. }
  883. #####################################################################
  884. # FUNCTION MakeHelpFromHash
  885. # RECEIVES Helpfile name, working directory, output directory,
  886. # and a hash containing the html files to process and
  887. # their titles
  888. # RETURNS 0 | 1
  889. # SETS None
  890. # EXPECTS None
  891. # PURPOSE Create a helpfile from a hash rather than from a
  892. # simple list of html files, to have better control
  893. # over the file titles. This function is unused and
  894. # may take some work to get it to work right.
  895. sub MakeHelpFromHash {
  896. my ($helpfile, $workdir, $outdir, %htmlfiles) = @_;
  897. my $tocfile;
  898. my $projfile;
  899. die("MakeHelpFromHash() is not completely implemented\n");
  900. $tocfile = $helpfile;
  901. $tocfile =~ s/\.chm/.hhc/i;
  902. $tocfile = "$workdir/$tocfile";
  903. $projfile = $helpfile;
  904. $projfile =~ s/\.chm/.hhp/i;
  905. $projfile = "$workdir/$projfile";
  906. $helpfile = "$outdir/$helpfile";
  907. unless(CreateHHP($helpfile, $projfile, $tocfile, keys(%htmlfiles))) {
  908. return 0;
  909. }
  910. unless(CreateHHCFromHash($helpfile, $tocfile, %htmlfiles)) {
  911. return 0;
  912. }
  913. RunCompiler($helpfile);
  914. 1;
  915. }
  916. #####################################################################
  917. # FUNCTION MakeModuleTreeHelp
  918. # RECEIVES Directory to start from, regex mask for that dir
  919. # RETURNS 1 | 0
  920. # SETS None
  921. # EXPECTS The directories to be right
  922. # PURPOSE Create help from a tree of pod files for packages
  923. sub MakeModuleTreeHelp {
  924. my ($fromdir, $mask) = @_;
  925. my @files;
  926. my @htmlfiles;
  927. my @podfiles;
  928. my @dirs;
  929. my $helpfile;
  930. my $podfile;
  931. my $htmlfile;
  932. my $dir;
  933. $fromdir =~ s{\\}{/}g;
  934. print "Creating help files for $fromdir\n";
  935. # Create the html for the directory
  936. unless(opendir(DIR, $fromdir)) {
  937. $! = "Can't read from directory $fromdir";
  938. return 0;
  939. }
  940. @files = readdir(DIR);
  941. closedir(DIR);
  942. @podfiles = map {"$fromdir/$_"} grep {/\.pm/i or /\.pod/i} @files;
  943. foreach $podfile (@podfiles) {
  944. $htmlfile = $podfile;
  945. $htmlfile =~ s/\.(pm|pod)$/.html/i;
  946. pod2html("--infile=$podfile", "--outfile=$htmlfile");
  947. }
  948. # Create the htmlhelp for the directory
  949. $CLEANUP = 0;
  950. @htmlfiles = map {"$fromdir/$_"} grep {/\.html?/i} @files;
  951. if(@htmlfiles) {
  952. $helpfile = $fromdir;
  953. $helpfile =~ s{$mask}{}i;
  954. $helpfile =~ s{/}{-}g;
  955. $helpfile .= ".chm";
  956. MakeHelp($helpfile, $fromdir, $fromdir, @htmlfiles);
  957. }
  958. # Recurse
  959. @dirs = map {"$fromdir/$_"} grep {-d and /[^.]$/} @files;
  960. foreach $dir (@dirs) {
  961. unless(CreateModuleTreeHelp("$fromdir/$dir")) {
  962. return 0;
  963. }
  964. }
  965. return 1;
  966. }
  967. #####################################################################
  968. # FUNCTION MakeHelp
  969. # RECEIVES Helpfile (without drive and path), Working Directory,
  970. # Output Directory, and a list of files to include
  971. # in the helpfile
  972. # RETURNS None
  973. # SETS None
  974. # EXPECTS None
  975. # PURPOSE Create help from a list of html files. Everything in
  976. # this library comes through here eventually.
  977. sub MakeHelp {
  978. my ($helpfile, $workdir, $outdir, @htmlfiles) = @_;
  979. my $longtocfile;
  980. my $longprojfile;
  981. my $longhelpfile;
  982. my $longouthelpfile;
  983. my $longouttocfile;
  984. my $libdir;
  985. my $tocfile;
  986. my $projfile;
  987. $libdir = ExtractFilePath($htmlfiles[0]);
  988. $tocfile = $helpfile;
  989. $tocfile =~ s/\.chm/.hhc/i;
  990. if ($libdir ne "") {
  991. $longtocfile = "$libdir/$tocfile";
  992. }
  993. else {
  994. $longtocfile = "$outdir/$tocfile";
  995. }
  996. $longouttocfile = "$outdir/$tocfile";
  997. $projfile = $helpfile;
  998. $projfile =~ s/\.chm/.hhp/i;
  999. if ($libdir ne "") {
  1000. $longprojfile = "$libdir/$projfile";
  1001. }
  1002. else {
  1003. $longprojfile = "$outdir/$projfile";
  1004. }
  1005. if ($libdir ne "") {
  1006. $longhelpfile = "$libdir/$helpfile";
  1007. }
  1008. else {
  1009. $longhelpfile = "$outdir/$helpfile";
  1010. }
  1011. $longouthelpfile = "$outdir/$helpfile";
  1012. print "----- CREATING HELP FILE $longouthelpfile -----\n";
  1013. # put in the default document
  1014. if ($libdir eq "") {
  1015. unshift(@htmlfiles, "$HTMLHELP/default.htm");
  1016. }
  1017. unless(CreateHHP($longhelpfile, $longprojfile, $longtocfile, @htmlfiles)) {
  1018. return 0;
  1019. }
  1020. unless(CreateHHC($longhelpfile, $longtocfile, @htmlfiles)) {
  1021. return 0;
  1022. }
  1023. return 0 if (!-x $COMPILER);
  1024. RunCompiler($longhelpfile);
  1025. if($libdir ne "") {
  1026. if($longhelpfile ne $longouthelpfile) {
  1027. copy($longhelpfile, $longouthelpfile);
  1028. copy($longtocfile, $longouttocfile);
  1029. }
  1030. }
  1031. # temporary for when i want to see what it's doing
  1032. # $CLEANUP = 0;
  1033. if($CLEANUP) {
  1034. unlink $longhelpfile, $longtocfile, $longprojfile;
  1035. }
  1036. 1;
  1037. }
  1038. #####################################################################
  1039. # FUNCTION BackSlash
  1040. # RECEIVES string containing a path to convert
  1041. # RETURNS converted string
  1042. # SETS none
  1043. # EXPECTS none
  1044. # PURPOSE Internally, perl works better if we're using a
  1045. # front slash in paths, so I don't care what I'm
  1046. # using. But externally we need to keep everything as
  1047. # backslashes. This function does that conversion.
  1048. sub BackSlash {
  1049. my $in = shift;
  1050. $in =~ s{/}{\\}g;
  1051. return $in;
  1052. }
  1053. #####################################################################
  1054. # FUNCTION ExtractFileName
  1055. # RECEIVES FileName with (drive and) path
  1056. # RETURNS FileName portion of the file name
  1057. # SETS None
  1058. # EXPECTS None
  1059. # PURPOSE Gives the file name (anything after the last slash)
  1060. # from a given file and path
  1061. sub ExtractFileName {
  1062. my $in = shift;
  1063. $in =~ s/.*(\\|\/)(.*)/$2/;
  1064. $in;
  1065. }
  1066. #####################################################################
  1067. # FUNCTION ExtractFilePath
  1068. # RECEIVES Full file and path name
  1069. # RETURNS Path without the file name (no trailing slash)
  1070. # SETS None
  1071. # EXPECTS None
  1072. # PURPOSE Returns the path portion of a path/file combination,
  1073. # not including the last slash.
  1074. sub ExtractFilePath {
  1075. my $in = shift;
  1076. if($in =~ /\\|\//) {
  1077. $in =~ s/(.*)(\\|\/)(.*)/$1/;
  1078. } else {
  1079. $in = "";
  1080. }
  1081. $in;
  1082. }
  1083. #####################################################################
  1084. # FUNCTION MakePackageMainFromSingleDir
  1085. # RECEIVES Package helpfile directory, helpfile to create
  1086. # RETURNS 1 | 0
  1087. # SETS None
  1088. # EXPECTS None
  1089. # PURPOSE Creates the package helpfile from the directory of
  1090. # package helpfiles. Creates the master.
  1091. sub MakePackageMainFromSingleDir {
  1092. my $package_helpfile_dir = shift;
  1093. my $helpfile = shift;
  1094. my $helpfile_dir;
  1095. my @hhcfiles;
  1096. $helpfile_dir = ExtractFilePath($helpfile);
  1097. $helpfile = ExtractFileName($helpfile);
  1098. unless(opendir(DIR, $package_helpfile_dir)) {
  1099. $! = "Couldn't read from package directory $package_helpfile_dir";
  1100. return 0;
  1101. }
  1102. @hhcfiles = grep {/\.hhc$/i} readdir(DIR);
  1103. closedir(DIR);
  1104. $CLEANUP = 0;
  1105. unless(MakeHelp($helpfile, $helpfile_dir, $helpfile_dir, @hhcfiles)) {
  1106. return 0;
  1107. }
  1108. 1;
  1109. }
  1110. #####################################################################
  1111. # FUNCTION MakePackageMain
  1112. # RECEIVES Packages directory (contains packages which contain
  1113. # blib directories), helpfile name to create (include
  1114. # drive and path information)
  1115. # RETURNS 1 | 0
  1116. # SETS None
  1117. # EXPECTS None
  1118. # PURPOSE For the packages build of HtmlHelp, this function
  1119. # combines all the little packages into one chm
  1120. # file linked to all the little ones per module.
  1121. sub MakePackageMain {
  1122. my $package_root_dir = shift;
  1123. my $helpfile = shift;
  1124. my $helpfile_dir;
  1125. my @files;
  1126. my @dirs;
  1127. my @dir;
  1128. my @hhcfiles;
  1129. $helpfile_dir = ExtractFilePath($helpfile);
  1130. $helpfile = ExtractFileName($helpfile);
  1131. unless(opendir(DIR, $package_root_dir)) {
  1132. $! = "Couldn't read from package directory $package_root_dir";
  1133. return 0;
  1134. }
  1135. @files = readdir(DIR);
  1136. closedir(DIR);
  1137. @dirs = map {"$package_root_dir/$_"} grep {-d "$package_root_dir/$_" and /[^.]/} @files;
  1138. foreach $dir (@dirs) {
  1139. if(opendir(DIR, "$dir/blib/HtmlHelp")) {
  1140. @files = readdir(DIR);
  1141. closedir(DIR);
  1142. @hhcfiles = (@hhcfiles, grep {/\.hhc$/i} @files);
  1143. } else {
  1144. warn "Couldn't read / didn't add $dir/blib/HtmlHelp";
  1145. }
  1146. }
  1147. $CLEANUP = 0;
  1148. unless(MakeHelp($helpfile, $helpfile_dir, $helpfile_dir, @hhcfiles)) {
  1149. return 0;
  1150. }
  1151. 1;
  1152. }
  1153. #####################################################################
  1154. # FUNCTION MakePackages
  1155. # RECEIVES Name of directory containing the package dirs, which
  1156. # package directories in turn contain blib dirs.
  1157. # RETURNS None
  1158. # SETS Creates Html and HtmlHelp within the package dirs
  1159. # EXPECTS None, but there should be some pm files in blib, but
  1160. # it ignores it if there isn't
  1161. # PURPOSE Creates Html and HtmlHelp within the package dirs. We
  1162. # decided that we don't want to build the packages at
  1163. # the same time as the main htmlhelp, so this was
  1164. # needed to build them (Murray) at a different time and
  1165. # merge them in.
  1166. sub MakePackages {
  1167. my $package_root_dir = shift;
  1168. my (@files) = @_;
  1169. my $package_root_dir_mask;
  1170. my @package_dirs;
  1171. my $package_dir;
  1172. my @file;
  1173. my @dirs;
  1174. my $package_file;
  1175. my $podfile;
  1176. my $htmlfile;
  1177. my @package_file_list;
  1178. my @helphtmlfiles;
  1179. my $htmlfilecopy;
  1180. my $helpfile;
  1181. $CLEANUP = 0;
  1182. $package_root_dir =~ s{\\}{/}g;
  1183. $package_root_dir_mask = $package_root_dir;
  1184. if (!defined @files) {
  1185. unless(opendir(DIR, $package_root_dir)) {
  1186. $! = "Directory could not be opened $package_root_dir";
  1187. return 0;
  1188. }
  1189. @files = readdir(DIR);
  1190. closedir(DIR);
  1191. }
  1192. @dirs = grep {-d "$package_root_dir/$_" and /[^.]$/} @files;
  1193. @package_dirs = map {"$package_root_dir/$_"} @dirs;
  1194. foreach $package_dir (@package_dirs) {
  1195. @helphtmlfiles = ();
  1196. next if (!-d "$package_dir/blib");
  1197. print "Making help for $package_dir\n";
  1198. # Make room for the stuff
  1199. unless(-d "$package_dir/blib/HtmlHelp") {
  1200. unless(mkpath("$package_dir/blib/HtmlHelp")) {
  1201. $! = "Directory could not be created $package_dir/blib/HtmlHelp";
  1202. return 0;
  1203. }
  1204. }
  1205. unless(-d "$package_dir/blib/Html") {
  1206. unless(mkpath("$package_dir/blib/Html")) {
  1207. $! = "Directory could not be created $package_dir/blib/Html";
  1208. return 0;
  1209. }
  1210. }
  1211. unless(-d "$package_dir/blib/Html/lib") {
  1212. unless(mkpath("$package_dir/blib/Html/lib")) {
  1213. $! = "Directory could not be created $package_dir/blib/Html/lib";
  1214. return 0;
  1215. }
  1216. }
  1217. unless(-d "$package_dir/blib/Html/lib/site") {
  1218. unless(mkpath("$package_dir/blib/Html/lib/site")) {
  1219. $! = "Directory could not be created $package_dir/blib/Html/lib/site";
  1220. return 0;
  1221. }
  1222. }
  1223. # Make the structure under the html
  1224. unless(CopyDirStructure("$package_dir/blib/lib", "$package_dir/blib/Html/lib/site")) {
  1225. return 0;
  1226. }
  1227. # Get a list of all the files to be worked with
  1228. @package_file_list = GetFileListForPackage("$package_dir/blib/lib");
  1229. foreach $file (@package_file_list) {
  1230. print " ... found $file\n";
  1231. }
  1232. unless(@package_file_list) {
  1233. print " Nothing to do for this package\n";
  1234. next;
  1235. }
  1236. # Make the html
  1237. foreach $package_file (@package_file_list) {
  1238. unless(-d "$package_dir/blib/temp") {
  1239. unless(mkpath("$package_dir/blib/temp")) {
  1240. $! = "Directory could not be created $package_dir/blib/temp";
  1241. return 0;
  1242. }
  1243. }
  1244. $htmlfile = $package_file;
  1245. $htmlfile =~ s/\.(pm|pod)$/.html/i;
  1246. $htmlfile =~ s{/blib/lib/}{/blib/Html/lib/site/}i;
  1247. pod2html("--infile=$package_file", "--outfile=$htmlfile");
  1248. if (-e $htmlfile) {
  1249. unless(-d "$package_dir/blib/temp") {
  1250. unless(mkpath("$package_dir/blib/temp")) {
  1251. $! = "Directory could not be created $package_dir/blib/temp";
  1252. return 0;
  1253. }
  1254. }
  1255. $htmlfilecopy = $htmlfile;
  1256. $htmlfilecopy =~ s{.*/blib/html/}{}i;
  1257. $htmlfilecopy =~ s{/}{-}g;
  1258. copy($htmlfile, "$package_dir/blib/temp/$htmlfilecopy");
  1259. push(@helphtmlfiles, "$package_dir/blib/temp/$htmlfilecopy");
  1260. }
  1261. }
  1262. # Make the htmlhelp
  1263. $helpfile = basename($package_dir);
  1264. # $helpfile =~ s{$package_root_dir_mask/?}{};
  1265. $helpfile .= ".chm";
  1266. $helpfile = "pkg-" . $helpfile;
  1267. unless(MakeHelp($helpfile, "$package_dir/blib/temp",
  1268. "$package_dir/blib/temp", @helphtmlfiles))
  1269. {
  1270. return 0;
  1271. }
  1272. if (-e "$package_dir/blib/temp/$helpfile") {
  1273. copy("$package_dir/blib/temp/$helpfile",
  1274. "$package_dir/blib/HtmlHelp/$helpfile");
  1275. $hhcfile = $helpfile;
  1276. $hhcfile =~ s/\.chm$/.hhc/i;
  1277. if (-e "$package_dir/blib/temp/$hhcfile") {
  1278. copy("$package_dir/blib/temp/$hhcfile",
  1279. "$package_dir/blib/HtmlHelp/$hhcfile");
  1280. }
  1281. else {
  1282. warn("$package_dir/blib/temp/$hhcfile not found, "
  1283. ."file will not be included");
  1284. }
  1285. }
  1286. else {
  1287. warn("No help file was generated for "
  1288. ."$package_dir/blib/temp/$helpfile");
  1289. }
  1290. # Clean up the mess from making helpfiles, temp stuff and that
  1291. if (-d "$package_dir/blib/temp") {
  1292. if (opendir(DIR, "$package_dir/blib/temp")) {
  1293. unlink(map {"$package_dir/blib/temp/$_"}
  1294. grep {-f "$package_dir/blib/temp/$_"} readdir(DIR));
  1295. closedir(DIR);
  1296. unless (rmdir("$package_dir/blib/temp")) {
  1297. warn "Couldn't rmdir temp dir $package_dir/blib/temp\n";
  1298. }
  1299. }
  1300. else {
  1301. warn "Couldn't read/remove temp dir $package_dir/blib/temp\n";
  1302. }
  1303. }
  1304. }
  1305. 1;
  1306. }
  1307. #####################################################################
  1308. # FUNCTION CopyDirStructure
  1309. # RECEIVES From Directory, To Directory
  1310. # RETURNS 1 | 0
  1311. # SETS None
  1312. # EXPECTS None
  1313. # PURPOSE Copies the structure of the dir tree at and below
  1314. # the Source Directory (fromdir) to the Target
  1315. # Directory (todir). This does not copy files, just
  1316. # the directory structure.
  1317. sub CopyDirStructure {
  1318. my ($fromdir, $todir) = @_;
  1319. my @files;
  1320. my @dirs;
  1321. my $dir;
  1322. unless(opendir(DIR, $fromdir)) {
  1323. $! = "Couldn't read from directory $fromdir";
  1324. return 0;
  1325. }
  1326. @files = readdir(DIR);
  1327. @dirs = grep {
  1328. -d "$fromdir/$_" and /[^.]$/ and $_ !~ /auto$/i
  1329. } @files;
  1330. closedir(DIR);
  1331. foreach $dir (@dirs) {
  1332. #
  1333. # I could make it so that it only creates the directory if
  1334. # it has pod in it, but what about directories below THAT
  1335. # if it DOES have pod in it. That would be skipped. May want
  1336. # to do some kind of lookahead. Cutting out the auto more
  1337. # or less cuts out the problem though, right?
  1338. #
  1339. unless(-e "$todir/$dir") {
  1340. unless(mkpath("$todir/$dir")) {
  1341. $! = "Directory could not be created $todir/$dir";
  1342. return 0;
  1343. }
  1344. }
  1345. unless(CopyDirStructure("$fromdir/$dir", "$todir/$dir")) {
  1346. return 0;
  1347. }
  1348. }
  1349. 1;
  1350. }
  1351. #####################################################################
  1352. # FUNCTION GetFileListForPackage (recursive)
  1353. # RECEIVES Root directory
  1354. # RETURNS List of pod files contained in directories under root
  1355. # SETS None
  1356. # EXPECTS None
  1357. # PURPOSE For the packages build, this function searches a
  1358. # directory for pod files, and all directories through
  1359. # the tree beneath it. It returns the complete path
  1360. # and file name for all the pm or pod files it finds.
  1361. sub GetFileListForPackage {
  1362. my ($root) = @_;
  1363. my @podfiles;
  1364. my @dirs;
  1365. my $dir;
  1366. unless(opendir(DIR, $root)) {
  1367. $! = "Can't read from directory $root";
  1368. return undef;
  1369. }
  1370. @files = readdir(DIR);
  1371. closedir(DIR);
  1372. @podfiles = map {
  1373. "$root/$_"
  1374. } grep {
  1375. /\.pm/i or /\.pod/i
  1376. } @files;
  1377. @dirs = map {
  1378. "$root/$_"
  1379. } grep {
  1380. -d "$root/$_" and /[^.]$/ and $_ !~ /auto$/i
  1381. } @files;
  1382. foreach $dir (@dirs) {
  1383. @podfiles = (@podfiles, GetFileListForPackage("$dir"))
  1384. }
  1385. @podfiles;
  1386. }
  1387. #####################################################################
  1388. # FUNCTION CreateHHP
  1389. # RECEIVES help file name, project file name, toc file name,
  1390. # and a list of files to include
  1391. # RETURNS 1|0 for success
  1392. # SETS none
  1393. # EXPECTS none
  1394. # PURPOSE Creates the project file for the html help project.
  1395. sub CreateHHP {
  1396. my ($helpfile, $projfile, $tocfile, @files) = @_;
  1397. my $file;
  1398. my $chmfile;
  1399. my $first_html_file;
  1400. my ($shorthelpfile, $shortprojfile, $shorttocfile);
  1401. my ($shortfirstfile, $shortfile);
  1402. my @htmlfiles = grep {/\.html?$/i} @files;
  1403. my @hhcfiles = grep {/\.hhc$/i} @files;
  1404. $shorthelpfile = ExtractFileName($helpfile);
  1405. $shortprojfile = ExtractFileName($projfile);
  1406. $shorttocfile = ExtractFileName($tocfile);
  1407. $first_html_file = $htmlfiles[0];
  1408. unless(defined $first_html_file) {
  1409. warn "No default html file for $backhelp\n";
  1410. }
  1411. $shortfirstfile = ExtractFileName($first_html_file);
  1412. print "Creating $shortprojfile\n";
  1413. unless(open(HHP, ">$projfile")) {
  1414. $! = "Could not write project file";
  1415. return 0;
  1416. }
  1417. print HHP <<EOT;
  1418. [OPTIONS]
  1419. Compatibility=1.1
  1420. Compiled file=$shorthelpfile
  1421. Contents file=$shorttocfile
  1422. Display compile progress=Yes
  1423. EOT
  1424. if ($FULLTEXTSEARCH) {
  1425. print HHP "Full-text search=Yes\n";
  1426. }
  1427. print HHP <<EOT;
  1428. Language=0x409 English (United States)
  1429. Default topic=$shortfirstfile
  1430. [FILES]
  1431. EOT
  1432. foreach $file (@htmlfiles) {
  1433. $shortfile = ExtractFileName($file);
  1434. print HHP "$shortfile\n";
  1435. print " added $shortfile\n";
  1436. }
  1437. if(@hhcfiles) {
  1438. print HHP "\n";
  1439. print HHP "[MERGE FILES]\n";
  1440. foreach $file (@hhcfiles) {
  1441. $chmfile = $file;
  1442. $chmfile =~ s/\.hhc$/.chm/i;
  1443. $shortfile = ExtractFileName($chmfile);
  1444. print HHP "$shortfile\n";
  1445. print " added $shortfile\n";
  1446. }
  1447. if($MERGE_PACKAGES) {
  1448. print HHP "packages.chm\n";
  1449. print " ---> MERGED PACKAGES.CHM\n";
  1450. }
  1451. }
  1452. close(HHP);
  1453. return 1;
  1454. }
  1455. #####################################################################
  1456. # FUNCTION CreateHHC
  1457. # RECEIVES Helpfile name, TOC file name (HHC), list of files
  1458. # RETURNS 0 | 1
  1459. # SETS None
  1460. # EXPECTS None
  1461. # PURPOSE Creates the HHC (Table of Contents) file for the
  1462. # htmlhelp file to be created.
  1463. # NOTE This function is used (and abused) for every piece
  1464. # of the htmlhelp puzzle, so any change for one thing
  1465. # can break something totally unrelated. Be careful.
  1466. # This was the result of rapidly changing spex. In
  1467. # general, it's used for:
  1468. # @ Creating helpfiles from pod/pm
  1469. # @ Creating helpfiles from html
  1470. # @ Creating helpfiles from chm's and hhc's
  1471. # @ Creating child helpfiles from modules
  1472. # @ Creating main helpfiles
  1473. # @ Creating helpfile for core build
  1474. # @ Creating main for core build
  1475. # @ Creating package helpfiles for packages build
  1476. # @ Creating package main for package build
  1477. # @ General Htmlhelp file building other than AS
  1478. sub CreateHHC {
  1479. my ($helpfile, $tocfile, @files) = @_;
  1480. my $file;
  1481. my $title;
  1482. my $shorttoc;
  1483. my $shorthelp;
  1484. my $shortfile;
  1485. my $backfile;
  1486. my @libhhcs;
  1487. my @sitehhcs;
  1488. my @otherhhcs;
  1489. $helpfile =~ s{\\}{/}g;
  1490. $tocfile =~ s{\\}{/}g;
  1491. $shorttoc = ExtractFileName($tocfile);
  1492. $shorthelp = ExtractFileName($helpfile);
  1493. print "Creating $shorttoc\n";
  1494. unless(open(HHC, ">$tocfile")) {
  1495. $! = "Could not write contents file";
  1496. return 0;
  1497. }
  1498. print HHC <<'EOT';
  1499. <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
  1500. <HTML>
  1501. <HEAD>
  1502. <!-- Sitemap 1.0 -->
  1503. </HEAD>
  1504. <BODY>
  1505. <OBJECT type="text/site properties">
  1506. <param name="ImageType" value="Folder">
  1507. </OBJECT>
  1508. <UL>
  1509. EOT
  1510. foreach $file (grep {/\.html?$/i} @files) {
  1511. # don't want default.htm in the toc file
  1512. next if $file =~ /default\.html?$/i;
  1513. $file =~ s{\\}{/}g;
  1514. $title = $file;
  1515. $title =~ s{\.html$}{}i;
  1516. $title =~ s{.*/(.*)}{$1};
  1517. # Section added for packages build
  1518. # Note: this is an abuse of regexes but needed for all cases
  1519. $title =~ s/^pkg-//i;
  1520. # $title =~ s{(.*lib)$}{$1/}i;
  1521. $title =~ s{^lib-site-}{lib/site/}i;
  1522. $title =~ s{^lib-}{lib/}i;
  1523. $title =~ s{^site}{site/}i;
  1524. $title =~ s{^site-}{site/}i;
  1525. # $title =~ s{([^2])-([^x])}{${1}::${2}}ig;
  1526. $title =~ s{Win32-(?!x86)}{Win32::}ig;
  1527. #$backfile = BackSlash($file);
  1528. $shortfile = ExtractFileName($backfile);
  1529. print " adding ${shorthelp}::/${shortfile}\n";
  1530. print HHC <<EOT;
  1531. <LI> <OBJECT type="text/sitemap">
  1532. <param name="Name" value="$title">
  1533. <param name="Local" value="${shorthelp}::/${shortfile}">
  1534. </OBJECT>
  1535. EOT
  1536. }
  1537. foreach $file (sort(grep {/\.hhc$/i} @files)) {
  1538. if($file =~ /^lib-site-/i) {
  1539. push(@sitehhcs, $file);
  1540. } elsif($file =~ /lib-site\.hhc/i) {
  1541. unshift(@sitehhcs, $file);
  1542. } elsif($file =~ /^lib-/i) {
  1543. push(@libhhcs, $file);
  1544. } elsif($file =~ /lib\.hhc/i) {
  1545. unshift(@libhhcs, $file);
  1546. } else {
  1547. push(@otherhhcs, $file);
  1548. }
  1549. }
  1550. #
  1551. # The Lib merge files
  1552. #
  1553. if(@libhhcs) {
  1554. print HHC <<EOT;
  1555. <LI> <OBJECT type="text/sitemap">
  1556. <param name="Name" value="Core Libraries">
  1557. </OBJECT>
  1558. <UL>
  1559. EOT
  1560. foreach $file (@libhhcs) {
  1561. $file =~ s{\\}{/}g;
  1562. next if uc($shorttoc) eq uc($file);
  1563. # Note: this is an abuse of regexes but needed for all cases
  1564. $title = $file;
  1565. $title =~ s{^pkg-}{}i;
  1566. $title =~ s{\.hhc$}{}i;
  1567. $title =~ s{(.*lib)$}{$1/}i;
  1568. $title =~ s{^lib-site-}{lib/site/}i;
  1569. $title =~ s{^lib-}{lib/}i;
  1570. $title =~ s{^site}{site/}i;
  1571. $title =~ s{^site-}{site/}i;
  1572. # $title =~ s{([^2])-([^x])}{${1}::${2}}ig;
  1573. $title =~ s{Win32-(?!x86)}{Win32::}ig;
  1574. if ($title =~ m{^lib/$}i) { $title = "Main Libraries" }
  1575. $title =~ s{^lib/}{}i;
  1576. # $backfile = BackSlash($file);
  1577. $shortfile = ExtractFileName($backfile);
  1578. print " merging ${shortfile}\n";
  1579. print HHC <<EOT;
  1580. <LI> <OBJECT type="text/sitemap">
  1581. <param name="Name" value="$title">
  1582. </OBJECT>
  1583. <OBJECT type="text/sitemap">
  1584. <param name="Merge" value="${shortfile}">
  1585. </OBJECT>
  1586. EOT
  1587. }
  1588. print HHC "</UL>\n";
  1589. }
  1590. #
  1591. # The site merge files
  1592. #
  1593. if(@sitehhcs) {
  1594. print HHC <<'EOT';
  1595. <!--Beginning of site libraries-->
  1596. <LI> <OBJECT type="text/sitemap">
  1597. <param name="Name" value="Site Libraries">
  1598. </OBJECT>
  1599. <UL>
  1600. EOT
  1601. foreach $file (@sitehhcs) {
  1602. $file =~ s{\\}{/}g;
  1603. next if uc($shorttoc) eq uc($file);
  1604. # Note: this is an abuse of regexes but needed for all cases
  1605. $title = $file;
  1606. $title =~ s{^pkg-}{}i;
  1607. $title =~ s{\.hhc$}{}i;
  1608. $title =~ s{(.*lib)$}{$1/}i;
  1609. $title =~ s{^lib-site-}{lib/site/}i;
  1610. $title =~ s{^lib-}{lib/}i;
  1611. $title =~ s{^site}{site/}i;
  1612. $title =~ s{^site-}{site/}i;
  1613. # $title =~ s{([^2])-([^x])}{${1}::${2}}ig;
  1614. $title =~ s{Win32-(?!x86)}{Win32::}ig;
  1615. if ($title =~ m{^lib/site$}i) { $title = "Main Libraries" }
  1616. $title =~ s{^lib/site/}{}i;
  1617. # $backfile = BackSlash($file);
  1618. $shortfile = ExtractFileName($backfile);
  1619. print " merging ${shortfile}\n";
  1620. print HHC <<EOT
  1621. <LI> <OBJECT type="text/sitemap">
  1622. <param name="Name" value="$title">
  1623. </OBJECT>
  1624. <OBJECT type="text/sitemap">
  1625. <param name="Merge" value="${shortfile}">
  1626. </OBJECT>
  1627. EOT
  1628. }
  1629. print HHC "</UL>\n";
  1630. #
  1631. # quick fix: plop in the packages file
  1632. #
  1633. if($MERGE_PACKAGES) {
  1634. print HHC <<EOT;
  1635. <OBJECT type="text/sitemap">
  1636. <param name="Merge" value="packages.hhc">
  1637. </OBJECT>
  1638. EOT
  1639. }
  1640. print HHC "<!--End of site libraries-->\n";
  1641. }
  1642. #
  1643. # All the rest of the merge files
  1644. #
  1645. if(@otherhhcs) {
  1646. foreach $file (@otherhhcs) {
  1647. $file =~ s{\\}{/}g;
  1648. next if uc($shorttoc) eq uc($file);
  1649. # Note: this is an abuse of regexes but needed for all cases
  1650. $title = $file;
  1651. $title =~ s{^pkg-}{}i;
  1652. $title =~ s{\.hhc$}{}i;
  1653. $title =~ s{(.*lib)$}{$1/}i;
  1654. $title =~ s{^lib-site-}{lib/site/}i;
  1655. $title =~ s{^lib-}{lib/}i;
  1656. $title =~ s{^site}{site/}i;
  1657. $title =~ s{^site-}{site/}i;
  1658. # $title =~ s{([^2])-([^x])}{${1}::${2}}ig;
  1659. $title =~ s{Win32-(?!x86)}{Win32::}ig;
  1660. # $backfile = BackSlash($file);
  1661. $shortfile = ExtractFileName($backfile);
  1662. print " merging ${shortfile}\n";
  1663. print HHC <<EOT;
  1664. <LI> <OBJECT type="text/sitemap">
  1665. <param name="Name" value="$title">
  1666. </OBJECT>
  1667. <OBJECT type="text/sitemap">
  1668. <param name="Merge" value="${shortfile}">
  1669. </OBJECT>
  1670. EOT
  1671. }
  1672. }
  1673. # Close up shop and go home
  1674. print HHC "</UL>\n";
  1675. print HHC "</BODY></HTML>\n";
  1676. close(HHC);
  1677. 1;
  1678. }
  1679. #####################################################################
  1680. # FUNCTION CreateHHCFromHash
  1681. # RECEIVES Helpfile, HHC filename, and assoc array of files
  1682. # where keys are files and values are file titles
  1683. # RETURNS 1|0
  1684. # SETS None
  1685. # EXPECTS None
  1686. # PURPOSE Same as CreateHHC but allows for direct control over
  1687. # the file titles
  1688. sub CreateHHCFromHash {
  1689. my ($helpfile, $tocfile, %files) = @_;
  1690. my $file;
  1691. my $title;
  1692. my $shorttoc;
  1693. my $shorthelp;
  1694. my $backfile;
  1695. $shorttoc = $tocfile;
  1696. $shorttoc =~ s{.*/(.*)}{$1};
  1697. $shorthelp = $helpfile;
  1698. $shorthelp =~ s{.*/(.*)}{$1};
  1699. print "Creating $shorttoc\n";
  1700. unless(open(HHC, ">$tocfile")) {
  1701. $! = "Could not write contents file";
  1702. return 0;
  1703. }
  1704. print HHC <<'EOT';
  1705. <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
  1706. <HTML>
  1707. <HEAD>
  1708. <!-- Sitemap 1.0 -->
  1709. </HEAD>
  1710. <BODY>
  1711. <OBJECT type="text/site properties">
  1712. <param name="ImageType" value="Folder">
  1713. </OBJECT>
  1714. <UL>
  1715. EOT
  1716. while (($file,$title) = each %files) {
  1717. next unless $file =~ /\.html?/i;
  1718. # $backfile = BackSlash($file);
  1719. print HHC <<EOT;
  1720. <LI> <OBJECT type="text/sitemap">
  1721. <param name="Name" value="$title">
  1722. <param name="Local" value="$backfile">
  1723. </OBJECT>
  1724. EOT
  1725. }
  1726. while (($file,$title) = each %files) {
  1727. next if uc($shorttoc) eq uc($file);
  1728. next unless $file =~ /\.hhc/i;
  1729. # $backfile = BackSlash($file);
  1730. print HHC <<EOT;
  1731. <LI> <OBJECT type="text/sitemap">
  1732. <param name="Name" value="$title">
  1733. </OBJECT>
  1734. <OBJECT type="text/sitemap">
  1735. <param name="Merge" value="$backfile">
  1736. </OBJECT>
  1737. EOT
  1738. }
  1739. print HHC "</UL>\n";
  1740. print HHC "</BODY></HTML>\n";
  1741. close(HHC);
  1742. 1;
  1743. }
  1744. #####################################################################
  1745. # DO NOT REMOVE THE FOLLOWING LINE, IT IS NEEDED TO LOAD THIS LIBRARY
  1746. 1;