def _get_commands_rest_summary_table(command_defs): """Creates rst summary table for given class""" name_max_len = 0 summary_max_len = 0 line_tuples = [] for c in command_defs: if not is_name_private(c.name): doc_ref = get_command_rest_rst_file_name(c)[:-4] # remove the ".rst" name = ":doc:`%s <%s>` " % (c.full_name, doc_ref) summary = c.doc.one_line if c.maturity: summary = get_maturity_rst(c.maturity) + " " + summary if len(name) > name_max_len: name_max_len = len(name) if len(summary) > summary_max_len: summary_max_len = len(summary) line_tuples.append((name, summary)) name_len = name_max_len + 2 summary_len = summary_max_len + 2 table_line = ("=" * name_len) + " " + ("=" * summary_len) header_command_name = "Command Name (explained :doc:`here <%s>`)" % ABOUT_COMMAND_NAMES table_header = "\n".join([table_line, "%s%s Description" % (header_command_name, " " * (name_len - len(header_command_name))), table_line]) lines = sorted(["%s%s %s" % (t[0], " " * (name_len - len(t[0])), t[1]) for t in line_tuples]) lines.insert(0, table_header) lines.append(table_line) return "\n".join(lines)
def get_command_def_rest_rst(command_def): """return rest entry for a function or attribute described by the command def""" one_line = command_def.doc.one_line if command_def.maturity: one_line = get_maturity_rst(command_def.maturity) + "\n" + one_line extended = command_def.doc.extended arguments = indent("\n".join([_get_argument_rest_rst(p) for p in command_def.parameters])) title = ':doc:`Commands <index>` %s' % command_def.full_name title_emphasis = "-" * len(title) return_info = _get_returns_rest_rst(command_def.return_info) command_rest_template = """ {title_emphasis} {title} {title_emphasis} {one_line} POST /v1/commands/ ================== GET /v1/commands/:id ==================== Request ------- **Route** :: POST /v1/commands/ **Body** {args_warning} :name: {full_name} :arguments: {arguments} | **Headers** :: Authorization: test_api_key_1 Content-type: application/json | **Description** {extended} | Response -------- **Status** :: 200 OK **Body** Returns information about the command. See the Response Body for Get Command here below. It is the same. GET /v1/commands/:id ==================== Request ------- **Route** :: GET /v1/commands/18 **Body** (None) **Headers** :: Authorization: test_api_key_1 Content-type: application/json | Response -------- **Status** :: 200 OK **Body** {return_info} """.format(title=title, title_emphasis=title_emphasis, one_line=one_line, full_name=command_def.full_name, args_warning=_get_args_warning(command_def), arguments=arguments, extended=extended, return_info=return_info) return command_rest_template