-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathdebug.py
28 lines (20 loc) · 940 Bytes
/
debug.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import json
from templates import indexTemplate, pkgTemplate, moduleTemplate, toHtml
import requests
import re
from cache import fetch
from generate import Module
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))