You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by jp...@apache.org on 2014/03/05 05:26:03 UTC

git commit: doc: script to check records.config documentation

Repository: trafficserver
Updated Branches:
  refs/heads/master d9ecf4f9e -> a7a51ecc1


doc: script to check records.config documentation


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/a7a51ecc
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/a7a51ecc
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/a7a51ecc

Branch: refs/heads/master
Commit: a7a51ecc190410c80fed7fce4f1f16039be027e3
Parents: d9ecf4f
Author: James Peach <jp...@apache.org>
Authored: Thu Feb 27 22:00:18 2014 -0800
Committer: James Peach <jp...@apache.org>
Committed: Tue Mar 4 20:25:12 2014 -0800

----------------------------------------------------------------------
 contrib/python/compare_RecordsConfigcc.py | 80 ++++++++++++++++++--------
 1 file changed, 56 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a7a51ecc/contrib/python/compare_RecordsConfigcc.py
----------------------------------------------------------------------
diff --git a/contrib/python/compare_RecordsConfigcc.py b/contrib/python/compare_RecordsConfigcc.py
index 24aeb6a..80c7412 100644
--- a/contrib/python/compare_RecordsConfigcc.py
+++ b/contrib/python/compare_RecordsConfigcc.py
@@ -18,6 +18,7 @@
 #
 import re
 import sys
+import string
 
 try:
     src_dir = sys.argv[1]
@@ -26,10 +27,6 @@ except IndexError:
     print "Compares values in RecordsConfig.cc with the default records.config file"
     sys.exit(1)
 
-cc_re = re.compile(r'\{RECT_(?:CONFIG|LOCAL), "([^"]+)", RECD_([A-Z]+), "([^"]+)",')
-cc_re_2 = re.compile(r'\{RECT_(?:CONFIG|LOCAL), "([^"]+)", RECD_([A-Z]+), (NULL),')
-in_re = re.compile(r'(?:CONFIG|LOCAL) (\S+)\s+(\S+)\s+(\S+)')
-
 # We expect these keys to differ between files, so ignore them
 ignore_keys = {
     "proxy.config.ssl.server.cert.path": 1,
@@ -49,34 +46,43 @@ ignore_keys = {
     "proxy.config.net.defer_accept": 1 # Specified in RecordsConfig.cc funny
 }
 
-# RecordsConfig.cc values
-rc_cc = {}
-# records.config.in values
-rc_in = {}
+rc_cc = {}  # RecordsConfig.cc values
+rc_in = {}  # records.config.in values
+rc_doc = {} # documented values
 
 # Process RecordsConfig.cc
-fh = open("%s/mgmt/RecordsConfig.cc" % src_dir)
-for line in fh:
-    m = cc_re.search(line)
-    if not m:
-        m = cc_re_2.search(line)
-    if m:
-        rc_cc[m.group(1)] = (m.group(2), m.group(3))
-
-fh.close()
+with open("%s/mgmt/RecordsConfig.cc" % src_dir) as fh:
+  cc_re = re.compile(r'\{RECT_(?:CONFIG|LOCAL), "([^"]+)", RECD_([A-Z]+), (.+?), ')
+  for line in fh:
+      m = cc_re.search(line)
+      if m:
+          value = m.group(3)
+          value = string.lstrip(value, '"')
+          value = string.rstrip(value, '"')
+          rc_cc[m.group(1)] = (m.group(2), value)
 
 # Process records.config.default.in
-fh = open("%s/proxy/config/records.config.default.in" % src_dir)
-for line in fh:
-    m = in_re.match(line)
-    if m:
-        rc_in[m.group(1)] = (m.group(2), m.group(3))
-fh.close()
+with open("%s/proxy/config/records.config.default.in" % src_dir) as fh:
+  in_re = re.compile(r'(?:CONFIG|LOCAL) (\S+)\s+(\S+)\s+(\S+)')
+  for line in fh:
+      m = in_re.match(line)
+      if m:
+          rc_in[m.group(1)] = (m.group(2), m.group(3))
+
+# Process records.comfig documentation.
+# eg. .. ts:cv:: CONFIG proxy.config.proxy_binary STRING traffic_server
+with open("%s/doc/reference/configuration/records.config.en.rst" % src_dir) as fh:
+  doc_re = re.compile(r'ts:cv:: CONFIG (\S+)\s+(\S+)\s+(\S+)')
+  for line in fh:
+      m = doc_re.search(line)
+      if m:
+          rc_doc[m.group(1)] = (m.group(2), m.group(3))
+          rc_doc[m.group(1)] = (m.group(2), m.group(3))
 
 # Compare the two
 # If a value is in RecordsConfig.cc  and not records.config.default.in, it is
 # ignored right now.
-print "# RecordsConfig.cc -> records.config.default.in"
+print "# Comparing RecordsConfig.cc -> records.config.default.in"
 for key in rc_in:
     if key in ignore_keys:
         continue
@@ -85,3 +91,29 @@ for key in rc_in:
         continue
     if rc_cc[key] != rc_in[key]:
         print "%s : %s -> %s" % (key, "%s %s" % rc_cc[key], "%s %s" % rc_in[key])
+
+# Search for undocumented variables ...
+missing = [ k for k in rc_cc if k not in rc_doc ]
+if len(missing) > 0:
+    print
+    print "Undocumented configuration variables:"
+    for m in sorted(missing):
+        print "\t%s %s" % (m, "%s %s" % rc_cc[m])
+
+# Search for incorrectly documented default values ...
+defaults = [ k for k in rc_cc if k in rc_doc and rc_cc[k] != rc_doc[k] ]
+if len(defaults) > 0:
+    print
+    print "Incorrectly documented defaults:"
+    for d in sorted(defaults):
+        print "\t%s %s -> %s" % (d, "%s %s" % rc_cc[d], "%s %s" % rc_doc[d])
+
+
+# Search for stale documentation ...
+stale = [ k for k in rc_doc if k not in rc_cc ]
+if (len(stale) > 0):
+    print
+    print "Stale documentation:"
+    for s in sorted(stale):
+        print "\t%s" %(s)
+