From e2b050c04823d4f2e58c20ab14e4b4a872f3e6bf Mon Sep 17 00:00:00 2001 From: myprigitee Date: Tue, 16 Dec 2025 14:59:26 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3lite=E6=96=87=E6=A1=A3?= =?UTF-8?q?=E9=83=A8=E5=88=86=E9=A1=B5=E9=9D=A2=E5=86=85=E5=AE=B9=E7=94=9F?= =?UTF-8?q?=E6=88=90=E9=94=99=E8=AF=AF=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/lite/api/source_en/conf.py | 61 +++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/docs/lite/api/source_en/conf.py b/docs/lite/api/source_en/conf.py index 0b7626caba..015f118e8f 100644 --- a/docs/lite/api/source_en/conf.py +++ b/docs/lite/api/source_en/conf.py @@ -592,6 +592,67 @@ folder_converter = '../include/converter/include' # 查找同名文件并删除converter下的 find_common_files2del(folder_runtime, folder_converter) +# 解决lite页面内容生成错误问题 +def code_content_replace(original_code, new_code, file_path): + try: + with open(file_path, "r", encoding="utf-8") as f: + content = f.read() + except Exception as e: + print(f"读取文件失败:{e}") + return False + modified_content = content.replace(original_code, new_code) + if modified_content: + print("找到完全匹配的代码块,执行精准替换") + + try: + with open(file_path, "w", encoding="utf-8") as f: + f.write(modified_content) + print(f"文件修改完成!路径:{file_path}") + return True + except Exception as e: + print(f"写入文件失败:{e}") + return False + +original_code = ''' +using Key = struct MS_API Key { + size_t max_key_len = 32; + size_t len = 0; + unsigned char key[32] = {0}; + Key() : len(0) {} + explicit Key(const char *dec_key, size_t key_len); +};''' +new_code = ''' +struct MS_API Key { + size_t max_key_len = 32; + size_t len = 0; + unsigned char key[32] = {0}; + Key() : len(0) {} + explicit Key(const char *dec_key, size_t key_len); +}; + +using Key = Key;''' +types_h_path = "../include/runtime/include/api/types.h" +code_content_replace(original_code, new_code, types_h_path) + +original_code = ''' +/// \\brief Get the value with the given type from a node if it is a ValueNode.''' +new_code = ''' +/// \\overload // Tell Doxygen that this is an independent overload and generate a separate entry +/// \\brief Get the value with the given type from a node if it is a ValueNode.''' +anf_h_path = "../include/converter/include/mindapi/ir/anf.h" +code_content_replace(original_code, new_code, anf_h_path) + +original_code = '''using CreateKernel = std::function( + const std::vector &inputs, const std::vector &outputs, const schema::Primitive *primitive, + const mindspore::Context *ctx)>;''' +new_code = '''std::shared_ptr CreateKernel( + const std::vector &inputs, const std::vector &outputs, const schema::Primitive *primitive, + const mindspore::Context *ctx); + +using CreateKernel = std::function;''' +register_kernel_h_path = "../include/runtime/include/registry/register_kernel.h" +code_content_replace(original_code, new_code, register_kernel_h_path) + # for file_name in fileList: # file_data = '' # with open(file_name, 'r', encoding='utf-8') as f: -- Gitee