diff --git a/RELEASE_NOTES.rst b/RELEASE_NOTES.rst index a8c5eb30..dfcf5c25 100644 --- a/RELEASE_NOTES.rst +++ b/RELEASE_NOTES.rst @@ -15,7 +15,8 @@ Release notes * ``diff_branches.py``: Updated output format. * Provide a ``hotref`` extension for sphinx, to automate the creation of references to the HOT resources documentation. -* ``openstack-auto-commands``: Handle python-openstackclient. +* ``openstack-auto-commands``: Handle python-openstackclient, handle + python-glanceclient v2 commands. 0.18.1 ------ diff --git a/os_doc_tools/commands.py b/os_doc_tools/commands.py index af09f951..d0428669 100644 --- a/os_doc_tools/commands.py +++ b/os_doc_tools/commands.py @@ -346,26 +346,34 @@ def generate_command(os_command, os_file): os_file.write(" \n") -def generate_subcommand(os_command, os_subcommand, os_file): +def generate_subcommand(os_command, os_subcommand, os_file, extra_params, + suffix, title_suffix): """Convert os_command help os_subcommand to DocBook. :param os_command: client command to document :param os_subcommand: client subcommand to document :param os_file: open filehandle for output of DocBook file + :param extra_params: Extra parameter to pass to os_command + :param suffix: Extra suffix to add to xml:id + :param title_suffix: Extra suffix for title """ + args = [os_command] + if extra_params: + args.extend(extra_params) if use_help_flag(os_command): - help_lines = check_output([os_command, os_subcommand, - "--help"]).split('\n') + args.append(os_subcommand) + args.append("--help") else: - help_lines = check_output([os_command, "help", - os_subcommand]).split('\n') + args.append("help") + args.append(os_subcommand) + help_lines = check_output(args).split('\n') os_subcommandid = os_subcommand.replace(' ', '_') - os_file.write("
\n" - % (os_command, os_subcommandid)) - os_file.write(" %s %s\n" - % (os_command, os_subcommand)) + os_file.write("
\n" + % (os_command, os_subcommandid, suffix)) + os_file.write(" %s %s%s\n" + % (os_command, os_subcommand, title_suffix)) if os_command == "swift": next_line_screen = False @@ -377,6 +385,10 @@ def generate_subcommand(os_command, os_subcommand, os_file): else: next_line_screen = True in_para = False + if extra_params: + extra_paramstr = ' '.join(extra_params) + help_lines[0] = help_lines[0].replace(os_command, "%s %s" % + (os_command, extra_paramstr)) line_index = -1 # Content is: # usage... @@ -430,13 +442,17 @@ def generate_subcommand(os_command, os_subcommand, os_file): os_file.write("
\n") -def generate_subcommands(os_command, os_file, blacklist, only_subcommands): +def generate_subcommands(os_command, os_file, blacklist, only_subcommands, + extra_params, suffix, title_suffix): """Convert os_command help subcommands for all subcommands to DocBook. :param os_command: client command to document :param os_file: open filehandle for output of DocBook file :param blacklist: list of elements that will not be documented :param only_subcommands: if not empty, list of subcommands to document + :param extra_params: Extra parameter to pass to os_command. + :param suffix: Extra suffix to add to xml:id + :param title_suffix: Extra suffix for title """ print("Documenting '%s' subcommands..." % os_command) @@ -452,7 +468,8 @@ def generate_subcommands(os_command, os_file, blacklist, only_subcommands): subcommands = [o for o in all_options if not (o.startswith('-') or o in blacklist)] for subcommand in sorted(subcommands): - generate_subcommand(os_command, subcommand, os_file) + generate_subcommand(os_command, subcommand, os_file, extra_params, + suffix, title_suffix) print ("%d subcommands documented." % len(subcommands)) @@ -612,8 +629,53 @@ def document_single_project(os_command, output_dir): out_file = open(os.path.join(output_dir, out_filename), 'w') generate_heading(os_command, api_name, title, out_file) generate_command(os_command, out_file) + + if os_command == 'glance': + out_file.write(""" +
+ Image Service API v1 commands\n""") + generate_subcommands(os_command, out_file, blacklist, - subcommands) + subcommands, None, "", "") + + if os_command == 'glance': + out_file.write("
\n") + subcommands = ['explain', 'image-create', 'image-delete', + 'image-download', 'image-list', 'image-show', + 'image-tag-delete', 'image-tag-update', 'image-update', + 'image-upload', 'location-add', 'location-delete', + 'location-update', 'md-namespace-create', + 'md-namespace-delete', 'md-namespace-import', + 'md-namespace-list', 'md-namespace-objects-delete', + 'md-namespace-properties-delete', + 'md-namespace-resource-type-list', 'md-namespace-show', + 'md-namespace-update', 'md-object-create', + 'md-object-delete', 'md-object-list', + 'md-object-property-show', 'md-object-show', + 'md-object-update', 'md-property-create', + 'md-property-delete', 'md-property-list', + 'md-property-show', 'md-property-update', + 'md-resource-type-associate', + 'md-resource-type-deassociate', + 'md-resource-type-list', 'member-create', + 'member-delete', 'member-list', 'member-update'] + + out_file.write(""" +
+ Image Service API v2 commands + + You can select an API version to use by adding the + --os-image-api-version option or by setting + the corresponding environment variable:\n""") + out_file.write("$ " + "export OS_IMAGE_API_VERSION=2\n" + "\n") + + generate_subcommands(os_command, out_file, blacklist, + subcommands, ["--os-image-api-version", "2"], + "_v2", " (v2)") + out_file.write("
\n") + generate_end(out_file) out_file.close()