From 9f4a1d8680e9656c16964f8bc6395bca70e1124e Mon Sep 17 00:00:00 2001 From: yuhan Date: Fri, 25 Jul 2025 09:24:10 +0800 Subject: [PATCH] modify config --- docs/lite/api/_custom/graph | 23 +++++++++++----- docs/lite/api/lite_api_filter.py | 2 +- docs/lite/api/source_en/conf.py | 42 +++++++++++++++++++++++++++-- docs/mindspore/source_zh_cn/conf.py | 21 ++++++++------- resource/sphinx_ext/anchor_mod.py | 2 +- resource/sphinx_ext/nbsphinx_mod.py | 2 +- 6 files changed, 71 insertions(+), 21 deletions(-) diff --git a/docs/lite/api/_custom/graph b/docs/lite/api/_custom/graph index 360a5b0e48..adf0c0f4e0 100644 --- a/docs/lite/api/_custom/graph +++ b/docs/lite/api/_custom/graph @@ -2148,7 +2148,7 @@ class ExhaleRoot(object): os.remove(dirB+file) title = re.compile(r'[\s\n\S]*=====') - content = re.compile(r'(Classes|Functions|Enums|Typedefs)([\s\n\S]*)') + content = re.compile(r'(Classes|Functions|Enums|Type Definition|Structs)([\s\n\S]*)') for file in os.listdir(dirB): with open(dirB+file, "r", encoding="utf-8") as f: data = f.read() @@ -3024,10 +3024,13 @@ MindSpore Lite API The string to be written to the namespace node's reStructuredText document. ''' # sort the children - nsp_namespaces = [] - nsp_nested_class_like = [] - nsp_enums = [] - nsp_functions = [] + nsp_namespaces = [] + nsp_nested_class_like = [] + nsp_nested_struct_like = [] + nsp_enums = [] + nsp_functions = [] + nsp_typedefs = [] + for child in nspace.children: # Skip children whose names were requested to be explicitly ignored. should_exclude = False @@ -3041,18 +3044,24 @@ MindSpore Lite API nsp_namespaces.append(child) elif child.kind == "class": child.findNestedClassLike(nsp_nested_class_like) - child.findNestedEnums(nsp_enums) + # child.findNestedEnums(nsp_enums) + elif child.kind == "struct": + child.findNestedClassLike(nsp_nested_struct_like) elif child.kind == "enum": nsp_enums.append(child) elif child.kind == "function": nsp_functions.append(child) + elif child.kind == "typedef": + nsp_typedefs.append(child) # generate their headings if they exist (no Defines...that's not a C++ thing...) children_stream = StringIO() self.generateSortedChildListString(children_stream, "Namespaces", nsp_namespaces) self.generateSortedChildListString(children_stream, "Classes", nsp_nested_class_like) + self.generateSortedChildListString(children_stream, "Structs", nsp_nested_struct_like) self.generateSortedChildListString(children_stream, "Enums", nsp_enums) self.generateSortedChildListString(children_stream, "Functions", nsp_functions) + self.generateSortedChildListString(children_stream, "Type Definition", nsp_typedefs) # read out the buffer contents, close it and return the desired string children_string = children_stream.getvalue() children_stream.close() @@ -3096,6 +3105,8 @@ MindSpore Lite API for l in lst: if spec.spec_apis and l.kind == "class" and l.name not in spec.class_list: continue + if '910' in l.name or '310' in l.name: + continue stream.write(textwrap.dedent(''' - :ref:`{link}` '''.format(link=l.link_name))) diff --git a/docs/lite/api/lite_api_filter.py b/docs/lite/api/lite_api_filter.py index bd15ae1406..0443d5db91 100644 --- a/docs/lite/api/lite_api_filter.py +++ b/docs/lite/api/lite_api_filter.py @@ -14,7 +14,7 @@ def lite_class_filter(file): filename = os.path.basename(file) white_files = [ "data_type.h", "format.h", "data_type_c.h", "format_c.h", - "opencl_runtime_wrapper.h", "dual_abi_helper.h" + "opencl_runtime_wrapper.h", "dual_abi_helper.h", "delegate_api.h" ] if filename in white_files\ or "MS_API" in content or "MIND_API" in content or "DATASET_API" in content or "/callback/" in file: diff --git a/docs/lite/api/source_en/conf.py b/docs/lite/api/source_en/conf.py index b9ccde4eb6..a2b131c1b5 100644 --- a/docs/lite/api/source_en/conf.py +++ b/docs/lite/api/source_en/conf.py @@ -228,7 +228,7 @@ exhale_args = { ############################################################################ # Example of adding contents directives on custom kinds with custom title "contentsTitle": "Page Contents", - "kindsWithContentsDirectives": ["class", "file", "namespace", "struct"], + "kindsWithContentsDirectives": ["class", "file", "namespace", "struct", "enum", "typedef", "define"], # Exclude PIMPL files from class hierarchy tree and namespace pages. # "listingExclude": [r".*Impl$"], ############################################################################ @@ -310,7 +310,7 @@ try: ("mindspore_lite/converter.py","del decorator", "@set_env","# generate api by del decorator set_env."), ("mindspore_lite/llm_engine.py","del decorator", - "@set_env","# generate api by del decorator set_env.")] + "@set_env","# generate api by del decorator set_env.")] for i in decorator_list: with open(os.path.join(base_path, os.path.normpath(i[0])), "r+", encoding="utf8") as f: @@ -439,6 +439,44 @@ for file_name in fileList: with open(file_name, 'w', encoding='utf-8') as p: p.write(data) +# 查找同名文件并优先删除converter的头文件 +def find_common_files2del(folder1, folder2): + files1 = {} + files2 = {} + + # 遍历第一个文件夹 + for root, _, filenames in os.walk(folder1): + for filename in filenames: + if filename not in files1: + files1[filename] = [] + files1[filename].append(os.path.join(root, filename)) + + # 遍历第二个文件夹 + for root, _, filenames in os.walk(folder2): + for filename in filenames: + if filename not in files2: + files2[filename] = [] + files2[filename].append(os.path.join(root, filename)) + + # 找出两个文件夹中都存在的文件名 + common_files = set(files1.keys()) & set(files2.keys()) + + # 删除runtime和converter的同名文件(删除converter的) + print('删除runtime和converter的同名文件如下:') + for f in common_files: + for path1 in files1[f]: + for path2 in files2[f]: + if path1.rsplit('/include/')[-1] == path2.rsplit('/include/')[-1]: + print(path2) + os.remove(path2) + +# 两个文件夹路径 +folder_runtime = '../include/runtime/include' +folder_converter = '../include/converter/include' + +# 查找同名文件并删除converter下的 +find_common_files2del(folder_runtime, folder_converter) + # for file_name in fileList: # file_data = '' # with open(file_name, 'r', encoding='utf-8') as f: diff --git a/docs/mindspore/source_zh_cn/conf.py b/docs/mindspore/source_zh_cn/conf.py index c9037cb406..e7fa7d8d82 100644 --- a/docs/mindspore/source_zh_cn/conf.py +++ b/docs/mindspore/source_zh_cn/conf.py @@ -474,16 +474,17 @@ except Exception as e: print(e) # 删除mint接口文件中CPU/GPU相关的无序列表内容 -for f_name in os.listdir("./api_python/mint"): - with open(os.path.join("./api_python/mint", f_name), 'r+', encoding='utf-8') as f: - mint_content = f.read() - if re.findall('\n[ ]+- (CPU:|GPU:|CPU/GPU:|GPU/CPU:)', mint_content): - print(f'{f_name}内有CPU/GPU相关内容,已删除') - blank_num = re.findall('\n([ ]+)- (CPU:|GPU:|CPU/GPU:|GPU/CPU:)', mint_content)[0][0] - mint_content = re.sub(f'\n[ ]+- (CPU:|GPU:|CPU/GPU:|GPU/CPU:)(?:.|\n|)+?(\n\n|\n{blank_num}-)', r'\2', mint_content) - f.seek(0) - f.truncate() - f.write(mint_content) +if os.path.exists("./api_python/mint"): + for f_name in os.listdir("./api_python/mint"): + with open(os.path.join("./api_python/mint", f_name), 'r+', encoding='utf-8') as f: + mint_content = f.read() + if re.findall('\n[ ]+- (CPU:|GPU:|CPU/GPU:|GPU/CPU:)', mint_content): + print(f'{f_name}内有CPU/GPU相关内容,已删除') + blank_num = re.findall('\n([ ]+)- (CPU:|GPU:|CPU/GPU:|GPU/CPU:)', mint_content)[0][0] + mint_content = re.sub(f'\n[ ]+- (CPU:|GPU:|CPU/GPU:|GPU/CPU:)(?:.|\n|)+?(\n\n|\n{blank_num}-)', r'\2', mint_content) + f.seek(0) + f.truncate() + f.write(mint_content) from myautosummary import MsPlatformAutoSummary, MsNoteAutoSummary, MsCnAutoSummary, MsCnPlatformAutoSummary, MsCnNoteAutoSummary, MsCnPlatWarnAutoSummary, MsCnPlataclnnAutoSummary diff --git a/resource/sphinx_ext/anchor_mod.py b/resource/sphinx_ext/anchor_mod.py index d7ee86be66..158adb4309 100644 --- a/resource/sphinx_ext/anchor_mod.py +++ b/resource/sphinx_ext/anchor_mod.py @@ -16,7 +16,7 @@ def short_title(titlename): titlename = titlename.replace(j, '') for k in spec_symbol: titlename = titlename.replace(k, ' ') - titlename = titlename.replace(' ', ' ').replace(' ', '-').replace('"', '') + titlename = titlename.replace(' ', ' ').replace(' ', '-').replace('"', '').replace("'", "") return titlename ''' diff --git a/resource/sphinx_ext/nbsphinx_mod.py b/resource/sphinx_ext/nbsphinx_mod.py index f95b18f3e1..0a6df9c7d1 100644 --- a/resource/sphinx_ext/nbsphinx_mod.py +++ b/resource/sphinx_ext/nbsphinx_mod.py @@ -19,7 +19,7 @@ def short_title(titlename): titlename = titlename.replace(j, '') for k in spec_symbol: titlename = titlename.replace(k, ' ') - titlename = titlename.replace(' ', ' ').replace(' ', '-') + titlename = titlename.replace(' ', ' ').replace(' ', '-').replace('"', '').replace("'", "") return titlename ''' -- Gitee