Include 'deprecation' as a flag
There is support for displaying deprecation information in a somewhat structured manner (proper lists, emphasis on titles, etc.). However, the deprecation information is still included in the help text rather than in this flags section. This makes things more difficult than they need to be. Resolve this by instead including any deprecation information in the flags section. This will transform output from something like this: (String) DEPRECATED: Host to locate redis. Replaced by [DEFAULT]/transport_url to this: (String) Host to locate redis. Deprecated Replaced by [DEFAULT]/transport_url Which should be a little more obvious. Change-Id: Ifaee90a814fa3efee8b41eb0411535cff70e7309
This commit is contained in:
parent
aeddde174e
commit
1518069a8b
|
@ -390,6 +390,8 @@ def pass_through(line):
|
|||
line.startswith('#'))
|
||||
|
||||
|
||||
# TODO(stephenfin): Remove this feature. We no longer need it now that
|
||||
# oslo.config supports 'group's
|
||||
def _get_options_by_cat(package_name):
|
||||
options_by_cat = {}
|
||||
|
||||
|
@ -421,6 +423,12 @@ def _get_category_names(package_name):
|
|||
return category_names
|
||||
|
||||
|
||||
def _remove_prefix(text, prefix):
|
||||
if text.startswith(prefix):
|
||||
return text[len(prefix):]
|
||||
return text
|
||||
|
||||
|
||||
def write_files(package_name, options, target, output_format):
|
||||
"""Write tables.
|
||||
|
||||
|
@ -472,8 +480,8 @@ def write_files(package_name, options, target, output_format):
|
|||
if not option.help:
|
||||
option.help = "No help text available for this option."
|
||||
|
||||
helptext = option.help.strip()
|
||||
|
||||
helptext = _remove_prefix(
|
||||
option.help.strip(), 'DEPRECATED').lstrip(':')
|
||||
helptext = re.sub(r'\n+\s*\* ', '$sentinal$* ', helptext)
|
||||
helptext = helptext.replace('\n\n', '$sentinal$')
|
||||
helptext = helptext.replace('\n', ' ')
|
||||
|
@ -481,18 +489,24 @@ def write_files(package_name, options, target, output_format):
|
|||
# TODO(johngarbutt) space matches only the current template :(
|
||||
helptext = helptext.replace('$sentinal$', '\n\n ')
|
||||
|
||||
if option.deprecated_for_removal:
|
||||
if not option.help.strip().startswith('DEPRECATED'):
|
||||
helptext = 'DEPRECATED: ' + helptext
|
||||
if getattr(option, 'deprecated_reason', None):
|
||||
helptext += ' '
|
||||
helptext += option.deprecated_reason.lstrip().rstrip()
|
||||
if not option.deprecated_reason:
|
||||
option.deprecated_reason = (
|
||||
'No deprecation reason provided for this option.')
|
||||
|
||||
deprecated_reason = ' '.join([
|
||||
x.strip() for x in
|
||||
option.deprecated_reason.split('\n')]).strip()
|
||||
|
||||
opt_type = _TYPE_DESCRIPTIONS.get(type(option), 'Unknown')
|
||||
|
||||
flags = []
|
||||
if (option.deprecated_for_removal or
|
||||
option.help.startswith('DEPRECATED')):
|
||||
flags.append(('Deprecated', deprecated_reason))
|
||||
if option.mutable:
|
||||
flags.append(('Mutable', 'This option can be changed without'
|
||||
' restarting.'))
|
||||
|
||||
item = (option.dest,
|
||||
_sanitize_default(option),
|
||||
"(%s) %s" % (opt_type, helptext),
|
||||
|
@ -506,6 +520,8 @@ def write_files(package_name, options, target, output_format):
|
|||
file_path = ("%(target)s/%(package_name)s-%(cat)s.%(ext)s" %
|
||||
{'target': target, 'package_name': package_name,
|
||||
'cat': cat, 'ext': ext})
|
||||
# TODO(stephenfin): This template should be using definition lists
|
||||
# rather than multiple tables
|
||||
tmpl_file = os.path.join(os.path.dirname(__file__),
|
||||
'templates/autohelp.%s.j2' % output_format)
|
||||
with open(tmpl_file) as fd:
|
||||
|
|
Loading…
Reference in New Issue