diff make/doclinkcheck.py @ 25:fe01baf8e2a0

Fix a bug (the attempt to filter out index.html from the list of files nothing links to was looking at the wrong variable), and add comments.
author Rob Landley <rob@landley.net>
date Mon, 13 Aug 2007 16:25:58 -0500
parents 8dc7c0651c06
children
line wrap: on
line diff
--- a/make/doclinkcheck.py	Fri Aug 10 15:43:28 2007 -0500
+++ b/make/doclinkcheck.py	Mon Aug 13 16:25:58 2007 -0500
@@ -2,13 +2,17 @@
 
 import os,sys
 
+# Get a list of files under the Documentation directory,
+# filtering out instances of index.html
+
 dirlist = []
 for i in os.walk("Documentation"):
   for j in i[1]: dirlist.append("%s/%s/" % (i[0], j))
   for j in i[2]:
-    if i!="index.html": dirlist.append("%s/%s" % (i[0], j))
+    if j!="index.html": dirlist.append("%s/%s" % (i[0], j))
 dirlist.sort()
 
+# Function to parse a relative link and append it to a list.
 taglist = []
 def handletag(path, tag, data):
   tag = tag.split()
@@ -19,6 +23,9 @@
         if i[0]=='"' and i[-1]=='"': i=i[1:-1]
         taglist.append("%s/%s" % (path, i))
 
+# Find all the index.html files under Documentation, read each one,
+# iterate through the html tags and call handletag() for each.
+
 for dir in os.walk("Documentation"):
   if "index.html" in dir[2]:
     data = open("%s/index.html" % dir[0]).read()
@@ -26,9 +33,8 @@
     for i in data:
       i = i.split(">")
       handletag(dir[0], i[0], i[1])
-      #if len(i)<2 or len(i[0])<2: continue
-      #if i[0][0]=="h" and i[0][1].isdigit():
 
+# Display the links with no files, and the files nothing linked to.
 print "404 errors:"
 for i in filter(lambda a: a not in dirlist, taglist): print i
 print "Unlinked documents:"