Example #1
0
def debug_module(pkg_name, module_name):
    all_pkgs = fetch("https://package.elm-lang.org/all-packages")
    # print(all_pkgs)
    # all_pkgs_dict = {p["name"]:p for p in all_pkgs}
    pkg_data = all_pkgs[pkg_name]
    # print(pkg_data)

    jsonURL = "/".join([
        "https://package.elm-lang.org/packages", pkg_name, pkg_data[-1],
        "docs.json"
    ])
    json_data = fetch(jsonURL)
    json_data_dict = {m["name"]: m for m in json_data}

    module = Module(json_data_dict[module_name], pkg_name)

    # print( json_data_dict[module_name])

    with open("./assets/debug.html", "wb") as fo:
        data = {
            "pkg_link": (pkg_name, "#"),
            "module_name":
            module.name,
            "markdown":
            toHtml(module.markdown).replace('<code>', '<code class="elm">')
        }
        fo.write(moduleTemplate(data))
Example #2
0
def generate_all():
    global pkgs
    print ("feching all packages list ..."),
    all_pkgs = fetch(pkgsURL + "all-packages")
    print ("DONE!")
    print ("feching new packages list ..."),
    new_pkgs = fetch(pkgsURL + "new-packages")
    print ("DONE!")

    new_pkgs = list(set(new_pkgs))
    all_pkgs_dict = {p["name"]: p for p in all_pkgs}

    deprecated = [p for p in all_pkgs_dict.iteritems() if not p in new_pkgs]

    pkgs = [p for p in all_pkgs if p["name"] in new_pkgs]
    pkgs.sort(key=lambda a: a["name"].lower())

    # generate the index
    with open(opj(docpath, "index.html"), "w") as fo:
        fo.write(indexTemplate({"pkgs": [(pkg["name"], docname(pkg["name"]), pkg["summary"]) for pkg in pkgs]}))

    no_pkgs = len(pkgs)
    for pkg in pkgs:
        idx = pkgs.index(pkg) + 1
        pkg_name = pkg["name"]
        pkg_file = docname(pkg_name)
        pkg_version = pkg["versions"][0]
        print "Generating package: " + pkg_name + " [% 3d / %03d]..." % (idx, no_pkgs),

        docURL = pkgsURL + "/".join(["packages", pkg_name, pkg_version, "documentation"]) + ".json"
        json = fetch(docURL)
        # module = Module(json)
        links = []
        for module_json in json:
            moduleJsonURL = (
                pkgsURL
                + "/".join(["packages", pkg_name, pkg_version, "docs", module_json["name"].replace(".", "-")])
                + ".json"
            )
            module = Module(fetch(moduleJsonURL), pkg_name)
            module_file = docname(pkg_name, module.name)
            links.append((module.name, module_file))
            with open(opj(docpath, module_file), "w") as fo:
                html = toHtml(module.markdown).replace("<code>", '<code class="elm">')  # fix syntax detection
                data = {"pkg_link": (pkg_name, pkg_file), "module_name": module.name, "markdown": html}
                fo.write(moduleTemplate(data))
            cur.execute(
                "INSERT OR IGNORE INTO searchIndex(name, type, path) VALUES (?,?,?)",
                (module.name, "Module", module_file),
            )

        with open(opj(docpath, pkg_file), "w") as fo:
            data = {"pkg_name": pkg_name, "modules": links, "version": pkg_version}
            fo.write(pkgTemplate(data))
        cur.execute(
            "INSERT OR IGNORE INTO searchIndex(name, type, path) VALUES (?,?,?)", (pkg_name, "Package", pkg_file)
        )

        print "DONE!"
Example #3
0
def debug_module(pkg_name, module_name):
    all_pkgs = fetch("http://package.elm-lang.org/all-packages")
    all_pkgs_dict = {p["name"]:p for p in all_pkgs}
    pkg_data = all_pkgs_dict[pkg_name]

    jsonURL = "/".join(["http://package.elm-lang.org/packages", pkg_name, pkg_data["versions"][0], "documentation.json"])
    json_data = fetch(jsonURL)
    json_data_dict = {m["name"]:m for m in json_data}


    module = Module(json_data_dict[module_name], pkg_name)

    # print json_data_dict[module_name]

    with open("./assetts/debug.html", "w") as fo:  
        data = { "pkg_link": (pkg_name, "#"), "module_name":module.name, "markdown":toHtml(module.markdown)}
        fo.write(moduleTemplate(data))
Example #4
0
def generate_all():
    global pkgs
    print("feching all packages list ..."),
    all_pkgs = requests.get(pkgsURL+"search.json").json()
    print("DONE!") 
    pkgs = sorted(all_pkgs, key=lambda a: a["name"].lower())
    
    # generate the index
    with open(opj(docpath, "index.html"), "wb") as fo:
        fo.write(indexTemplate({"pkgs":[(pkg["name"], docname(pkg["name"]), pkg["summary"]) for pkg in pkgs]}))

    no_pkgs = len(pkgs)
    for pkg in pkgs:
        idx = pkgs.index(pkg)+1
        pkg_name = pkg["name"]
        pkg_file = docname(pkg_name)
        try:
            pkg_version = pkg["version"]
        except IndexError:
            print ("No version found, skipping package: %s"%pkg_name)
            continue
        print ("Generating package: "+pkg_name+" [% 3d / %03d]..."%(idx, no_pkgs), end="") 
 
        json = fetch( pkgsURL+"/".join(["packages", pkg_name, pkg_version, "docs"])+".json")
        # module = Module(json)
        links = []
        for module_json in json:
              
            module = Module(module_json, pkg_name)
            module_file = docname(pkg_name, module.name) 
            links.append((module.name, module_file))
            with open(opj(docpath, module_file), "wb") as fo:  
                html = toHtml(module.markdown).replace('<code>', '<code class="elm">') # fix syntax detection
                data = { "pkg_link": (pkg_name, pkg_file), "module_name":module.name, "markdown":html, "pkg_name":pkg_name, "version":pkg_version}
                fo.write(moduleTemplate(data))
            cur.execute('INSERT OR IGNORE INTO searchIndex(name, type, path) VALUES (?,?,?)', (module.name + ' (' + pkg_name + ')', 'Module', module_file))

        with open(opj(docpath, pkg_file), "wb") as fo:
            data = { "pkg_name": pkg_name, "modules":links, "version":pkg_version}
            fo.write(pkgTemplate(data))
        cur.execute('INSERT OR IGNORE INTO searchIndex(name, type, path) VALUES (?,?,?)', (pkg_name, 'Package', pkg_file))

        print ("DONE!")
Example #5
0
def debug_module(pkg_name, module_name):
    all_pkgs = requests.get("http://package.elm-lang.org/search.json").json()

    pkgs = sorted(all_pkgs, key=lambda a: a["name"].lower())
    all_pkgs_dict = {p["name"]:p for p in pkgs}
    pkg_data = all_pkgs_dict[pkg_name]

    # print(pkg_data);
    jsonURL = "/".join(["http://package.elm-lang.org/packages", pkg_name, pkg_data["version"], "docs.json"])
    json_data = fetch(jsonURL)
    json_data_dict = {m["name"]:m for m in json_data}
    #print(jsonURL)


    module = Module(json_data_dict[module_name], pkg_name)

    # print json_data_dict[module_name]
    # print module.markdown

    with open("./assets/debug.html", "w") as fo:  
        data = { "pkg_link": (pkg_name, "#"), "module_name":module.name, "markdown":toHtml(module.markdown).replace('<code>', '<code class="elm">')}
        fo.write(moduleTemplate(data))
Example #6
0
def debug_module(pkg_name, module_name):
    all_pkgs = fetch("http://package.elm-lang.org/all-packages")
    all_pkgs_dict = {p["name"]: p for p in all_pkgs}
    pkg_data = all_pkgs_dict[pkg_name]

    jsonURL = "/".join([
        "http://package.elm-lang.org/packages", pkg_name,
        pkg_data["versions"][0], "documentation.json"
    ])
    json_data = fetch(jsonURL)
    json_data_dict = {m["name"]: m for m in json_data}

    module = Module(json_data_dict[module_name], pkg_name)

    # print json_data_dict[module_name]

    with open("./assetts/debug.html", "w") as fo:
        data = {
            "pkg_link": (pkg_name, "#"),
            "module_name": module.name,
            "markdown": toHtml(module.markdown)
        }
        fo.write(moduleTemplate(data))
Example #7
0
def generate_all():
    global pkgs
    print("feching all packages list ..."),
    all_pkgs = fetch(pkgsURL + "all-packages")
    print("DONE!")
    print("feching new packages list ..."),
    new_pkgs = fetch(pkgsURL + "new-packages")
    print("DONE!")

    new_pkgs = list(set(new_pkgs))
    all_pkgs_dict = {p["name"]: p for p in all_pkgs}

    deprecated = [p for p in all_pkgs_dict.items() if not p in new_pkgs]

    pkgs = [p for p in all_pkgs if p["name"] in new_pkgs]
    pkgs.sort(key=lambda a: a["name"].lower())

    # generate the index
    with open(opj(docpath, "index.html"), "wb") as fo:
        fo.write(
            indexTemplate({
                "pkgs": [(pkg["name"], docname(pkg["name"]), pkg["summary"])
                         for pkg in pkgs]
            }))

    no_pkgs = len(pkgs)
    for pkg in pkgs:
        idx = pkgs.index(pkg) + 1
        pkg_name = pkg["name"]
        pkg_file = docname(pkg_name)
        pkg_version = pkg["versions"][0]
        print("Generating package: " + pkg_name + " [% 3d / %03d]..." %
              (idx, no_pkgs),
              end="")

        docURL = pkgsURL + "/".join(
            ["packages", pkg_name, pkg_version, "documentation"]) + ".json"
        json = fetch(docURL)
        # module = Module(json)
        links = []
        for module_json in json:
            moduleJsonURL = pkgsURL + "/".join([
                "packages", pkg_name, pkg_version, "docs",
                module_json["name"].replace(".", "-")
            ]) + ".json"
            module = Module(fetch(moduleJsonURL), pkg_name)
            module_file = docname(pkg_name, module.name)
            links.append((module.name, module_file))
            with open(opj(docpath, module_file), "wb") as fo:
                html = toHtml(module.markdown).replace(
                    '<code>', '<code class="elm">')  # fix syntax detection
                data = {
                    "pkg_link": (pkg_name, pkg_file),
                    "module_name": module.name,
                    "markdown": html
                }
                fo.write(moduleTemplate(data))
            cur.execute(
                'INSERT OR IGNORE INTO searchIndex(name, type, path) VALUES (?,?,?)',
                (module.name, 'Module', module_file))

        with open(opj(docpath, pkg_file), "wb") as fo:
            data = {
                "pkg_name": pkg_name,
                "modules": links,
                "version": pkg_version
            }
            fo.write(pkgTemplate(data))
        cur.execute(
            'INSERT OR IGNORE INTO searchIndex(name, type, path) VALUES (?,?,?)',
            (pkg_name, 'Package', pkg_file))

        print("DONE!")