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 == '\\':
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
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:
nameNroff = "%s : %s" % (name, key)
if column.type.value:
- typeNroff = "optional %s" % column.type.value.toEnglish()
+ 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
else:
typeNroff += ", containing a %s" % type_english
constraints = (
- type_.constraintsToEnglish(escapeNroffLiteral))
+ type_.constraintsToEnglish(escapeNroffLiteral,
+ textToNroff))
if constraints:
typeNroff += ", %s" % constraints
else:
. 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 = []