commit b58a4d160ecbdde279f06d2ece052f67f9a60408
Author: Michael Hanselmann <hansmi@google.com>
Date:   Wed Jan 12 13:54:02 2011 +0100

    Fix typos in RAPI docstrings, add unittest
    
    This patch fixes a number of typos and standardizes RAPI resource
    docstrings. A unittest is added.
    
    Signed-off-by: Michael Hanselmann <hansmi@google.com>
    Reviewed-by: Iustin Pop <iustin@google.com>

diff --git a/lib/rapi/connector.py b/lib/rapi/connector.py
index ef03525..fceda6d 100644
--- a/lib/rapi/connector.py
+++ b/lib/rapi/connector.py
@@ -134,7 +134,9 @@ def _getResources(id_):
 
 
 class R_2(baserlib.R_Generic):
-  """ /2 resource, the root of the version 2 API.
+  """/2 resource.
+
+  This is the root of the version 2 API.
 
   """
   @staticmethod
diff --git a/lib/rapi/rlib2.py b/lib/rapi/rlib2.py
index 3ff2988..499f932 100644
--- a/lib/rapi/rlib2.py
+++ b/lib/rapi/rlib2.py
@@ -122,7 +122,7 @@ class R_version(baserlib.R_Generic):
 
 
 class R_2_info(baserlib.R_Generic):
-  """Cluster info.
+  """/2/info resource.
 
   """
   @staticmethod
@@ -329,7 +329,7 @@ class R_2_nodes(baserlib.R_Generic):
 
 
 class R_2_nodes_name(baserlib.R_Generic):
-  """/2/nodes/[node_name] resources.
+  """/2/nodes/[node_name] resource.
 
   """
   def GET(self):
@@ -470,7 +470,7 @@ class R_2_nodes_name_migrate(baserlib.R_Generic):
 
 
 class R_2_nodes_name_storage(baserlib.R_Generic):
-  """/2/nodes/[node_name]/storage ressource.
+  """/2/nodes/[node_name]/storage resource.
 
   """
   # LUQueryNodeStorage acquires locks, hence restricting access to GET
@@ -496,7 +496,7 @@ class R_2_nodes_name_storage(baserlib.R_Generic):
 
 
 class R_2_nodes_name_storage_modify(baserlib.R_Generic):
-  """/2/nodes/[node_name]/storage/modify ressource.
+  """/2/nodes/[node_name]/storage/modify resource.
 
   """
   def PUT(self):
@@ -526,7 +526,7 @@ class R_2_nodes_name_storage_modify(baserlib.R_Generic):
 
 
 class R_2_nodes_name_storage_repair(baserlib.R_Generic):
-  """/2/nodes/[node_name]/storage/repair ressource.
+  """/2/nodes/[node_name]/storage/repair resource.
 
   """
   def PUT(self):
@@ -594,7 +594,7 @@ class R_2_groups(baserlib.R_Generic):
 
 
 class R_2_groups_name(baserlib.R_Generic):
-  """/2/groups/[group_name] resources.
+  """/2/groups/[group_name] resource.
 
   """
   def GET(self):
@@ -670,7 +670,7 @@ def _ParseRenameGroupRequest(name, data, dry_run):
 
 
 class R_2_groups_name_rename(baserlib.R_Generic):
-  """/2/groups/[groupe_name]/rename resource.
+  """/2/groups/[group_name]/rename resource.
 
   """
   def PUT(self):
@@ -686,7 +686,7 @@ class R_2_groups_name_rename(baserlib.R_Generic):
 
 
 class R_2_groups_name_assign_nodes(baserlib.R_Generic):
-  """/2/groups/[groupe_name]/assign-nodes resource.
+  """/2/groups/[group_name]/assign-nodes resource.
 
   """
   def PUT(self):
@@ -912,7 +912,7 @@ class R_2_instances(baserlib.R_Generic):
 
 
 class R_2_instances_name(baserlib.R_Generic):
-  """/2/instances/[instance_name] resources.
+  """/2/instances/[instance_name] resource.
 
   """
   def GET(self):
@@ -1319,7 +1319,7 @@ class R_2_instances_name_modify(baserlib.R_Generic):
 
 
 class R_2_instances_name_disk_grow(baserlib.R_Generic):
-  """/2/instances/[instance_name]/disk/[index]/grow resource.
+  """/2/instances/[instance_name]/disk/[disk_index]/grow resource.
 
   """
   def POST(self):
@@ -1420,7 +1420,7 @@ class R_2_nodes_name_tags(_R_Tags):
 
 
 class R_2_tags(_R_Tags):
-  """ /2/instances/tags resource.
+  """ /2/tags resource.
 
   Manages cluster tags.
 
diff --git a/test/docs_unittest.py b/test/docs_unittest.py
index fbd31a0..87aa26d 100755
--- a/test/docs_unittest.py
+++ b/test/docs_unittest.py
@@ -72,7 +72,12 @@ class TestDocs(unittest.TestCase):
                  msg=("Missing documentation for hook %s/%s" %
                       (lucls.HTYPE, lucls.HPATH)))
 
-  def _CheckRapiResource(self, uri, fixup):
+  def _CheckRapiResource(self, uri, fixup, handler):
+    docline = "%s resource." % uri
+    self.assertEqual(handler.__doc__.splitlines()[0].strip(), docline,
+                     msg=("First line of %r's docstring is not %r" %
+                          (handler, docline)))
+
     # Apply fixes before testing
     for (rx, value) in fixup.items():
       uri = rx.sub(value, uri)
@@ -131,7 +136,7 @@ class TestDocs(unittest.TestCase):
           if title.startswith("``") and title.endswith("``"):
             uri = title[2:-2]
             if key.match(uri):
-              self._CheckRapiResource(uri, uri_check_fixup)
+              self._CheckRapiResource(uri, uri_check_fixup, handler)
               found = True
               break
 
@@ -144,7 +149,7 @@ class TestDocs(unittest.TestCase):
                      msg="Path %r does not start with '/2/'" % key)
 
         if ("``%s``" % key) in titles:
-          self._CheckRapiResource(key, {})
+          self._CheckRapiResource(key, {}, handler)
         else:
           undocumented.append(key)
 
