diff --git a/docs/golden_stick/docs/source_en/conf.py b/docs/golden_stick/docs/source_en/conf.py index 9971a6c62e22796c87cc7b4ba7877a0bf16a7f20..ce9dba849c5f7a34c04f5c3fc66e2e7576c0cdb4 100644 --- a/docs/golden_stick/docs/source_en/conf.py +++ b/docs/golden_stick/docs/source_en/conf.py @@ -274,81 +274,41 @@ for root,dirs,files in os.walk(src_dir_api): os.remove(os.path.join(moment_dir,file)) shutil.copy(os.path.join(src_dir_api,file),os.path.join(moment_dir,file)) -readme_path = os.path.join(os.getenv("GS_PATH"), 'README.md') - -with open(readme_path, 'r', encoding='utf-8') as f: - content = f.read() - -ind_content = 'MindSpore Golden Stick\n=============================\n' - -sc_doc = re.findall('\n## Overview\n((?:.|\n|)+?)\n## ', content) -if sc_doc: - ind_content += re.sub('!\[(.*?)\]\((.*?)\)', r'.. image:: \2', sc_doc[0]) - ind_content = re.sub('.. image:: docs/.*?/(images/.*)', r'.. image:: ./\1', ind_content) - ind_content = re.sub('\n\n> (.+)', r'\n\n.. note::\n \1', ind_content) - ind_content = re.sub('\n> (.+)', r'\n \1', ind_content) - ind_content += "\n\nCode repository address: \n" +if os.path.exists(os.path.join(moment_dir, 'index.rst')): + os.remove(os.path.join(moment_dir, 'index.rst')) + shutil.copy(os.path.join(os.getenv("GS_PATH"), 'docs/en/index.rst'), + os.path.join(moment_dir, 'index.rst')) gsdocs_image = os.path.join(os.getenv("GS_PATH"), 'docs/en/images') if not os.path.exists(os.path.join(moment_dir, 'images')): shutil.copytree(gsdocs_image, os.path.join(moment_dir, 'images')) -ind_content += """ -.. toctree:: - :glob: - :maxdepth: 1 - :caption: Installation and Deployment - - install - -""" +def extract_toctree(content): + """ + 从index.rst内容中提取所有toctree指令中的文档条目 + """ + entries = re.findall(r'^\s+([a-zA-Z0-9_\-./]+)\s*$', content, re.MULTILINE) + keywords = ['ptq/', 'quantization/', 'pruner/'] + filtered_entries = [entry for entry in entries if any(keyword in entry for keyword in keywords)] + spec_copy=[] + + for path in filtered_entries: + path_split = path.split('/') + directory = path_split[0] + filename = path_split[1] + if filename == 'overview': + gs_p = 'mindspore_gs/' + directory + '/README.md' + docs_p = directory + '/' + filename + '.md' + else: + gs_p = 'mindspore_gs/' + path + '/README.md' + docs_p = directory + '/' + filename + '.md' + spec_copy.append([gs_p, docs_p]) -toctree = [] + return spec_copy -spec_copy = [] -toctree_list = re.findall('(?:.|\n|)+?\n[ ]+?(?:.|\n|)+?', content) -if toctree_list: - for i in toctree_list: - toctree_n = re.findall('(.*?)', i) - if 'demo' in toctree_n[-1] or 'TBD' in toctree_n[-1] or toctree_n[-1] == 'Overview' or toctree_n[-1] == 'Others': - continue - toctree_p = [] - if re.findall('(.*?)<', i): - for href, name in re.findall('(.*?)<', i): - if 'demo' not in name and 'README_CN.' not in href.split('/')[-1]: - toctree_p.append('/'.join(href.split('/')[:-1])) - docs_p = '/'.join(href.replace('mindspore_gs/', '').split('/')[:-1]) + '.' + href.split('.')[-1] - spec_copy.append([href, docs_p]) - toctree.append([toctree_n[-1], toctree_p]) - -for toc_n, toc_p in toctree: - ind_content += f'.. toctree::\n :glob:\n :maxdepth: 1\n :caption: {toc_n}\n\n' - for p in toc_p: - p_new = p.replace('mindspore_gs/', '') - ind_content += f' {p_new}\n' - ind_content += '\n' - -with open(os.path.join(src_dir_api, 'index.rst'), 'r', encoding='utf-8') as f: - api_ind = f.read() - -api_toc = re.findall('.. toctree::(?:.|\n|)+', api_ind)[0] -ind_content += api_toc - -ind_content += """ -.. toctree:: - :glob: - :maxdepth: 1 - :caption: RELEASE NOTES - - RELEASE -""" -with open(os.path.join('./index.rst'), 'w', encoding='utf-8') as f: - f.write(ind_content) +with open("index.rst", 'r', encoding='utf-8') as f: + content = f.read() +spec_copy = extract_toctree(content) for gs_p, f_p in spec_copy: ori_p = os.path.join(os.getenv("GS_PATH"), gs_p) @@ -386,6 +346,26 @@ if not os.path.exists(os.path.join(moment_dir, 'install.md')): f.truncate() f.write(content) +if not os.path.exists(os.path.join(moment_dir, 'design.md')): + shutil.copy(os.path.join(os.getenv("GS_PATH"), 'docs/en/design.md'), + os.path.join(moment_dir, 'design.md')) + with open(os.path.join(moment_dir, 'design.md'), 'r+', encoding='utf-8') as f: + content = f.read() + content = re.sub('\n\[查看中文\].*\n', '', content, 1) + f.seek(0) + f.truncate() + f.write(content) + +if not os.path.exists(os.path.join(moment_dir, 'CONTRIBUTING.md')): + shutil.copy(os.path.join(os.getenv("GS_PATH"), 'CONTRIBUTING.md'), + os.path.join(moment_dir, 'CONTRIBUTING.md')) + with open(os.path.join(moment_dir, 'CONTRIBUTING.md'), 'r+', encoding='utf-8') as f: + content = f.read() + content = re.sub('\n\[查看中文\].*\n', '', content, 1) + f.seek(0) + f.truncate() + f.write(content) + # get params for add view source import json diff --git a/docs/golden_stick/docs/source_zh_cn/conf.py b/docs/golden_stick/docs/source_zh_cn/conf.py index 71681c71a05f2f40bb26597574dc9194a7a18b2a..146d0e2ef1f71eab2aa3f6155981d0fae608ce7e 100644 --- a/docs/golden_stick/docs/source_zh_cn/conf.py +++ b/docs/golden_stick/docs/source_zh_cn/conf.py @@ -289,81 +289,45 @@ for root, dirs, files in os.walk(src_dir_api): shutil.copy(root_p / file, dst) copy_list.append(str(dst)) -readme_path = os.path.join(os.getenv("GS_PATH"), 'README_CN.md') - -with open(readme_path, 'r', encoding='utf-8') as f: - content = f.read() - -ind_content = 'MindSpore Golden Stick 文档\n=============================\n' - -sc_doc = re.findall('\n## 概述\n((?:.|\n|)+?)\n## ', content) -if sc_doc: - ind_content += re.sub('!\[(.*?)\]\((.*?)\)', r'.. image:: \2', sc_doc[0]) - ind_content = re.sub('.. image:: docs/.*?/(images/.*)', r'.. image:: ./\1', ind_content) - ind_content = re.sub('\n\n> (.+)', r'\n\n.. note::\n \1', ind_content) - ind_content = re.sub('\n> (.+)', r'\n \1', ind_content) - ind_content += "\n\n代码仓地址: \n" +if os.path.exists(os.path.join(moment_dir, 'index.rst')): + os.remove(os.path.join(moment_dir, 'index.rst')) + shutil.copy(os.path.join(os.getenv("GS_PATH"), 'docs/zh_cn/index.rst'), + os.path.join(moment_dir, 'index.rst')) gsdocs_image = os.path.join(os.getenv("GS_PATH"), 'docs/zh_cn/images') if not os.path.exists(os.path.join(moment_dir, 'images')): shutil.copytree(gsdocs_image, os.path.join(moment_dir, 'images')) -ind_content += """ -.. toctree:: - :glob: - :maxdepth: 1 - :caption: 安装部署 - - install - -""" +def extract_toctree(content): + """ + 从index.rst内容中提取所有toctree指令中的文档条目 + """ + entries = re.findall(r'^\s+([a-zA-Z0-9_\-./]+)\s*$', content, re.MULTILINE) + keywords = ['ptq/', 'quantization/', 'pruner/'] + filtered_entries = [entry for entry in entries if any(keyword in entry for keyword in keywords)] + spec_copy=[] + + for path in filtered_entries: + path_split = path.split('/') + directory = path_split[0] + filename = path_split[1] + if filename == 'overview': + gs_p = 'mindspore_gs/' + directory + '/README_CN.md' + docs_p = directory + '/' + filename + '.md' + else: + if 'round_to_nearest' in filename: + gs_p = 'mindspore_gs/' + path + '/README_CN.ipynb' + docs_p = directory + '/' + filename + '.ipynb' + else: + gs_p = 'mindspore_gs/' + path + '/README_CN.md' + docs_p = directory + '/' + filename + '.md' + spec_copy.append([gs_p, docs_p]) -toctree = [] + return spec_copy -spec_copy = [] -toctree_list = re.findall('(?:.|\n|)+?\n[ ]+?(?:.|\n|)+?', content) -if toctree_list: - for i in toctree_list: - toctree_n = re.findall('(.*?)', i) - if 'demo' in toctree_n[-1] or 'TBD' in toctree_n[-1] or toctree_n[-1] == '概览' or toctree_n[-1] == '其他': - continue - toctree_p = [] - if re.findall('(.*?)<', i): - for href, name in re.findall('(.*?)<', i): - if 'demo' not in name and 'README.' not in href.split('/')[-1]: - toctree_p.append('/'.join(href.split('/')[:-1])) - docs_p = '/'.join(href.replace('mindspore_gs/', '').split('/')[:-1]) + '.' + href.split('.')[-1] - spec_copy.append([href, docs_p]) - toctree.append([toctree_n[-1], toctree_p]) - -for toc_n, toc_p in toctree: - ind_content += f'.. toctree::\n :glob:\n :maxdepth: 1\n :caption: {toc_n}\n\n' - for p in toc_p: - p_new = p.replace('mindspore_gs/', '') - ind_content += f' {p_new}\n' - ind_content += '\n' - -with open(os.path.join(src_dir_api, 'index.rst'), 'r', encoding='utf-8') as f: - api_ind = f.read() - -api_toc = re.findall('.. toctree::(?:.|\n|)+', api_ind)[0] -ind_content += api_toc - -ind_content += """ -.. toctree:: - :glob: - :maxdepth: 1 - :caption: RELEASE NOTES - - RELEASE -""" -with open(os.path.join('./index.rst'), 'w', encoding='utf-8') as f: - f.write(ind_content) +with open("index.rst", 'r', encoding='utf-8') as f: + content = f.read() +spec_copy = extract_toctree(content) for gs_p, f_p in spec_copy: ori_p = os.path.join(os.getenv("GS_PATH"), gs_p) @@ -454,6 +418,26 @@ if not os.path.exists(os.path.join(moment_dir, 'install.md')): f.truncate() f.write(content) +if not os.path.exists(os.path.join(moment_dir, 'design.md')): + shutil.copy(os.path.join(os.getenv("GS_PATH"), 'docs/zh_cn/design.md'), + os.path.join(moment_dir, 'design.md')) + with open(os.path.join(moment_dir, 'design.md'), 'r+', encoding='utf-8') as f: + content = f.read() + content = re.sub('\n\[View English\].*\n', '', content, 1) + f.seek(0) + f.truncate() + f.write(content) + +if not os.path.exists(os.path.join(moment_dir, 'CONTRIBUTING.md')): + shutil.copy(os.path.join(os.getenv("GS_PATH"), 'CONTRIBUTING_CN.md'), + os.path.join(moment_dir, 'CONTRIBUTING.md')) + with open(os.path.join(moment_dir, 'CONTRIBUTING.md'), 'r+', encoding='utf-8') as f: + content = f.read() + content = re.sub('\n\[View English\].*\n', '', content, 1) + f.seek(0) + f.truncate() + f.write(content) + sys.path.append(os.path.abspath('../../../../resource/sphinx_ext')) import nbsphinx_mod diff --git a/tools/generate_html/daily.json b/tools/generate_html/daily.json index aacf410e770d6bdeb97744ddb7e8e13d289314ca..796aeb7a1b6405679e9d4697e28e37d74edc4f8d 100644 --- a/tools/generate_html/daily.json +++ b/tools/generate_html/daily.json @@ -43,6 +43,15 @@ }, { "id" : 5 , + "name" : "golden_stick", + "branch" : "master", + "whl_path" : "/golden-stick/newest/any/", + "whl_name" : "mindspore_gs-.*-py3-none-any.whl$", + "environ" : "GS_PATH", + "uninstall_name" : "mindspore_gs" +}, +{ + "id" : 6 , "name" : "mindchemistry", "branch" : "master", "whl_path" : "/mindscience/website/mindchemistry/gpu/x86_64/cuda-11.1/", @@ -51,7 +60,7 @@ "uninstall_name" : "mindchemistry_gpu" }, { - "id" : 6 , + "id" : 7 , "name" : "mindformers", "branch" : "master", "whl_search" : "any/", @@ -63,7 +72,7 @@ "extra_whl_name" : "mindspore-.*-cp39-cp39-linux_x86_64.whl$" }, { - "id" : 7 , + "id" : 8 , "name" : "vllm_mindspore", "branch" : "master", "whl_path" : "", @@ -72,7 +81,7 @@ "uninstall_name" : "" }, { - "id" : 8 , + "id" : 9 , "name" : "mindstudio", "branch" : "master", "whl_path" : "", @@ -81,7 +90,7 @@ "uninstall_name" : "" }, { - "id" : 9 , + "id" : 10 , "name" : "msadapter", "branch" : "master", "whl_path" : "", @@ -90,7 +99,7 @@ "uninstall_name" : "" }, { - "id" : 10 , + "id" : 11 , "name" : "mindquantum", "branch" : "master", "whl_path" : "/mindquantum/newest/gpu/x86_64/cuda-11.1/",