def getParmTooltip(op_table_name, op_type, version, namespace, scopeop, parm_token, parm_label, is_spare): pages = get_pages() # Load the page path = components_to_path(op_table_name, scopeop, namespace, op_type, version) try: jsondata = pages.json(path, postprocess=False) except stores.ResourceNotFoundError: # No docs for this node at all return None if jsondata: # Try to find the given parameter parmblock = find_parm(jsondata, parm_token, parm_label) if parmblock: text = functions.first_subblock_string(parmblock) return hstring(text) # If we didn't find the parameter, and it's a spare parameter, assume it's # a render property and try to look it up in the properties if is_spare: s = get_searcher() fields = s.document(path=u"/props/mantra#%s" % parm_token) if fields and "summary" in fields: return hstring(fields["summary"])
def _superclasses(self, pages, methodnames, context, block, history=None): # Recursively loads the doc pointed to by the block's "superclass" # attribute and yields a (path, rootblock) pair for each superclass history = history or set() attrs = block.get("attrs", {}) superclass = attrs.get("superclass") if superclass: path = "/hom/" + superclass.replace(".", "/") spath = pages.source_path(path) if pages.exists(spath): if spath in history: raise Exception("Circular superclass structure") else: history.add(spath) doc = pages.json(spath, conditional=context.get("conditional"), postprocess=False) titleblock = functions.first_subblock_of_type(doc, "title") if titleblock: title = functions.string(titleblock.get("text")) else: title = superclass # Find the method items on the superclass section = functions.subblock_by_id(doc, "methods") methods = [] if section: for methblock in functions.find_items(doc, "methods_item"): text = methblock.get("text") name = functions.string(text).split("(")[0] attrs = methblock.get("attrs", {}) body = methblock.get("body", []) # If this name is in the set of seen methods, it's # overridden, so we should skip it if name in methodnames: continue methodnames.add(name) # Copy information about the method into a dict summary = functions.first_subblock_string(methblock) methdict = { "name": name, "text": text, "summary": summary, "more": len(body) > 1, } if "status" in attrs: methdict["status"] = attrs["status"] methods.append(methdict) yield { "path": path, "title": title, "methods": methods } for x in self._superclasses(pages, methodnames, context, doc, history): yield x