ovsdb-doc: Get manpage name from the XML file instead of command line.
authorBen Pfaff <blp@nicira.com>
Tue, 17 Feb 2015 23:52:54 +0000 (15:52 -0800)
committerBen Pfaff <blp@nicira.com>
Thu, 19 Feb 2015 18:57:52 +0000 (10:57 -0800)
This seems like a better place for it.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Gurucharan Shetty <gshetty@nicira.com>
ovsdb/ovsdb-doc
vswitchd/automake.mk
vswitchd/vswitch.xml
vtep/automake.mk
vtep/vtep.xml

index b670452..15618ef 100755 (executable)
@@ -264,7 +264,7 @@ def tableToNroff(schema, tableXml):
 
     return s
 
-def docsToNroff(schemaFile, xmlFile, erFile, title=None, version=None):
+def docsToNroff(schemaFile, xmlFile, erFile, version=None):
     schema = ovs.db.schema.DbSchema.from_json(ovs.json.from_file(schemaFile))
     doc = xml.dom.minidom.parse(xmlFile).documentElement
 
@@ -272,8 +272,10 @@ def docsToNroff(schemaFile, xmlFile, erFile, title=None, version=None):
     xmlDate = os.stat(xmlFile).st_mtime
     d = date.fromtimestamp(max(schemaDate, xmlDate))
 
-    if title == None:
-        title = schema.name
+    if doc.hasAttribute('name'):
+        manpage = doc.attributes['name'].nodeValue
+    else:
+        manpage = schema.name
 
     if version == None:
         version = "UNKNOWN"
@@ -297,7 +299,7 @@ def docsToNroff(schemaFile, xmlFile, erFile, title=None, version=None):
 .SH NAME
 %s \- %s database schema
 .PP
-''' % (title, schema.version, version, textToNroff(schema.name), schema.name)
+''' % (manpage, schema.version, version, textToNroff(manpage), schema.name)
 
     tables = ""
     introNodes = []
@@ -378,7 +380,6 @@ where SCHEMA is an OVSDB schema in JSON format
 
 The following options are also available:
   --er-diagram=DIAGRAM.PIC    include E-R diagram from DIAGRAM.PIC
-  --title=TITLE               use TITLE as title instead of schema name
   --version=VERSION           use VERSION to display on document footer
   -h, --help                  display this help message\
 """ % {'argv0': argv0}
@@ -388,20 +389,17 @@ if __name__ == "__main__":
     try:
         try:
             options, args = getopt.gnu_getopt(sys.argv[1:], 'hV',
-                                              ['er-diagram=', 'title=',
+                                              ['er-diagram=',
                                                'version=', 'help'])
         except getopt.GetoptError, geo:
             sys.stderr.write("%s: %s\n" % (argv0, geo.msg))
             sys.exit(1)
 
         er_diagram = None
-        title = None
         version = None
         for key, value in options:
             if key == '--er-diagram':
                 er_diagram = value
-            elif key == '--title':
-                title = value
             elif key == '--version':
                 version = value
             elif key in ['-h', '--help']:
@@ -415,7 +413,7 @@ if __name__ == "__main__":
             sys.exit(1)
 
         # XXX we should warn about undocumented tables or columns
-        s = docsToNroff(args[0], args[1], er_diagram, title, version)
+        s = docsToNroff(args[0], args[1], er_diagram, version)
         for line in s.split("\n"):
             line = line.strip()
             if len(line):
index 80affe9..2f07c0f 100644 (file)
@@ -48,7 +48,6 @@ vswitchd/ovs-vswitchd.conf.db.5: \
        ovsdb/ovsdb-doc vswitchd/vswitch.xml vswitchd/vswitch.ovsschema \
        $(VSWITCH_PIC)
        $(AM_V_GEN)$(OVSDB_DOC) \
-               --title="ovs-vswitchd.conf.db" \
                $(VSWITCH_DOT_DIAGRAM_ARG) \
                --version=$(VERSION) \
                $(srcdir)/vswitchd/vswitch.ovsschema \
index 04de3ca..c6516af 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
-<database title="Open vSwitch Configuration Database">
+<database name="ovs-vswitchd.conf.db" title="Open vSwitch Configuration Database">
   <p>
     A database with this schema holds the configuration for one Open
     vSwitch daemon.  The top-level configuration for the daemon is the
index eac81d0..a204d0a 100644 (file)
@@ -48,7 +48,6 @@ man_MANS += vtep/vtep.5
 vtep/vtep.5: \
        ovsdb/ovsdb-doc vtep/vtep.xml vtep/vtep.ovsschema $(VTEP_PIC)
        $(AM_V_GEN)$(OVSDB_DOC) \
-               --title="vtep" \
                $(VTEP_DOT_DIAGRAM_ARG) \
                --version=$(VERSION) \
                $(srcdir)/vtep/vtep.ovsschema \
index 7ed7f43..6199055 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
-<database title="Hardware VTEP Database">
+<database name="vtep" title="Hardware VTEP Database">
   <p>
     This schema specifies relations that a VTEP can use to integrate
     physical ports into logical switches maintained by a network