aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2015-07-06 21:05:03 -0700
committerBen Pfaff <blp@nicira.com>2015-07-06 21:05:51 -0700
commit4d9d1d9e7248820fd192dfbc6780fc5f673594fc (patch)
tree1c506b0edc164f2ae082c5f70d730485419b4043
parent44648b0f08fecf237a3c71203a334dd5ee3f9cad (diff)
nroff: Fix style of names.
The recommended Google Python style is multi_word_names, not multiWordNames. There are lots of other places where the style could be improved. I started here because I was working in this code anyway and because this code is only used at build time and not installed, so that it can't break any third-party code. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Justin Pettit <jpettit@nicira.com>
-rwxr-xr-xbuild-aux/xml2nroff5
-rwxr-xr-xovsdb/ovsdb-doc24
-rw-r--r--python/build/nroff.py56
3 files changed, 43 insertions, 42 deletions
diff --git a/build-aux/xml2nroff b/build-aux/xml2nroff
index 1df195e59..1f8519a20 100755
--- a/build-aux/xml2nroff
+++ b/build-aux/xml2nroff
@@ -73,9 +73,10 @@ def manpage_to_nroff(xml_file, subst, version=None):
. I "\\$1"
. RE
..
-''' % (textToNroff(program), textToNroff(section), textToNroff(title), textToNroff(version))
+''' % (text_to_nroff(program), text_to_nroff(section),
+ text_to_nroff(title), text_to_nroff(version))
- s += blockXmlToNroff(doc.childNodes) + "\n"
+ s += block_xml_to_nroff(doc.childNodes) + "\n"
return s
diff --git a/ovsdb/ovsdb-doc b/ovsdb/ovsdb-doc
index 51b022b43..5cf26ee46 100755
--- a/ovsdb/ovsdb-doc
+++ b/ovsdb/ovsdb-doc
@@ -29,9 +29,9 @@ from build.nroff import *
argv0 = sys.argv[0]
def typeAndConstraintsToNroff(column):
- type = column.type.toEnglish(escapeNroffLiteral)
- constraints = column.type.constraintsToEnglish(escapeNroffLiteral,
- textToNroff)
+ type = column.type.toEnglish(escape_nroff_literal)
+ constraints = column.type.constraintsToEnglish(escape_nroff_literal,
+ text_to_nroff)
if constraints:
type += ", " + constraints
if column.unique:
@@ -53,7 +53,7 @@ def columnGroupToNroff(table, groupXml, documented_columns):
introNodes += [node]
summary = []
- intro = blockXmlToNroff(introNodes)
+ intro = block_xml_to_nroff(introNodes)
body = ''
for node in columnNodes:
if node.tagName == 'column':
@@ -76,7 +76,7 @@ def columnGroupToNroff(table, groupXml, documented_columns):
if column.type.value:
typeNroff = "optional %s" % column.type.value.toEnglish(
- escapeNroffLiteral)
+ escape_nroff_literal)
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
@@ -90,8 +90,8 @@ def columnGroupToNroff(table, groupXml, documented_columns):
else:
typeNroff += ", containing a %s" % type_english
constraints = (
- type_.constraintsToEnglish(escapeNroffLiteral,
- textToNroff))
+ type_.constraintsToEnglish(escape_nroff_literal,
+ text_to_nroff))
if constraints:
typeNroff += ", %s" % constraints
else:
@@ -102,14 +102,14 @@ def columnGroupToNroff(table, groupXml, documented_columns):
if not column.mutable:
typeNroff = "immutable %s" % typeNroff
body += '.IP "\\fB%s\\fR: %s"\n' % (nameNroff, typeNroff)
- body += blockXmlToNroff(node.childNodes, '.IP') + "\n"
+ body += block_xml_to_nroff(node.childNodes, '.IP') + "\n"
summary += [('column', nameNroff, typeNroff)]
elif node.tagName == 'group':
title = node.attributes["title"].nodeValue
subSummary, subIntro, subBody = columnGroupToNroff(
table, node, documented_columns)
summary += [('group', title, subSummary)]
- body += '.ST "%s:"\n' % textToNroff(title)
+ body += '.ST "%s:"\n' % text_to_nroff(title)
body += subIntro + subBody
else:
raise error.Error("unknown element %s in <table>" % node.tagName)
@@ -186,7 +186,7 @@ def docsToNroff(schemaFile, xmlFile, erFile, version=None):
.SH NAME
%s \- %s database schema
.PP
-''' % (manpage, schema.version, version, textToNroff(manpage), schema.name)
+''' % (manpage, schema.version, version, text_to_nroff(manpage), schema.name)
tables = ""
introNodes = []
@@ -212,7 +212,7 @@ def docsToNroff(schemaFile, xmlFile, erFile, version=None):
for table in undocumented_tables:
raise error.Error("undocumented table %s" % table)
- s += blockXmlToNroff(introNodes) + "\n"
+ s += block_xml_to_nroff(introNodes) + "\n"
s += r"""
.SH "TABLE SUMMARY"
@@ -228,7 +228,7 @@ Purpose
.TQ 1in
\fB%s\fR
%s
-""" % (name, textToNroff(title))
+""" % (name, text_to_nroff(title))
if erFile:
s += """
diff --git a/python/build/nroff.py b/python/build/nroff.py
index 078ec4b9a..68d2b4628 100644
--- a/python/build/nroff.py
+++ b/python/build/nroff.py
@@ -16,7 +16,7 @@ import re
from ovs.db import error
-def textToNroff(s, font=r'\fR'):
+def text_to_nroff(s, font=r'\fR'):
def escape(match):
c = match.group(0)
@@ -55,20 +55,20 @@ def textToNroff(s, font=r'\fR'):
s = re.sub('(-[0-9]|--|[-"\'\\\\.])', escape, s)
return s
-def escapeNroffLiteral(s, font=r'\fB'):
- return font + r'%s\fR' % textToNroff(s, font)
+def escape_nroff_literal(s, font=r'\fB'):
+ return font + r'%s\fR' % text_to_nroff(s, font)
-def inlineXmlToNroff(node, font, to_upper=False):
+def inline_xml_to_nroff(node, font, to_upper=False):
if node.nodeType == node.TEXT_NODE:
if to_upper:
- return textToNroff(node.data.upper(), font)
+ return text_to_nroff(node.data.upper(), font)
else:
- return textToNroff(node.data, font)
+ return text_to_nroff(node.data, font)
elif node.nodeType == node.ELEMENT_NODE:
if node.tagName in ['code', 'em', 'option', 'env']:
s = r'\fB'
for child in node.childNodes:
- s += inlineXmlToNroff(child, r'\fB')
+ s += inline_xml_to_nroff(child, r'\fB')
return s + font
elif node.tagName == 'ref':
s = r'\fB'
@@ -88,7 +88,7 @@ def inlineXmlToNroff(node, font, to_upper=False):
elif node.tagName == 'var' or node.tagName == 'dfn':
s = r'\fI'
for child in node.childNodes:
- s += inlineXmlToNroff(child, r'\fI')
+ s += inline_xml_to_nroff(child, r'\fI')
return s + font
else:
raise error.Error("element <%s> unknown or invalid here" % node.tagName)
@@ -101,15 +101,15 @@ def pre_to_nroff(nodes, para, font):
if node.nodeType != node.TEXT_NODE:
fatal("<pre> element may only have text children")
for line in node.data.split('\n'):
- s += escapeNroffLiteral(line, font) + '\n.br\n'
+ s += escape_nroff_literal(line, font) + '\n.br\n'
s += '.fi\n'
return s
-def blockXmlToNroff(nodes, para='.PP'):
+def block_xml_to_nroff(nodes, para='.PP'):
s = ''
for node in nodes:
if node.nodeType == node.TEXT_NODE:
- s += textToNroff(node.data)
+ s += text_to_nroff(node.data)
s = s.lstrip()
elif node.nodeType == node.ELEMENT_NODE:
if node.tagName in ['ul', 'ol']:
@@ -117,17 +117,17 @@ def blockXmlToNroff(nodes, para='.PP'):
s += "\n"
s += ".RS\n"
i = 0
- for liNode in node.childNodes:
- if (liNode.nodeType == node.ELEMENT_NODE
- and liNode.tagName == 'li'):
+ for li_node in node.childNodes:
+ if (li_node.nodeType == node.ELEMENT_NODE
+ and li_node.tagName == 'li'):
i += 1
if node.tagName == 'ul':
s += ".IP \\(bu\n"
else:
s += ".IP %d. .25in\n" % i
- s += blockXmlToNroff(liNode.childNodes, ".IP")
- elif (liNode.nodeType != node.TEXT_NODE
- or not liNode.data.isspace()):
+ s += block_xml_to_nroff(li_node.childNodes, ".IP")
+ elif (li_node.nodeType != node.TEXT_NODE
+ or not li_node.data.isspace()):
raise error.Error("<%s> element may only have <li> children" % node.tagName)
s += ".RE\n"
elif node.tagName == 'dl':
@@ -135,30 +135,30 @@ def blockXmlToNroff(nodes, para='.PP'):
s += "\n"
s += ".RS\n"
prev = "dd"
- for liNode in node.childNodes:
- if (liNode.nodeType == node.ELEMENT_NODE
- and liNode.tagName == 'dt'):
+ for li_node in node.childNodes:
+ if (li_node.nodeType == node.ELEMENT_NODE
+ and li_node.tagName == 'dt'):
if prev == 'dd':
s += '.TP\n'
else:
s += '.TQ .5in\n'
prev = 'dt'
- elif (liNode.nodeType == node.ELEMENT_NODE
- and liNode.tagName == 'dd'):
+ elif (li_node.nodeType == node.ELEMENT_NODE
+ and li_node.tagName == 'dd'):
if prev == 'dd':
s += '.IP\n'
prev = 'dd'
- elif (liNode.nodeType != node.TEXT_NODE
- or not liNode.data.isspace()):
+ elif (li_node.nodeType != node.TEXT_NODE
+ or not li_node.data.isspace()):
raise error.Error("<dl> element may only have <dt> and <dd> children")
- s += blockXmlToNroff(liNode.childNodes, ".IP")
+ s += block_xml_to_nroff(li_node.childNodes, ".IP")
s += ".RE\n"
elif node.tagName == 'p':
if s != "":
if not s.endswith("\n"):
s += "\n"
s += para + "\n"
- s += blockXmlToNroff(node.childNodes, para)
+ s += block_xml_to_nroff(node.childNodes, para)
elif node.tagName in ('h1', 'h2', 'h3'):
if s != "":
if not s.endswith("\n"):
@@ -166,7 +166,7 @@ def blockXmlToNroff(nodes, para='.PP'):
nroffTag = {'h1': 'SH', 'h2': 'SS', 'h3': 'ST'}[node.tagName]
s += '.%s "' % nroffTag
for child_node in node.childNodes:
- s += inlineXmlToNroff(child_node, r'\fR',
+ s += inline_xml_to_nroff(child_node, r'\fR',
to_upper=(nroffTag == 'SH'))
s += '"\n'
elif node.tagName == 'pre':
@@ -177,7 +177,7 @@ def blockXmlToNroff(nodes, para='.PP'):
font = r'\fB'
s += pre_to_nroff(node.childNodes, para, font)
else:
- s += inlineXmlToNroff(node, r'\fR')
+ s += inline_xml_to_nroff(node, r'\fR')
else:
raise error.Error("unknown node %s in block xml" % node)
if s != "" and not s.endswith('\n'):