Mercurial > hg > kdocs
comparison make/doclinkcheck.py @ 21:8dc7c0651c06
Link checker for Documentation, shows 404 errors and files not linked to.
author | Rob Landley <rob@landley.net> |
---|---|
date | Thu, 09 Aug 2007 22:16:32 -0500 |
parents | |
children | fe01baf8e2a0 |
comparison
equal
deleted
inserted
replaced
20:8e9357f5cb1b | 21:8dc7c0651c06 |
---|---|
1 #!/usr/bin/python | |
2 | |
3 import os,sys | |
4 | |
5 dirlist = [] | |
6 for i in os.walk("Documentation"): | |
7 for j in i[1]: dirlist.append("%s/%s/" % (i[0], j)) | |
8 for j in i[2]: | |
9 if i!="index.html": dirlist.append("%s/%s" % (i[0], j)) | |
10 dirlist.sort() | |
11 | |
12 taglist = [] | |
13 def handletag(path, tag, data): | |
14 tag = tag.split() | |
15 if tag[0]=="a": | |
16 for i in tag: | |
17 if i.startswith("href="): | |
18 i = i[5:] | |
19 if i[0]=='"' and i[-1]=='"': i=i[1:-1] | |
20 taglist.append("%s/%s" % (path, i)) | |
21 | |
22 for dir in os.walk("Documentation"): | |
23 if "index.html" in dir[2]: | |
24 data = open("%s/index.html" % dir[0]).read() | |
25 data = data.split("<")[1:] | |
26 for i in data: | |
27 i = i.split(">") | |
28 handletag(dir[0], i[0], i[1]) | |
29 #if len(i)<2 or len(i[0])<2: continue | |
30 #if i[0][0]=="h" and i[0][1].isdigit(): | |
31 | |
32 print "404 errors:" | |
33 for i in filter(lambda a: a not in dirlist, taglist): print i | |
34 print "Unlinked documents:" | |
35 for i in filter(lambda a: a not in taglist, dirlist): print i |