import urllib2 import markdown import htmlentitydefs # Scans files for comments of the form /*JSON......*/ and then writes out an HTML file describing # all the functions # htmldev default is False # if htmldev is set to True indicating 'html development mode', script: # - creates standalone html version for temporary html generation development by: # --- inserting a searchbox text input to test top link function # --- skipping MDN links dump and validation to complete quicker htmldev = False jsondatas = common.get_jsondata(True) classes = [] libraries = [] for jsondata in jsondatas: if "class" in jsondata: if not jsondata["class"] in classes: classes.append(jsondata["class"]) if jsondata["type"]=="library": if not jsondata["class"] in libraries: libraries.append(jsondata["class"]) # Load list of 'uses' in EspruinoDocs code_uses = [] referenceFile = "../EspruinoDocs/references.json" if os.path.isfile(referenceFile):
# end extensioin by jumjum return delete_by_indices(datas, toremove) # ------------------------------------------------------------------------------------------------------ # ------------------------------------------------------------------------------------------------------ # ------------------------------------------------------------------------------------------------------ # ------------------------------------------------------------------------------------------------------ # ------------------------------------------------------------------------------------------------------ # ------------------------------------------------------------------------------------------------------ print("BOARD " + boardName) board = importlib.import_module(boardName) jsondatas = common.get_jsondata(is_for_document=False, parseArgs=True, board=board) if 'BLACKLIST' in os.environ: jsondatas = removeBlacklistForWrapper(os.environ['BLACKLIST'], jsondatas) includes = common.get_includes_from_jsondata(jsondatas) # work out what we have actually got classes = [] constructors = [] for jsondata in jsondatas: if "class" in jsondata: if not jsondata["class"] in classes: classes.append(jsondata["class"]) if jsondata["type"] == "constructor": if not jsondata["name"] in constructors:
# Scans files for comments of the form /*JSON......*/ and then builds a tree structure of ifs to # efficiently detect the symbols without using RAM. See common.py for formatting # ---------------------------------------------------------------------------------------- import subprocess import re import json import sys import os sys.path.append(".") import common # Scans files for comments of the form /*JSON......*/ and then builds a tree structure of ifs to # efficiently detect the symbols without using RAM. See common.py for formatting jsondatas = common.get_jsondata(False) includes = common.get_includes_from_jsondata(jsondatas) # ------------------------------------------------------------------------------------------------------ def treewalk(tree, name, jsondata): if len(name) == 0: tree[""] = jsondata else: firstchar = name[:1] if not firstchar in tree: tree[firstchar] = {} treewalk(tree[firstchar], name[1:], jsondata) # ------------------------------------------------------------------------------------------------------
print("Script location " + scriptdir) if len(sys.argv) != 2: print("ERROR, USAGE: build_board_json.py BOARD_NAME") exit(1) boardname = sys.argv[1] jsonFilename = "boards/" + boardname + ".json" print("JSON_FILENAME " + jsonFilename) print("BOARD " + boardname) # import the board def board = importlib.import_module(boardname) # Call the included board_specific file - it sets up 'pins' and 'fill_gaps' pins = board.get_pins() pins = pinutils.append_devices_to_pin_list(pins, board) # ----------------------------------------------------------------------------------------- # Documentation/functions jsondatas = common.get_jsondata(False, False, board) # ----------------------------------------------------------------------------------------- board.info["image_url"] = "http://www.espruino.com/img/" + boardname + ".jpg" board.info[ "thumb_url"] = "http://www.espruino.com/img/" + boardname + "_thumb.jpg" board.info["binary_version"] = common.get_version() board.info[ "binary_url"] = "http://www.espruino.com/binaries/" + common.get_board_binary_name( board) # ----------------------------------------------------------------------------------------- # Built-in modules builtinModules = [] for jsondata in jsondatas: if jsondata["type"] == "library": builtinModules.append(jsondata["class"])
# jswrap_*.c files # ---------------------------------------------------------------------------------------- import subprocess import re import json import sys import os sys.path.append(".") import common import urllib2 # Scans files for comments of the form /*JSON......*/ and then writes out an HTML file describing # all the functions jsondatas = common.get_jsondata(True) classes = [] for jsondata in jsondatas: if "class" in jsondata: if not jsondata["class"] in classes: classes.append(jsondata["class"]) # Load list of 'uses' in EspruinoDocs code_uses = [] referenceFile = "../EspruinoDocs/references.json" if os.path.isfile(referenceFile): print "Found references.json - using this to link to examples" code_uses = json.loads(open(referenceFile, "r").read()) # Load list of MDN URLs (to speed up processing)
print("Script location "+scriptdir) if len(sys.argv)!=2: print("ERROR, USAGE: build_board_json.py BOARD_NAME") exit(1) boardname = sys.argv[1] jsonFilename = "boards/"+boardname+".json" print("JSON_FILENAME "+jsonFilename) print("BOARD "+boardname) # import the board def board = importlib.import_module(boardname) # Call the included board_specific file - it sets up 'pins' and 'fill_gaps' pins = board.get_pins() pins = pinutils.append_devices_to_pin_list(pins, board) # ----------------------------------------------------------------------------------------- # Documentation/functions jsondatas = common.get_jsondata(False, False, board) # ----------------------------------------------------------------------------------------- board.info["image_url"] = "http://www.espruino.com/img/"+boardname+".jpg" board.info["thumb_url"] = "http://www.espruino.com/img/"+boardname+"_thumb.jpg" board.info["binary_version"] = common.get_version(); board.info["binary_url"] = "http://www.espruino.com/binaries/"+common.get_board_binary_name(board) # ----------------------------------------------------------------------------------------- # Built-in modules builtinModules = [] for jsondata in jsondatas: if jsondata["type"]=="library": builtinModules.append(jsondata["class"]) board.info["builtin_modules"] = builtinModules # -----------------------------------------------------------------------------------------
# file, You can obtain one at http://mozilla.org/MPL/2.0/. # # ---------------------------------------------------------------------------------------- # Reads JSON schemas from jswrap files and uses it to generate a JS stub # which is useful for autocomplete # # To generate the stubs for Node.js use `build_jssstub.py node` # ---------------------------------------------------------------------------------------- import sys import json import common # encapsulate output in a comment print "/*" schemas = common.get_jsondata(True, False) print "*/" # get structured data for further parsing context = common.get_struct_from_jsondata(schemas) #print(json.dumps(context, sort_keys=True, indent=2)) def println(line): print "\n" + line def getDescComment(obj): if not "desc" in obj or len(obj["desc"]) == 0: return '' val = "/**"
# Scans files for comments of the form /*JSON......*/ and then builds a tree structure of ifs to # efficiently detect the symbols without using RAM. See common.py for formatting # ---------------------------------------------------------------------------------------- import subprocess; import re; import json; import sys; import os; sys.path.append("."); import common # Scans files for comments of the form /*JSON......*/ and then builds a tree structure of ifs to # efficiently detect the symbols without using RAM. See common.py for formatting jsondatas = common.get_jsondata(False) includes = common.get_includes_from_jsondata(jsondatas) # ------------------------------------------------------------------------------------------------------ def treewalk(tree, name, jsondata): if len(name)==0: tree[""] = jsondata else: firstchar = name[:1] if not firstchar in tree: tree[firstchar] = {} treewalk(tree[firstchar], name[1:], jsondata) # ------------------------------------------------------------------------------------------------------ # Creates something like 'name[0]=='s' && name[1]=='e' && name[2]=='t' && name[3]==0' def createStringCompare(varName, checkOffsets, checkCharacters):
if black["class"] == "__": if jsondata["name"] == black["name"]: toremove.append(idx) # end extensioin by jumjum return delete_by_indices( datas, toremove) # ------------------------------------------------------------------------------------------------------ # ------------------------------------------------------------------------------------------------------ # ------------------------------------------------------------------------------------------------------ # ------------------------------------------------------------------------------------------------------ # ------------------------------------------------------------------------------------------------------ # ------------------------------------------------------------------------------------------------------ print("BOARD "+boardName) board = importlib.import_module(boardName) jsondatas = common.get_jsondata(is_for_document = False, parseArgs = True, board = board) if 'BLACKLIST' in os.environ: jsondatas = removeBlacklistForWrapper(os.environ['BLACKLIST'],jsondatas) includes = common.get_includes_from_jsondata(jsondatas) # work out what we have actually got classes = [] constructors = [] for jsondata in jsondatas: if "class" in jsondata : if not jsondata["class"] in classes: classes.append(jsondata["class"]) if jsondata["type"]=="constructor": if not jsondata["name"] in constructors: constructors.append(jsondata["name"])
# file, You can obtain one at http://mozilla.org/MPL/2.0/. # # ---------------------------------------------------------------------------------------- # Reads JSON schemas from jswrap files and uses it to generate a JS stub # which is useful for autocomplete # # To generate the stubs for Node.js use `build_jssstub.py node` # ---------------------------------------------------------------------------------------- import sys; import json; import common; # encapsulate output in a comment print("/*"); schemas = common.get_jsondata(True, False) print("*/"); # get structured data for further parsing context = common.get_struct_from_jsondata(schemas) #print(json.dumps(context, sort_keys=True, indent=2)) def println(line): print ("\n" + line) def getDescComment(obj): if not "desc" in obj or len(obj["desc"]) == 0: return '' val = "/**" desc = obj["desc"] if not isinstance(desc, list):
print("It's much easier to run this from the Makefile with:") print(" BOARDNAME=1 make boardjson") exit(1) print("Script location " + scriptdir) jsonFilename = "boards/" + boardname + ".json" print("JSON_FILENAME " + jsonFilename) print("BOARD " + boardname) # import the board def board = importlib.import_module(boardname) # Call the included board_specific file - it sets up 'pins' and 'fill_gaps' pins = board.get_pins() pins = pinutils.append_devices_to_pin_list(pins, board) # ----------------------------------------------------------------------------------------- # Documentation/functions jsondatas = common.get_jsondata(False) # use command-line args # ----------------------------------------------------------------------------------------- board.info["image_url"] = "http://www.espruino.com/img/" + boardname + ".jpg" board.info[ "thumb_url"] = "http://www.espruino.com/img/" + boardname + "_thumb.jpg" board.info["binary_version"] = common.get_version() board.info[ "binary_url"] = "http://www.espruino.com/binaries/" + common.get_board_binary_name( board) # ----------------------------------------------------------------------------------------- # Built-in modules builtinModules = [] for jsondata in jsondatas: if jsondata["type"] == "library": builtinModules.append(jsondata["class"])
print("It's much easier to run this from the Makefile with:") print(" BOARDNAME=1 make boardjson") exit(1) print("Script location "+scriptdir) jsonFilename = "boards/"+boardname+".json" print("JSON_FILENAME "+jsonFilename) print("BOARD "+boardname) # import the board def board = importlib.import_module(boardname) # Call the included board_specific file - it sets up 'pins' and 'fill_gaps' pins = board.get_pins() pins = pinutils.append_devices_to_pin_list(pins, board) # ----------------------------------------------------------------------------------------- # Documentation/functions jsondatas = common.get_jsondata(False) # use command-line args # ----------------------------------------------------------------------------------------- board.info["image_url"] = "http://www.espruino.com/img/"+boardname+".jpg" board.info["thumb_url"] = "http://www.espruino.com/img/"+boardname+"_thumb.jpg" board.info["binary_version"] = common.get_version(); board.info["binary_url"] = "http://www.espruino.com/binaries/"+common.get_board_binary_name(board) # ----------------------------------------------------------------------------------------- # Built-in modules builtinModules = [] for jsondata in jsondatas: if jsondata["type"]=="library": builtinModules.append(jsondata["class"]) # print (json.dumps(jsondata, indent=1)); board.info["builtin_modules"] = builtinModules