]> https://gitweb.dealii.org/ - dealii.git/commitdiff
validate xrefs again
authorGuido Kanschat <dr.guido.kanschat@gmail.com>
Tue, 14 Sep 2004 17:02:20 +0000 (17:02 +0000)
committerGuido Kanschat <dr.guido.kanschat@gmail.com>
Tue, 14 Sep 2004 17:02:20 +0000 (17:02 +0000)
git-svn-id: https://svn.dealii.org/trunk@9615 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/common/scripts/validate-xrefs.pl [new file with mode: 0644]
deal.II/doc/Makefile.in
deal.II/doc/development/Makefile
deal.II/doc/news/Makefile
deal.II/doc/publications/Makefile

diff --git a/deal.II/common/scripts/validate-xrefs.pl b/deal.II/common/scripts/validate-xrefs.pl
new file mode 100644 (file)
index 0000000..b0111f0
--- /dev/null
@@ -0,0 +1,116 @@
+# $Id$
+# Check whether references in HTML files are valid or 
+# point to non-existing files/links/etc
+#
+# Author: Wolfgang Bangerth, Guido Kanschat 2000, 2004
+
+#TODO: Th
+
+# set this to 1 if you want verbose output
+$debug = 0;
+
+$startdir = `pwd`;
+chop $startdir;
+
+foreach $filename (@ARGV)
+{
+    chdir $startdir || die "Could not change dir to $startdir\n";          
+    open IN, $filename
+        or die "---Can't open file `$filename'\n";
+    
+    print "File: $filename\n" if $debug;
+    if ($filename =~ m!(.+)/([^/]+)!)
+    {
+       chdir $1;
+       $filename = $2;
+    }
+    
+    while (<IN>) {
+        # first find all hrefs
+        while ( /<\s*a\s+href=\"?(.*?)[\s\"]/gi ) {
+           # then decide whether they are relevant for 
+            # our purpose
+           $link = $1;
+           
+           if ( $link =~ /^mailto|http:\/\//i ) {
+               # link is external. don't check it
+               print "external link: $link\n" if $debug;
+               next;
+           }
+           elsif ( $link =~ m/^#(.*)/ )
+               {
+                       # this is a reference within this file. try to 
+               # find its anchor
+               $internal_ref = $1;
+               print "internal reference: $link\n" if $debug;
+           
+               open IN2, $filename;
+               $found = 0;
+               while ( <IN2> ) {
+                   while ( /<a[^>]* name=\"?(.*?)[\s\"]/gi ) {
+                       if ( $1 eq $internal_ref) {
+                           print "                    found.\n" if $debug;
+                           $found = 1;
+                           last;
+                       }
+                   }
+               }
+               
+               die "---Internal reference `$internal_ref' not found in file $filename\n"
+                   unless $found;
+               next;
+           }
+           elsif ( $link =~ /^(.*?)#(.*)/ )
+           {
+               # this is a reference within another file. try to 
+               # find its anchor
+               $external_file = $1;
+               $external_ref = $2;
+
+               # if the file name was prepended with http: (but is a local file, 
+               # so no double-slash), then split off http:
+               $external_file =~ s/^http://g;
+
+               print "external reference: $link\n" if $debug;
+               
+               open IN2, $external_file;
+               $found = 0;
+               while ( <IN2> ) {
+                   while ( /<a[^>]* name=\"?(.*?)[\s\"]/gi ) {
+                       if ( $1 eq $external_ref) {
+                           print "                    found.\n" if $debug;
+                           $found = 1;
+                           last;
+                       }
+                   }
+               }
+               
+               die "---External reference `$external_file#$external_ref' not found in file $filename\n"
+                   unless $found;
+               next;
+           }
+           else {
+               # this must now be a regular file which is
+               # referenced. the file must be local
+
+               # if the file name was prepended with http: (but is a local file, 
+               # so no double-slash), then split off http:
+               $link =~ s/^http://g;
+
+               die "---Local file `$link' not found in file `$filename'\n"
+                   unless ((-r $link) && (-f $link));
+           }
+       }
+
+       # check whether references to images are valid
+       while ( /img\s+src=\"?(.*?)[\s\"]/gi ) {
+           # check whether the file for the image is present
+           $link = $1;
+
+           die "---Local image `$link' not found in file `$filename'\n"
+               unless ((-r $link) && (-f $link));
+       }
+   }
+}
+
+print "---- All local links found to be ok.\n";
index 815ec9e849de4f0d6a61ed9dc3e0b35a06a1480f..fafc8a58067ad45f9f7f2bd44c1388e6141dc6cc 100644 (file)
@@ -10,7 +10,7 @@ include $D/common/Make.global_options
 
 
 # generic targets
-default: doxygen tutorial development glossary # validate-xrefs
+default: doxygen tutorial development validate-xrefs
 
 all: default
 
@@ -31,10 +31,9 @@ glossary:
 
 validate-xrefs:
        @echo "Validating cross-references in HTML files."
-#      $(PERL) $D/doc/auto/scripts/validate-xrefs.pl *html
+       $(PERL) $D/common/scripts/validate-xrefs.pl *html doxygen/*/*.html
        cd tutorial ; $(MAKE) validate-xrefs
        cd development ; $(MAKE) validate-xrefs
-       cd glossary ; $(MAKE) validate-xrefs
        cd publications ; $(MAKE) validate-xrefs
        cd news ; $(MAKE) validate-xrefs
        cd reports ; $(MAKE) validate-xrefs
index 55a39865abab9f92dabba1abd192ce62268df3ac..e1a914837b97add469aa735c9475e0f23bdf908a 100644 (file)
@@ -82,7 +82,7 @@ makefile.rules.html: $D/common/Makefile.template
        @$(PERL) makefile2html < $< > $@
 
 validate-xrefs:
-       $(PERL) $D/doc/auto/scripts/validate-xrefs.pl \
+       @$(PERL) $D/common/scripts/validate-xrefs.pl \
                $(filter-out makefiles.1.html makefiles.2.html, \
                  $(shell echo *.html))
 
index d67a473fec14d2ef838360f3b12fc6f3f3d40da7..8b93429d800b9a77ed2c9ca8d38e9ed661508ebf 100644 (file)
@@ -6,8 +6,8 @@ include $D/common/Make.global_options
 
 
 validate-xrefs:
-       $(PERL) $D/doc/auto/scripts/validate-xrefs.pl *.html
-       for dir in 200* ; do cd $$dir ; $(MAKE) validate-xrefs ; cd .. ; done
+       @$(PERL) $D/common/scripts/validate-xrefs.pl *.html */*.html
+
 
 
 .PHONY: validate-xrefs
index 20ae806b1d7f460f0fee5ffcdabbfb6deda1fdaa..19b3b7b342620c90cf42e1d8d8bd70e0c5531207 100644 (file)
@@ -9,7 +9,7 @@ default:
 
 
 validate-xrefs:
-       $(PERL) $D/doc/auto/scripts/validate-xrefs.pl *.html
+       $(PERL) $D/common/scripts/validate-xrefs.pl *.html
 
 
 .PHONY: default validate-xrefs
\ No newline at end of file

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.