diff --git a/autogenerate_config_docs/README.rst b/autogenerate_config_docs/README.rst index 6d553c6f..16bd157e 100644 --- a/autogenerate_config_docs/README.rst +++ b/autogenerate_config_docs/README.rst @@ -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 ------------------ diff --git a/autogenerate_config_docs/autohelp-wrapper b/autogenerate_config_docs/autohelp-wrapper index 7b92427c..e98e5ffe 100755 --- a/autogenerate_config_docs/autohelp-wrapper +++ b/autogenerate_config_docs/autohelp-wrapper @@ -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 diff --git a/autogenerate_config_docs/autohelp.py b/autogenerate_config_docs/autohelp.py index 89a79488..b13b749d 100755 --- a/autogenerate_config_docs/autohelp.py +++ b/autogenerate_config_docs/autohelp.py @@ -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 [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'): diff --git a/autogenerate_config_docs/releasenotes/notes/update-can-create-097dd0790567eeb5.yaml b/autogenerate_config_docs/releasenotes/notes/update-can-create-097dd0790567eeb5.yaml new file mode 100644 index 00000000..77322caa --- /dev/null +++ b/autogenerate_config_docs/releasenotes/notes/update-can-create-097dd0790567eeb5.yaml @@ -0,0 +1,3 @@ +--- +other: + - ``autohelp.py update`` will create the flagmappings file if it doesn't exist yet.