installdox 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. #!/usr/bin/perl
  2. %subst = ( );
  3. $quiet = 0;
  4. while ( @ARGV ) {
  5. $_ = shift @ARGV;
  6. if ( s/^-// ) {
  7. if ( /^l(.*)/ ) {
  8. $v = ($1 eq "") ? shift @ARGV : $1;
  9. ($v =~ /\/$/) || ($v .= "/");
  10. $_ = $v;
  11. if ( /(.+)\@(.+)/ ) {
  12. if ( exists $subst{$1} ) {
  13. $subst{$1} = $2;
  14. } else {
  15. print STDERR "Unknown tag file $1 given with option -l\n";
  16. &usage();
  17. }
  18. } else {
  19. print STDERR "Argument $_ is invalid for option -l\n";
  20. &usage();
  21. }
  22. }
  23. elsif ( /^q/ ) {
  24. $quiet = 1;
  25. }
  26. elsif ( /^\?|^h/ ) {
  27. &usage();
  28. }
  29. else {
  30. print STDERR "Illegal option -$_\n";
  31. &usage();
  32. }
  33. }
  34. else {
  35. push (@files, $_ );
  36. }
  37. }
  38. foreach $sub (keys %subst)
  39. {
  40. if ( $subst{$sub} eq "" )
  41. {
  42. print STDERR "No substitute given for tag file `$sub'\n";
  43. &usage();
  44. }
  45. elsif ( ! $quiet && $sub ne "_doc" && $sub ne "_cgi" )
  46. {
  47. print "Substituting $subst{$sub} for each occurrence of tag file $sub\n";
  48. }
  49. }
  50. if ( ! @files ) {
  51. if (opendir(D,".")) {
  52. foreach $file ( readdir(D) ) {
  53. $match = ".html";
  54. next if ( $file =~ /^\.\.?$/ );
  55. ($file =~ /$match/) && (push @files, $file);
  56. ($file =~ /\.svg/) && (push @files, $file);
  57. ($file =~ "navtree.js") && (push @files, $file);
  58. }
  59. closedir(D);
  60. }
  61. }
  62. if ( ! @files ) {
  63. print STDERR "Warning: No input files given and none found!\n";
  64. }
  65. foreach $f (@files)
  66. {
  67. if ( ! $quiet ) {
  68. print "Editing: $f...\n";
  69. }
  70. $oldf = $f;
  71. $f .= ".bak";
  72. unless (rename $oldf,$f) {
  73. print STDERR "Error: cannot rename file $oldf\n";
  74. exit 1;
  75. }
  76. if (open(F,"<$f")) {
  77. unless (open(G,">$oldf")) {
  78. print STDERR "Error: opening file $oldf for writing\n";
  79. exit 1;
  80. }
  81. if ($oldf ne "tree.js") {
  82. while (<F>) {
  83. s/doxygen\=\"([^ \"\:\t\>\<]*)\:([^ \"\t\>\<]*)\" (xlink:href|href|src)=\"\2/doxygen\=\"$1:$subst{$1}\" \3=\"$subst{$1}/g;
  84. print G "$_";
  85. }
  86. }
  87. else {
  88. while (<F>) {
  89. s/\"([^ \"\:\t\>\<]*)\:([^ \"\t\>\<]*)\", \"\2/\"$1:$subst{$1}\" ,\"$subst{$1}/g;
  90. print G "$_";
  91. }
  92. }
  93. }
  94. else {
  95. print STDERR "Warning file $f does not exist\n";
  96. }
  97. unlink $f;
  98. }
  99. sub usage {
  100. print STDERR "Usage: installdox [options] [html-file [html-file ...]]\n";
  101. print STDERR "Options:\n";
  102. print STDERR " -l tagfile\@linkName tag file + URL or directory \n";
  103. print STDERR " -q Quiet mode\n\n";
  104. exit 1;
  105. }