def BuildQueryFields(fields): """Build query fields documentation. @type fields: dict (field name as key, field details as value) """ defs = [(fdef.name, fdef.doc) for (_, (fdef, _, _, _)) in utils.NiceSort(fields.items(), key=compat.fst)] return BuildValuesDoc(defs)
def _BuildRapiAccessTable(res): """Build a table with access permissions needed for all RAPI resources. """ for (uri, handler) in utils.NiceSort(res.items(), key=compat.fst): reslink = _MakeRapiResourceLink(None, uri) if not reslink: # No link was generated continue yield ":ref:`%s <%s>`" % (uri, reslink) for method in _GetHandlerMethods(handler): yield (" | :ref:`%s <%s>`: %s" % (method, _MakeRapiResourceLink(method, uri), _DescribeHandlerAccess(handler, method)))
def _BuildOpcodeParams(op_id, include, exclude, alias): """Build opcode parameter documentation. @type op_id: string @param op_id: Opcode ID """ op_cls = opcodes.OP_MAPPING[op_id] params_with_alias = \ utils.NiceSort([(alias.get(name, name), name, default, test, doc) for (name, default, test, doc) in op_cls.GetAllParams()], key=compat.fst) for (rapi_name, name, default, test, doc) in params_with_alias: # Hide common parameters if not explicitly included if (name in COMMON_PARAM_NAMES and (not include or name not in include)): continue if exclude is not None and name in exclude: continue if include is not None and name not in include: continue has_default = default is not None or default is not ht.NoDefault has_test = test is not None buf = StringIO() buf.write("``%s``" % (rapi_name,)) if has_default or has_test: buf.write(" (") if has_default: if default == "": buf.write("defaults to the empty string") else: buf.write("defaults to ``%s``" % (default,)) if has_test: buf.write(", ") if has_test: buf.write("must be ``%s``" % (test,)) buf.write(")") yield buf.getvalue() # Add text for line in doc.splitlines(): yield " %s" % line