Ejemplo n.º 1
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!"
Ejemplo n.º 2
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!")
Ejemplo n.º 3
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!")