X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=ovsdb%2Fovsdb-doc.in;h=7b783e1a0414c9e29b329c3b30ec44133b844ae8;hb=7c00ccb6740ac240c7d50e3631b36553f47eb769;hp=6f77702c3329b4415512d470847014c7ec16eb78;hpb=3fd8d44544df9c4cdb6108a72154f7ebc5077dd0;p=sliver-openvswitch.git diff --git a/ovsdb/ovsdb-doc.in b/ovsdb/ovsdb-doc.in index 6f77702c3..7b783e1a0 100755 --- a/ovsdb/ovsdb-doc.in +++ b/ovsdb/ovsdb-doc.in @@ -16,9 +16,9 @@ argv0 = sys.argv[0] def textToNroff(s, font=r'\fR'): def escape(match): c = match.group(0) - if c == '-': - if font == r'\fB': - return r'\-' + if c.startswith('-'): + if c != '-' or font == r'\fB': + return '\\' + c else: return '-' if c == '\\': @@ -31,7 +31,7 @@ def textToNroff(s, font=r'\fR'): raise error.Error("bad escape") # Escape - \ " ' as needed by nroff. - s = re.sub('([-"\'\\\\])', escape, s) + s = re.sub('(-[0-9]|[-"\'\\\\])', escape, s) if s.startswith('.'): s = '\\' + s return s @@ -144,7 +144,8 @@ def blockXmlToNroff(nodes, para='.PP'): def typeAndConstraintsToNroff(column): type = column.type.toEnglish(escapeNroffLiteral) - constraints = column.type.constraintsToEnglish(escapeNroffLiteral) + constraints = column.type.constraintsToEnglish(escapeNroffLiteral, + textToNroff) if constraints: type += ", " + constraints if column.unique: @@ -174,8 +175,40 @@ def columnGroupToNroff(table, groupXml): column = table.columns[name] if node.hasAttribute('key'): key = node.attributes['key'].nodeValue + if node.hasAttribute('type'): + type_string = node.attributes['type'].nodeValue + type_json = ovs.json.from_string(str(type_string)) + if type(type_json) in (str, unicode): + raise error.Error("%s %s:%s has invalid 'type': %s" + % (table.name, name, key, type_json)) + type_ = ovs.db.types.BaseType.from_json(type_json) + else: + type_ = column.type.value + nameNroff = "%s : %s" % (name, key) - typeNroff = "optional %s" % column.type.value.toEnglish() + + if column.type.value: + typeNroff = "optional %s" % column.type.value.toEnglish( + escapeNroffLiteral) + if (column.type.value.type == ovs.db.types.StringType and + type_.type == ovs.db.types.BooleanType): + # This is a little more explicit and helpful than + # "containing a boolean" + typeNroff += r", either \fBtrue\fR or \fBfalse\fR" + else: + if type_.type != column.type.value.type: + type_english = type_.toEnglish() + if type_english[0] in 'aeiou': + typeNroff += ", containing an %s" % type_english + else: + typeNroff += ", containing a %s" % type_english + constraints = ( + type_.constraintsToEnglish(escapeNroffLiteral, + textToNroff)) + if constraints: + typeNroff += ", %s" % constraints + else: + typeNroff = "none" else: nameNroff = name typeNroff = typeAndConstraintsToNroff(column) @@ -245,9 +278,9 @@ def docsToNroff(schemaFile, xmlFile, erFile, title=None): . I "\\$1" . RE .. -''' % (title, d.strftime("%B %Y")) - - s += '.SH "%s DATABASE"\n' % schema.name +.SH NAME +%s \- %s database schema +''' % (title, d.strftime("%B %Y"), textToNroff(title), schema.name) tables = "" introNodes = [] @@ -287,7 +320,8 @@ Purpose if erFile: s += """ -.if !'\*[.T]'ascii' \{ +.\\" check if in troff mode (TTY) +.if t \{ .bp .SH "TABLE RELATIONSHIPS" .PP