Skip to content

Commit

Permalink
ovsdb-doc: Get manpage name from the XML file instead of command line.
Browse files Browse the repository at this point in the history
This seems like a better place for it.

Signed-off-by: Ben Pfaff <[email protected]>
Acked-by: Gurucharan Shetty <[email protected]>
  • Loading branch information
blp committed Feb 19, 2015
1 parent a826ac9 commit 57ba0a7
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 14 deletions.
18 changes: 8 additions & 10 deletions ovsdb/ovsdb-doc
Original file line number Diff line number Diff line change
Expand Up @@ -264,16 +264,18 @@ 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

schemaDate = os.stat(schemaFile).st_mtime
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"
Expand All @@ -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 = []
Expand Down Expand Up @@ -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}
Expand All @@ -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']:
Expand All @@ -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):
Expand Down
1 change: 0 additions & 1 deletion vswitchd/automake.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
2 changes: 1 addition & 1 deletion vswitchd/vswitch.xml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 0 additions & 1 deletion vtep/automake.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
2 changes: 1 addition & 1 deletion vtep/vtep.xml
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 57ba0a7

Please sign in to comment.