diff --git a/docs/lite/api/source_en/conf.py b/docs/lite/api/source_en/conf.py index 0b7626caba3391b63a4675e07efb87b118ff6356..015f118e8f9dfc49eb092467b2ea4bbb95108110 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: