From 3363959ce77a8ee90f4a6050def1ab4ac7e9a36c Mon Sep 17 00:00:00 2001 From: Dnomd343 Date: Tue, 27 Dec 2022 17:55:18 +0800 Subject: [PATCH] update: gitbook folder --- src/release/gitbook.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/release/gitbook.py b/src/release/gitbook.py index f774d58..9c6addf 100644 --- a/src/release/gitbook.py +++ b/src/release/gitbook.py @@ -7,13 +7,13 @@ from common import loadData from common import saveFile from common import createFolder -workDir = './temp/' -contentDir = os.path.join(workDir, './content/') +workDir = './xxrs-online/' def initFolder() -> None: createFolder(workDir) - createFolder(contentDir) + createFolder(os.path.join(workDir, './assets/')) + createFolder(os.path.join(workDir, './content/')) def loadChapter(caption: str, content: list) -> str: @@ -38,7 +38,7 @@ def loadCover(metadata: dict) -> None: cover = '---\ndescription: 作者:%s\n---\n\n# %s\n\n' % (metadata['author'], metadata['name']) cover += '
\n\n' cover += '\n>\n'.join(['> %s' % x for x in metadata['desc']]) - saveFile(os.path.join(workDir, 'README.md'), cover) + saveFile(os.path.join(workDir, 'README.md'), cover + '\n') def loadSummary(catalog: dict) -> None: @@ -50,7 +50,13 @@ def loadSummary(catalog: dict) -> None: saveFile(os.path.join(workDir, 'SUMMARY.md'), summary) -initFolder() -# c = loadChapters(loadData('rc-4')['content']) -# loadSummary(c) -loadCover(loadData('rc-4')['metadata']) +def loadGitbook(jsonName: str) -> None: + data = loadData(jsonName) + loadCover(data['metadata']) + catalog = loadChapters(data['content']) + loadSummary(catalog) + + +if __name__ == '__main__': + initFolder() + loadGitbook('rc-4')