Permalink
Browse files

Adds script to check links, and fixes a number of detected issues

git-svn-id: svn://cherokee-project.com/cherokee/trunk@6311 5dc97367-97f1-0310-9951-d761b3857238
  • Loading branch information...
1 parent 73c0628 commit 4bf9deab5a8be74b6bfbbb4872d0b49725d2d56f taher committed Feb 16, 2011
Showing with 75 additions and 5 deletions.
  1. +6 −1 doc/Makefile.am
  2. +0 −2 doc/config_wizards.txt
  3. +2 −2 doc/modules_balancers.txt
  4. +67 −0 doc/test_links.py
View
@@ -122,13 +122,16 @@ other_bundle_cherokee-admin.html \
other_bundle_cherokee-config.html \
other_bundle_cherokee-tweak.html \
other_bundle_cherokee-worker.html \
+other_bundle_cherokee-admin-launcher.html \
other_bundle_cget.html \
dev.html \
dev_debug.html \
dev_cherokee.conf.html \
dev_issues.html \
dev_qa.html \
-dev_quickstart.html
+dev_quickstart.html \
+dev_api.html \
+dev_examples.html
docmediacssdir = $(docdir)/media/css/
docmediacss_DATA = \
@@ -276,9 +279,11 @@ $(doc_DATA) \
$(docmediacss_DATA) \
$(docmediaimages_DATA) \
test_images.py
+test_links.py
serve:
../cherokee/cherokee -r .
test:
./test_images.py
+ ./test_links.py
View
@@ -80,8 +80,6 @@ Available Wizards
* MediaWiki: Free wiki engine written in PHP for use in Wikipedia.
-* link:cookbook_moinmoin.html[MoinMoin]: Python Wiki enginge.
-
* link:cookbook_mono.html[Mono.NET]: .NET open source framework.
* link:cookbook_moodle.html[Moodle]: Course Management System.
@@ -1,4 +1,4 @@
-== link:index.html[Index] -> link:modules.html[Modules]
+m t== link:index.html[Index] -> link:modules.html[Modules]
Modules: Balancers
------------------
@@ -32,5 +32,5 @@ And these are the handlers that use balancing:
* link:modules_handlers_fcgi.html[FastCGI]
* link:modules_handlers_scgi.html[SCGI]
-* link:modules_handlers_wsgi.html[uWSGI]
+* link:modules_handlers_uwsgi.html[uWSGI]
* link:modules_handlers_dbslayer.html[MySQL bridge]
View
@@ -0,0 +1,67 @@
+#!/usr/bin/env python
+
+# Cherokee Doc: Link checker
+#
+# Authors:
+# Taher Shihadeh <taher@unixwars.com>
+#
+# Copyright (C) 2001-2011 Alvaro Lopez Ortega
+# This file is distributed under the GPL2 license.
+
+import os
+import sys
+import re
+
+def get_link_refs():
+ link_refs = {}
+ for f in filter(lambda x: x.endswith('.txt'), os.listdir('.')):
+ tmp = re.findall ('link:([^#].+?)(#.*?)?\[', open(f, 'r').read(), re.M)
+ for ref in tmp:
+ link_refs[ref[0]] = True
+ return link_refs.keys()
+
+def get_txt_refs (link_refs):
+ def is_txt (x):
+ if not ('://' in x or x.startswith('mailto:')):
+ return True
+
+ refs = filter(is_txt, link_refs)
+ return [x.replace('.html', '.txt') for x in refs]
+
+def check_links():
+ error = False
+
+ refs = get_link_refs()
+ link_refs = [x for x in refs if x.startswith('http')]
+ txt_refs = get_txt_refs (refs)
+ txt_files = filter(lambda x: x.endswith('.txt'), os.listdir('.'))
+
+ for ref in txt_refs:
+ if not ref in txt_files:
+ print "ERROR: %s: File not found" %(ref)
+ error = True
+
+ for txt in txt_files:
+ if not txt in txt_refs:
+ print "ERROR: %s: No longer used" %(txt)
+ error = True
+
+ automake_am = open("Makefile.am", 'r').read()
+ for txt in txt_refs:
+ if not txt.replace('.txt', '.html') in automake_am:
+ print "ERROR: %s isn't covered in Makefile.am " %(txt)
+ error = True
+
+ # TODO: check if link_refs are still accessible.
+
+ return error
+
+if __name__ == "__main__":
+ # Exit if .txt files are not included
+ if not filter (lambda x: x.endswith('.txt'), os.listdir('.')):
+ print "Nothing to check.."
+ raise SystemExit
+
+ # Test
+ error = check_links()
+ sys.exit(int(error))

0 comments on commit 4bf9dea

Please sign in to comment.