This commit is contained in:
virusdefender 2016-10-05 22:13:00 +08:00
parent 31e77059f0
commit 45ec83cb29
11 changed files with 79 additions and 33 deletions

49
gen.py Normal file
View File

@ -0,0 +1,49 @@
# coding=utf-8
import yaml
with open("mkdocs_template.yml", "r") as f:
raw_data = yaml.load(f)
data = raw_data["pages"]
def one(item, depth=0, result=""):
for k, v in item.iteritems():
if isinstance(v, basestring):
result += " ".join([" " * depth, "-", "[" + k + "](/" + v.rstrip("index.md").rstrip(".md") + ")\n"])
elif isinstance(v, list):
result += " ".join([" " * depth, "-", k, "\n"])
for v_item in v:
result += one(v_item, depth+4)
return result
def get_all(l):
result = ""
for _ in l:
result += one(_)
return result
new_data = []
for _ in data:
name = list(_.iteritems())[0][0]
if name == "Home":
new_data.append(_)
content = get_all(data)
with open("src/index_template.md", "r") as f:
old = f.read()
old = old.replace("<!--TOC-->", content.encode("utf-8"))
with open("src/index.md", "w") as f:
f.write(old)
else:
content = one(_)
path = name + "/index.md"
with open("src/" + path, "w") as f:
f.write("# Table of contents\n" + content.encode("utf-8"))
tmp = [{"index": path}]
tmp.extend(_[name])
new_data.append({name: tmp})
raw_data["pages"] = new_data
with open("mkdocs.yml", "w") as f:
yaml.dump(raw_data, f, default_flow_style=False)

View File

@ -1,19 +0,0 @@
site_name: Online Judge Docs
theme: yeti
docs_dir: 'src'
site_dir: 'docs'
pages:
- Home: 'index.md'
- Judger:
# - 'Index': 'judger/index.md'
- 'English':
- 'API': 'judger/English/index.md'
- JudgeServer:
# - 'Index': 'judge_server/index.md'
- 'English':
- 'API': 'judge_server/English/index.md'
- 'Deploy': 'judge_server/English/deploy.md'
# - '中文':
# - 'API': 'judge_server/Chinese/index.md'
# - '部署': 'judge_server/Chinese/deploy.md'

16
mkdocs_template.yml Normal file
View File

@ -0,0 +1,16 @@
pages:
- Home: index.md
- Judger:
- English:
- API: Judger/English/index.md
- JudgeServer:
- English:
- API: JudgeServer/English/index.md
- Deploy: JudgeServer/English/deploy.md
- 中文:
- API: JudgeServer/Chinese/index.md
- 部署: JudgeServer/Chinese/deploy.md
docs_dir: src
site_dir: docs
site_name: Online Judge Docs
theme: yeti

8
src/JudgeServer/index.md Normal file
View File

@ -0,0 +1,8 @@
# Table of contents
- JudgeServer
- English
- [API](/JudgeServer/English/)
- [Deploy](/JudgeServer/English/deploy)
- 中文
- [API](/JudgeServer/Chinese/)
- [部署](/JudgeServer/Chinese/deploy)

View File

@ -3,3 +3,5 @@
目前此处的文档均为未公开发布版本的最新release的版本请参考github。
https://github.com/QingdaoU
<!--TOC-->

View File

@ -1,7 +0,0 @@
# 中文版本
[链接](Chinese)
# English Version
[link](English)

View File

@ -1,7 +1,4 @@
# 中文版本
[链接](Chinese)
# English Version
[link](English)
# Table of contents
- Judger
- English
- [API](/Judger/English/)