autohelp update
can create the flags file
If the flagmappings file doesn't exist the function will create it, with all the sections set to Unknown. This mimics the behavior of the `create`, not needed anymore. Change-Id: I7a920300b784aa8fca6412c292d807beb4d5c8e5
This commit is contained in:
parent
69c7c929c7
commit
e3c42a269d
@ -51,16 +51,6 @@ names as arguments:
|
||||
$ ./autohelp-wrapper rst cinder heat
|
||||
|
||||
|
||||
Creating mappings for a new project
|
||||
-----------------------------------
|
||||
|
||||
Run the wrapper with the create subcommand:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ ./autohelp-wrapper create zaqar
|
||||
|
||||
|
||||
Flagmappings files
|
||||
------------------
|
||||
|
||||
|
@ -29,11 +29,10 @@ FAST=0
|
||||
usage() {
|
||||
echo "Wrapper for autohelp.py"
|
||||
echo "Usage:"
|
||||
echo " $(basename $0) [ OPTIONS ] create|update|docbook|rst|setup [ project1 ... ]"
|
||||
echo " $(basename $0) [ OPTIONS ] update|docbook|rst|setup [ project1 ... ]"
|
||||
echo
|
||||
echo "Subcommands:"
|
||||
echo " create: Create an initial flagmapping file"
|
||||
echo " update: Update the flagmapping files"
|
||||
echo " update: Update or create the flagmapping files"
|
||||
echo " docbook: Generate the options tables in docbook format"
|
||||
echo " rst: Generate the options tables in RST format"
|
||||
echo " setup: Install the environment only"
|
||||
@ -140,7 +139,7 @@ ACTION=$1
|
||||
shift
|
||||
|
||||
case $ACTION in
|
||||
create|update|docbook|rst|setup) ;;
|
||||
update|docbook|rst|setup) ;;
|
||||
*)
|
||||
usage
|
||||
exit 1
|
||||
@ -230,15 +229,6 @@ for project in $PROJECTS; do
|
||||
cd $MANUALSREPO/tools/autogenerate-config-flagmappings
|
||||
|
||||
case $ACTION in
|
||||
create)
|
||||
[ "$project" = "swift" ] && continue
|
||||
file=$MANUALSREPO/tools/autogenerate-config-flagmappings/$project.flagmappings
|
||||
if [ -e $file ]; then
|
||||
echo "$project.flagmappings already exists, ignoring."
|
||||
continue
|
||||
fi
|
||||
$AUTOHELP create $project -i $SOURCESDIR/$project/$project $AUTOOPT
|
||||
;;
|
||||
update)
|
||||
[ "$project" = "swift" ] && continue
|
||||
$AUTOHELP update $project -i $SOURCESDIR/$project/$project $extra_flags $AUTOOPT
|
||||
|
@ -459,17 +459,6 @@ def write_files(package_name, options, target, output_format):
|
||||
fd.write(output)
|
||||
|
||||
|
||||
def create_flagmappings(package_name, options, verbose=0):
|
||||
"""Create a flagmappings file.
|
||||
|
||||
Create a flagmappings file. This will create a new file called
|
||||
$package_name.flagmappings with all the categories set to Unknown.
|
||||
"""
|
||||
with open(package_name + '.flagmappings', 'w') as f:
|
||||
for opt in options.get_option_names():
|
||||
f.write(opt + ' Unknown\n')
|
||||
|
||||
|
||||
def update_flagmappings(package_name, options, verbose=0):
|
||||
"""Update flagmappings file.
|
||||
|
||||
@ -478,14 +467,18 @@ def update_flagmappings(package_name, options, verbose=0):
|
||||
category information merged from the existing $package_name.flagmappings.
|
||||
"""
|
||||
original_flags = {}
|
||||
with open(package_name + '.flagmappings') as f:
|
||||
for line in f:
|
||||
try:
|
||||
flag, category = line.split(' ', 1)
|
||||
except ValueError:
|
||||
flag = line.strip()
|
||||
category = "Unknown"
|
||||
original_flags.setdefault(flag, []).append(category.strip())
|
||||
try:
|
||||
with open(package_name + '.flagmappings') as f:
|
||||
for line in f:
|
||||
try:
|
||||
flag, category = line.split(' ', 1)
|
||||
except ValueError:
|
||||
flag = line.strip()
|
||||
category = "Unknown"
|
||||
original_flags.setdefault(flag, []).append(category.strip())
|
||||
except IOError:
|
||||
# If the flags file doesn't exist we'll create it
|
||||
pass
|
||||
|
||||
updated_flags = []
|
||||
for opt in options.get_option_names():
|
||||
@ -519,8 +512,8 @@ def main():
|
||||
description='Manage flag files, to aid in updating documentation.',
|
||||
usage='%(prog)s <cmd> <package> [options]')
|
||||
parser.add_argument('subcommand',
|
||||
help='Action (create, update, verify, dump).',
|
||||
choices=['create', 'update', 'docbook', 'rst', 'dump'])
|
||||
help='Action (update, docbook, rst, dump).',
|
||||
choices=['update', 'docbook', 'rst', 'dump'])
|
||||
parser.add_argument('package',
|
||||
help='Name of the top-level package.')
|
||||
parser.add_argument('-v', '--verbose',
|
||||
@ -572,10 +565,7 @@ def main():
|
||||
print("%s options imported from package %s." % (len(options),
|
||||
str(package_name)))
|
||||
|
||||
if args.subcommand == 'create':
|
||||
create_flagmappings(args.package, options, verbose=args.verbose)
|
||||
|
||||
elif args.subcommand == 'update':
|
||||
if args.subcommand == 'update':
|
||||
update_flagmappings(args.package, options, verbose=args.verbose)
|
||||
|
||||
elif args.subcommand in ('docbook', 'rst'):
|
||||
|
@ -0,0 +1,3 @@
|
||||
---
|
||||
other:
|
||||
- ``autohelp.py update`` will create the flagmappings file if it doesn't exist yet.
|
Loading…
Reference in New Issue
Block a user