get_surround(j) + "</a></li>") html(" </ul>") html(" <h3 class=\"detail\"><a name=\"" + get_link(jsondata) + "\">" + get_fullname(jsondata) + "</a></h3>") insert_mdn_link(jsondata) html(" <p class=\"top\"><a href=\"#top\">(top)</a></p>") html(" <h4>Call type:</h4>") html(" <p class=\"call\"><code>" + get_code(jsondata) + "</code></p>") if "description" in jsondata: html(" <h4>Description</h4>") desc = jsondata["description"] if not isinstance(desc, list): desc = [desc] if ("ifdef" in jsondata) or ("ifndef" in jsondata): conds = "" if "ifdef" in jsondata: conds = common.get_ifdef_description(jsondata["ifdef"]) if "ifndef" in jsondata: if conds != "": conds += " and " conds = "not " + common.get_ifdef_description( jsondata["ifndef"]) desc.append( "<b>Note:</b> This is only available in some devices: " + conds) html_description(desc, jsondata["name"]) html(" <h4>Parameters</h4>") if "params" in jsondata: for param in jsondata["params"]: desc = "" if len(param) > 2: desc = param[2] if isinstance(desc, list): desc = '<br/>'.join(desc) extra = ""
html('<a class="githublink" title="Link to source code on GitHub" href="'+jsondata["githublink"]+'">⇒</a>'); html("</h3>") insert_mdn_link(jsondata); html(" <p class=\"top\"><a href=\"javascript:toppos();\">(top)</a></p>") if jsondata["type"]!="object": html(" <h4>Call type:</h4>") html(" <div class=\"call\"><code>"+get_code(jsondata)+"</code></div>") elif "instanceof" in jsondata: html(" <h4>Instance of <a href=\"#"+jsondata["instanceof"]+"\"><code>"+jsondata["instanceof"]+"</code></a>") if "description" in jsondata: html(" <h4>Description</h4>") desc = jsondata["description"] if not isinstance(desc, list): desc = [ desc ] if ("ifdef" in jsondata) or ("ifndef" in jsondata): conds = "" if "ifdef" in jsondata: conds = common.get_ifdef_description(jsondata["ifdef"]) if "ifndef" in jsondata: if conds!="": conds += " and " conds = "not "+common.get_ifdef_description(jsondata["ifndef"]) desc.append("\n\n**Note:** This is only available in "+conds); html_description(desc, jsondata["name"]) if "params" in jsondata: html(" <h4>Parameters</h4>") for param in jsondata["params"]: desc = "" if len(param)>2: desc=param[2] if isinstance(desc, list): desc = '<br/>'.join(desc) extra = "" if param[1]=="JsVarArray": extra = ", ..."; html(" <div class=\"param\">"+htmlify("`"+param[0]+extra+"` - "+desc)+"</div>") if "return" in jsondata:
def replace_with_ifdef_description(m): contents = m.group(1) return common.get_ifdef_description(contents)
insert_mdn_link(jsondata) html(" <p class=\"top\"><a href=\"javascript:toppos();\">(top)</a></p>") if jsondata["type"] != "object": html(" <h4>Call type:</h4>") html(" <div class=\"call\"><code>" + get_code(jsondata) + "</code></div>") elif "instanceof" in jsondata: html(" <h4>Instance of <a href=\"#" + jsondata["instanceof"] + "\"><code>" + jsondata["instanceof"] + "</code></a>") if "description" in jsondata: html(" <h4>Description</h4>") desc = jsondata["description"] if not isinstance(desc, list): desc = [desc] if "ifdef" in jsondata: desc.append("\n\n**Note:** This is only available in " + common.get_ifdef_description(jsondata["ifdef"])) if "ifndef" in jsondata: desc.append("\n\n**Note:** This is not available in " + common.get_ifdef_description(jsondata["ifndef"])) if "#if" in jsondata: d = jsondata["#if"].replace("||", " and ").replace("&&", " with ") d = re.sub('defined\((.+?)\)', replace_with_ifdef_description, d) d = re.sub('(.*)_COUNT>=(.*)', "devices with more than \\2 \\1 peripherals", d) desc.append("\n\n**Note:** This is only available in " + d) html_description(desc, jsondata["name"]) if "params" in jsondata: html(" <h4>Parameters</h4>") for param in jsondata["params"]: desc = "" if len(param) > 2: desc = param[2]
html('<a class="githublink" title="Link to source code on GitHub" href="'+jsondata["githublink"]+'">⇒</a>'); html("</h3>") insert_mdn_link(jsondata); html(" <p class=\"top\"><a href=\"javascript:toppos();\">(top)</a></p>") if jsondata["type"]!="object": html(" <h4>Call type:</h4>") html(" <div class=\"call\"><code>"+get_code(jsondata)+"</code></div>") elif "instanceof" in jsondata: html(" <h4>Instance of <a href=\"#"+jsondata["instanceof"]+"\"><code>"+jsondata["instanceof"]+"</code></a>") if "description" in jsondata: html(" <h4>Description</h4>") desc = jsondata["description"] if not isinstance(desc, list): desc = [ desc ] if ("ifdef" in jsondata) or ("ifndef" in jsondata): if "ifdef" in jsondata: desc.append("\n\n**Note:** This is only available in "+common.get_ifdef_description(jsondata["ifdef"])); if "ifndef" in jsondata: desc.append("\n\n**Note:** This is not available in "+common.get_ifdef_description(jsondata["ifndef"])); html_description(desc, jsondata["name"]) if "params" in jsondata: html(" <h4>Parameters</h4>") for param in jsondata["params"]: desc = "" if len(param)>2: desc=param[2] if isinstance(desc, list): desc = '<br/>'.join(desc) extra = "" if param[1]=="JsVarArray": extra = ", ..."; html(" <div class=\"param\">"+htmlify("`"+param[0]+extra+"` - "+desc)+"</div>") if "return" in jsondata: html(" <h4>Returns</h4>") desc = ""
if isinstance(desc, list): desc = '<br/>'.join(desc) extra = "" if param[1]=="JsVarArray": extra = ", ..."; html(" <div class=\"param\">"+htmlify("`"+param[0]+extra+"` - "+desc,"")+"</div>") if "return" in jsondata: html(" <h4>Returns</h4>") desc = "" if len(jsondata["return"])>1: desc=jsondata["return"][1] if desc=="": desc="See description above" html(" <div class=\"return\">"+htmlify(desc,"")+"</div>") if "description" in jsondata: html(" <h4>Description</h4>") desc = jsondata["description"] if not isinstance(desc, list): desc = [ desc ] if "ifdef" in jsondata: desc.append("\n\n**Note:** This is only available in "+common.get_ifdef_description(jsondata["ifdef"])); if "ifndef" in jsondata: desc.append("\n\n**Note:** This is not available in "+common.get_ifdef_description(jsondata["ifndef"])); if "#if" in jsondata: d = jsondata["#if"].replace("||", " and ").replace("&&", " with ") d = re.sub('defined\((.+?)\)', replace_with_ifdef_description, d) d = re.sub('(.*)_COUNT>=(.*)', "devices with more than \\2 \\1 peripherals", d) desc.append("\n\n**Note:** This is only available in "+d); html_description(desc, jsondata["name"]) url = "http://www.espruino.com/Reference#"+get_link(jsondata) if url in code_uses: uses = code_uses[url] html(" <h4>Examples</h4>") html(" <p class=\"examples\">This function is used in the following places in Espruino's documentation</p>")