extract_swift_flags: Remove '--from' argument
There's no reason to keep this around now that all Swift docs have been converted to rST. Change-Id: Ie9eb561394625509895420eb665523110b264a8e
This commit is contained in:
parent
80d376e08e
commit
6d6f122209
|
@ -22,7 +22,6 @@ from docutils import core
|
||||||
from docutils import io
|
from docutils import io
|
||||||
from docutils import nodes
|
from docutils import nodes
|
||||||
import jinja2
|
import jinja2
|
||||||
from lxml import etree
|
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
|
|
||||||
from autohelp import OptionsCache # noqa
|
from autohelp import OptionsCache # noqa
|
||||||
|
@ -34,8 +33,6 @@ from autohelp import OptionsCache # noqa
|
||||||
# and generally only having a single entry
|
# and generally only having a single entry
|
||||||
# after the equals (the default value)
|
# after the equals (the default value)
|
||||||
|
|
||||||
DBK_NS = ".//{http://docbook.org/ns/docbook}"
|
|
||||||
|
|
||||||
|
|
||||||
def parse_line(line):
|
def parse_line(line):
|
||||||
"""Parse a line.
|
"""Parse a line.
|
||||||
|
@ -60,7 +57,7 @@ def parse_line(line):
|
||||||
return config, default.strip()
|
return config, default.strip()
|
||||||
|
|
||||||
|
|
||||||
def get_existing_options_from_rst(optfiles):
|
def get_existing_options(optfiles):
|
||||||
"""Parse an existing RST table to compile a list of existing options."""
|
"""Parse an existing RST table to compile a list of existing options."""
|
||||||
options = {}
|
options = {}
|
||||||
for optfile in optfiles:
|
for optfile in optfiles:
|
||||||
|
@ -86,29 +83,6 @@ def get_existing_options_from_rst(optfiles):
|
||||||
return options
|
return options
|
||||||
|
|
||||||
|
|
||||||
def get_existing_options(optfiles):
|
|
||||||
"""Parse an existing XML table to compile a list of existing options."""
|
|
||||||
options = {}
|
|
||||||
for optfile in optfiles:
|
|
||||||
if optfile.endswith('/swift-conf-changes.xml'):
|
|
||||||
continue
|
|
||||||
xml = etree.fromstring(open(optfile).read().replace(':ref:', ''))
|
|
||||||
tbody = xml.find(DBK_NS + "tbody")
|
|
||||||
trlist = tbody.findall(DBK_NS + "tr")
|
|
||||||
for tr in trlist:
|
|
||||||
try:
|
|
||||||
col1, col2 = tr.findall(DBK_NS + "td")
|
|
||||||
option = col1.find(DBK_NS + "option").text
|
|
||||||
helptext = etree.tostring(col2, xml_declaration=False,
|
|
||||||
method="text")
|
|
||||||
except IndexError:
|
|
||||||
continue
|
|
||||||
if option not in options or 'No help text' in options[option]:
|
|
||||||
# options[option.split('=',1)[0]] = helptext
|
|
||||||
options[option] = helptext.strip()
|
|
||||||
return options
|
|
||||||
|
|
||||||
|
|
||||||
def extract_descriptions_from_devref(swift_repo, options):
|
def extract_descriptions_from_devref(swift_repo, options):
|
||||||
"""Extract descriptions from devref RST files.
|
"""Extract descriptions from devref RST files.
|
||||||
|
|
||||||
|
@ -183,21 +157,15 @@ def write_files(options, manuals_repo):
|
||||||
fd.write(output)
|
fd.write(output)
|
||||||
|
|
||||||
|
|
||||||
def read_options(swift_repo, manuals_repo, read_from, verbose):
|
def read_options(swift_repo, manuals_repo, verbose):
|
||||||
"""Find swift configuration options.
|
"""Find swift configuration options.
|
||||||
|
|
||||||
Uses existing tables and swift devref as a source of truth in that order to
|
Uses existing tables and swift devref as a source of truth in that order to
|
||||||
determine helptext for options found in sample config files.
|
determine helptext for options found in sample config files.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if read_from == 'rst':
|
options = get_existing_options(glob.glob(
|
||||||
options = get_existing_options_from_rst(
|
manuals_repo + '/doc/config-reference/source/tables/swift*rst'))
|
||||||
glob.glob(manuals_repo +
|
|
||||||
'/doc/config-reference/source/tables/swift*rst'))
|
|
||||||
else:
|
|
||||||
options = get_existing_options(
|
|
||||||
glob.glob(manuals_repo + '/doc/common/tables/swift*xml'))
|
|
||||||
|
|
||||||
option_descs = extract_descriptions_from_devref(swift_repo, options)
|
option_descs = extract_descriptions_from_devref(swift_repo, options)
|
||||||
conf_samples = glob.glob(swift_repo + '/etc/*conf-sample')
|
conf_samples = glob.glob(swift_repo + '/etc/*conf-sample')
|
||||||
for sample in conf_samples:
|
for sample in conf_samples:
|
||||||
|
@ -278,12 +246,6 @@ def main():
|
||||||
help="Location of the manuals git repository.",
|
help="Location of the manuals git repository.",
|
||||||
required=False,
|
required=False,
|
||||||
default="./sources/openstack-manuals")
|
default="./sources/openstack-manuals")
|
||||||
parser.add_argument('-f', '--from',
|
|
||||||
dest='read_from',
|
|
||||||
help="Source to get defined options (rst or docbook)",
|
|
||||||
required=False,
|
|
||||||
default='rst',
|
|
||||||
choices=['rst', 'docbook'])
|
|
||||||
parser.add_argument('-v', '--verbose',
|
parser.add_argument('-v', '--verbose',
|
||||||
action='count',
|
action='count',
|
||||||
default=0,
|
default=0,
|
||||||
|
@ -297,7 +259,6 @@ def main():
|
||||||
|
|
||||||
read_options(args.swift_repo,
|
read_options(args.swift_repo,
|
||||||
args.manuals_repo,
|
args.manuals_repo,
|
||||||
args.read_from,
|
|
||||||
args.verbose)
|
args.verbose)
|
||||||
options = OptionsCache()
|
options = OptionsCache()
|
||||||
|
|
||||||
|
|
|
@ -5,3 +5,7 @@ upgrade:
|
||||||
This previously allowed outputting of Docbook-formatted text but the
|
This previously allowed outputting of Docbook-formatted text but the
|
||||||
feature was broken and unsupported by the community. reStructuredText
|
feature was broken and unsupported by the community. reStructuredText
|
||||||
should be used for everything.
|
should be used for everything.
|
||||||
|
- |
|
||||||
|
The `extract_swift_flags` tool no longer supports the `--from` argument.
|
||||||
|
All Swift documentation has been converted to reStructuredText meaning
|
||||||
|
there is no reason to keep this around.
|
||||||
|
|
Loading…
Reference in New Issue