2 Star 2 Fork 0

czy21/script

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
main.py 1.85 KB
一键复制 编辑 原始数据 按行查看 历史
czy21 提交于 2024-06-01 16:22 . # read env like spring property load way
import logging
import pathlib
import shutil
from server import share
from utility import file as file_util, template as template_util
def collect_doc(source_name):
source_dir = root_path.joinpath("server/{0}".format(source_name))
share.execute("cd {0} && rm -rf build && sh main.sh {1} build --target doc --env-active public --all-namespace".format(source_dir.as_posix(), "local"))
source_build_dir = source_dir.joinpath("build")
target_dir = doc_public.joinpath(source_name)
shutil.rmtree(target_dir, ignore_errors=True)
namespaces = []
for s in filter(lambda f: f.is_dir(), source_build_dir.iterdir()):
roles = []
for sd in filter(lambda f: f.is_file, s.rglob("**/output/doc.md")):
t = target_dir.joinpath("{}/{}.md".format(s.name, sd.parent.parent.parent.name))
role_name = sd.parent.parent.parent.name
roles.append({"name": role_name, "file": "{}/{}/{}.md".format(source_name, s.name, role_name)})
file_util.copy(sd, t)
roles.sort(key=lambda k: k.get('name'))
if roles:
namespaces.append({"namespace": s.name, "roles": roles})
namespaces.sort(key=lambda k: k.get('namespace'))
return namespaces
logger = logging.getLogger()
# sh toolchain.sh -h user@host build --target doc --env-active public --all-namespace
if __name__ == '__main__':
logger.setLevel(logging.DEBUG)
root_path = pathlib.Path(__file__).parent
mkdocs = root_path.joinpath("mkdocs.yaml")
doc = root_path.joinpath("doc")
doc_public = doc.joinpath("public")
mkdocs_template = doc.joinpath("mkdocs_template.yaml")
mkdocs_text = template_util.Template(file_util.read_text(mkdocs_template)).render(
**{
"param_doc_nav": dict([t.capitalize(), collect_doc(t)] for t in ["docker", "chart"])
}
)
file_util.write_text(mkdocs, mkdocs_text)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/czy21/script.git
git@gitee.com:czy21/script.git
czy21
script
script
master

搜索帮助

D67c1975 1850385 1daf7b77 1850385