Sanitize option defaults in autogenerated config reference

This fixes a number of glitches in the default option values shown
in the docs, many of which involve exposing information about the
system where the docs were built. In particular:

* The hostname and IP address are changed to neutral defaults.
* Python's site-packages location is changed to a neutral default.
* Values where whitespace is significant are quoted, as they are
  in the sample config files.

Change-Id: Ie3dafd53d0b8c49998ed513c44c7d133c8eb90c5
This commit is contained in:
Shaun McCance 2014-01-17 10:28:02 -05:00
parent 721fcaa13d
commit 8f0654c8bc
1 changed files with 20 additions and 8 deletions

View File

@ -179,7 +179,7 @@ def write_docbook(package_name, options, verbose=0):
<th>Description</th>\n\
</tr>\n\
</thead>\n\
<tbody>')
<tbody>\n')
for optname in options_by_cat[cat]:
modname, group, option = options.get_option(optname)
if not option.help:
@ -187,13 +187,25 @@ def write_docbook(package_name, options, verbose=0):
if ((type(option).__name__ == "ListOpt") and (
option.default is not None)):
option.default = ", ".join(option.default)
groups_file.write('\n <tr>\n\
<td>' + option.name + ' = ' +
str(option.default) + '</td>\n\
<td>(' + type(option).__name__ + ') ' +
escape(option.help) + '</td>\n\
</tr>')
groups_file.write('\n </tbody>\n\
groups_file.write(' <tr>\n')
default = generator._sanitize_default(option.name,
str(option.default))
# This should be moved to generator._sanitize_default
for pathelm in sys.path:
if pathelm == '':
continue
if pathelm.endswith('/'):
pathelm = pathelm[:-1]
if default.startswith(pathelm):
default = default.replace(pathelm,
'/usr/lib/python/site-packages')
break
groups_file.write(' <td>%s = %s</td>\n' %
(option.name, default))
groups_file.write(' <td>(%s) %s</td>\n' %
(type(option).__name__, escape(option.help)))
groups_file.write(' </tr>\n')
groups_file.write(' </tbody>\n\
</table>\n\
</para>\n')
groups_file.close()