autohelp.py: update the paramters handling

- generate the tables in the doc/common/tables dir by default
- make the -i switch optional, and assume that git git repositories are
  in a ./sources/ dir
- use elif's instead of multiple return statements in the subcommand
  test

Change-Id: If96ac9df247cea5061c056328307ec88ab74a4f3
This commit is contained in:
Gauvain Pocentek 2014-05-13 07:25:39 -04:00
parent fa80be3495
commit ded3788ff3
3 changed files with 21 additions and 15 deletions

View File

@ -106,6 +106,10 @@ Release notes
-v output.
* New command ``openstack-jsoncheck`` to check for niceness of JSON
files and reformat them.
* ``openstack-autohelp``: Update the default parameters. The tables
are generated in the doc/common/tables/ dir by default, and the git
repository for the project being worked on is looked at in a sources/
dir by default.
0.13
----

View File

@ -140,9 +140,11 @@ start. This can be done by sourcing the `venv/bin/activate` file.
Now, download and install the projects. Installation is necessary to satisfy
dependencies between projects. This will also install required dependencies.
$ mkdir -p sources && cd sources
$ PROJECTS="ceilometer cinder glance heat neutron nova trove"
$ for p in $PROJECTS; do git clone git://git.openstack.org/openstack/$p.git; done
$ for p in $PROJECTS; do cd $p && python setup.py install && cd ..; done
$ cd ..
Install some missing requirements:
@ -156,7 +158,7 @@ discovered.
Update the flag names:
$ for p in $PROJECTS; do
> ../../../openstack-doc-tools/autogenerate_config_docs/autohelp.py -vvv update $project -i $project
> ../../../openstack-doc-tools/autogenerate_config_docs/autohelp.py -vvv update $project
> done
At this point, search through the `*.flagmappings.new` files for anything
@ -165,7 +167,7 @@ files and run `autohelp.py` with the `docbook` subcommand:
$ for p in $PROJECTS; do
> mv $p.flagmappings.new $p.flagmappings
> ../../../openstack-doc-tools/autogenerate_config_docs/autohelp.py -vvv docbook $project -i $project
> ../../../openstack-doc-tools/autogenerate_config_docs/autohelp.py -vvv docbook $project
> done
to generate the XML files and move those into the appropriate part of

View File

@ -47,8 +47,8 @@ def git_check(repo_path):
package_name = os.path.basename(repo.remotes.origin.url)
package_name = package_name.replace('.git', '')
except Exception:
print("\nThere is a problem verifying that the directory passed in")
print("is a valid git repository. Please try again.\n")
print("\n%s doesn't seem to be a valid git repository." % repo_path)
print("Use the -i flag to specify the repository path.\n")
sys.exit(1)
return package_name
@ -462,10 +462,10 @@ 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) [REQUIRED]',
help='Action (create, update, verify).',
choices=['create', 'update', 'docbook'])
parser.add_argument('package',
help='name of the top-level package')
help='Name of the top-level package.')
parser.add_argument('-v', '--verbose',
action='count',
default=0,
@ -473,17 +473,20 @@ def main():
required=False,)
parser.add_argument('-i', '--input',
dest='repo',
help='path to valid git repository [REQUIRED]',
required=True,
help='Path to a valid git repository.',
required=False,
type=str,)
parser.add_argument('-o', '--output',
dest='target',
help='directory in which xml files are generated',
help='Directory in which xml files are generated.',
required=False,
default='./',
default='../../doc/common/tables/',
type=str,)
args = parser.parse_args()
if args.repo is None:
args.repo = './sources/%s' % args.package
package_name = git_check(args.repo)
sys.path.insert(0, args.repo)
@ -504,19 +507,16 @@ def main():
if args.subcommand == 'create':
create_flagmappings(package_name, options, verbose=args.verbose)
return
if args.subcommand == 'update':
elif args.subcommand == 'update':
update_flagmappings(package_name, options, verbose=args.verbose)
return
if args.subcommand == 'docbook':
elif args.subcommand == 'docbook':
write_docbook(package_name, options, verbose=args.verbose,
target=args.target)
write_docbook_rootwrap(package_name, args.repo,
verbose=args.verbose,
target=args.target)
return
if __name__ == "__main__":