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
1114d5c161
commit
bde286751d
|
@ -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 = {}
|
||||
|
||||
|
@ -472,8 +474,11 @@ 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()
|
||||
|
||||
_prefix = 'DEPRECATED'
|
||||
helptext = option.help.strip()
|
||||
helptext = helptext[
|
||||
helptext.startswith(_prefix) and len(_prefix):].lstrip(': ')
|
||||
helptext = re.sub(r'\n+\s*\* ', '$sentinal$* ', helptext)
|
||||
helptext = helptext.replace('\n\n', '$sentinal$')
|
||||
helptext = helptext.replace('\n', ' ')
|
||||
|
@ -481,18 +486,19 @@ 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()
|
||||
deprecated_reason = ' '.join([x.strip() for x in (
|
||||
option.deprecated_reason or '').split('\n')])
|
||||
|
||||
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 +512,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