|
|
@@ -13,14 +13,18 @@ bsp_header_list = [
|
|
|
]
|
|
|
print("getting bsp.h files...")
|
|
|
for bsp in bsp_header_list:
|
|
|
- print("getting "+bsp["name"]+"...")
|
|
|
+ # print("getting "+bsp["name"]+"...")
|
|
|
res = ""
|
|
|
#有时候获取不到完整的数据,报错的页面就是html
|
|
|
while len(res) < 200 or res.find("</title>") != -1:
|
|
|
res = requests.get(bsp["url"]).text
|
|
|
- print(res)
|
|
|
+ # print(res)
|
|
|
bsp["url"] = res
|
|
|
- print("done "+ str(len(bsp["url"])) + " bytes")
|
|
|
+ # print("done "+ str(len(bsp["url"])) + " bytes")
|
|
|
+
|
|
|
+def is_supported(tag, bsp) :
|
|
|
+ if bsp["url"].find(" "+tag+" ") >= 0 or bsp["url"].find(" "+tag+"\r") >= 0 or bsp["url"].find(" "+tag+"\n") >= 0:
|
|
|
+ return True
|
|
|
|
|
|
def get_tags(tag, is_api = False):
|
|
|
if len(tag) == 0:
|
|
|
@@ -47,9 +51,45 @@ def make(path,modules,index_text):
|
|
|
except:
|
|
|
pass
|
|
|
os.mkdir(path)
|
|
|
-
|
|
|
+ is_api = str(path).endswith("api/")
|
|
|
+
|
|
|
+ # 创建表格
|
|
|
+ if is_api :
|
|
|
+ doc = open(path+"supported.md", "w+",encoding='utf-8')
|
|
|
+ doc.write("#适配状态\n\n")
|
|
|
+ doc.write("|BSP/库|简介")
|
|
|
+ for bsp in bsp_header_list:
|
|
|
+ doc.write("|" + bsp["name"])
|
|
|
+ doc.write("|\n")
|
|
|
+
|
|
|
+ doc.write("|---|---")
|
|
|
+ for bsp in bsp_header_list:
|
|
|
+ doc.write("|---")
|
|
|
+ doc.write("|\n")
|
|
|
+
|
|
|
+ for module in modules:
|
|
|
+ name = module["module"]
|
|
|
+ doc.write("|[{}]({}.html)|`{}`".format(name, name, module["summary"]))
|
|
|
+ for bsp in bsp_header_list:
|
|
|
+ if len(module["tag"]) == 0 :
|
|
|
+ doc.write("|?")
|
|
|
+ continue
|
|
|
+ if is_supported(module["tag"], bsp) :
|
|
|
+ doc.write("|Y")
|
|
|
+ else:
|
|
|
+ doc.write("|X")
|
|
|
+ doc.write("|\n")
|
|
|
+
|
|
|
doc = open(path+"index.rst", "a+",encoding='utf-8')
|
|
|
doc.write(index_text)
|
|
|
+ # 创建toctree
|
|
|
+ doc.write("\n\n请点击左侧列表,查看各个接口。如需搜索,请使用F5进行搜索。\n\n"+
|
|
|
+ ".. toctree::\n\n")
|
|
|
+ if is_api:
|
|
|
+ doc.write(" supported\n")
|
|
|
+ for module in modules:
|
|
|
+ doc.write(" "+module["module"]+"\n")
|
|
|
+ doc.close()
|
|
|
|
|
|
for module in modules:
|
|
|
mdoc = open(path+module["module"]+".md", "a+",encoding='utf-8')
|
|
|
@@ -80,7 +120,7 @@ def make(path,modules,index_text):
|
|
|
mdoc.write("|"+const["var"].replace("|","\|")+"|"+const["type"].replace("|","\|")+"|"+const["summary"].replace("|","\|")+"|\n")
|
|
|
mdoc.write("\n\n")
|
|
|
|
|
|
- doc.write(" "+module["module"]+"\n")
|
|
|
+
|
|
|
for api in module["api"]:
|
|
|
mdoc.write("## "+api["api"]+"\n\n")
|
|
|
|
|
|
@@ -118,7 +158,6 @@ def make(path,modules,index_text):
|
|
|
|
|
|
mdoc.close()
|
|
|
|
|
|
- doc.close()
|
|
|
|
|
|
|
|
|
def get_description(api):
|