From d6870780992adc1ae353014d2b2dd2aab82539ba Mon Sep 17 00:00:00 2001 From: Neo Zhang Jianyu Date: Thu, 23 May 2024 10:42:43 +0800 Subject: [PATCH] fix online doc search (#2700) Co-authored-by: arthw <14088817+arthw@users.noreply.github.com> --- docs/build_docs/update_html.py | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/docs/build_docs/update_html.py b/docs/build_docs/update_html.py index 3822119d7..dc8683f98 100644 --- a/docs/build_docs/update_html.py +++ b/docs/build_docs/update_html.py @@ -28,19 +28,38 @@ def update_version_link(version, folder_name, index_file): {}▼

Click link above to switch version

'''.format(index_path, folder_name) - #print(index_buf.find(key_str)) index_buf = index_buf.replace(key_str, version_list) - #print(index_buf) with open(index_file, "w") as f: f.write(index_buf) +def update_search(folder): + search_file_name="{}/search.html".format(folder) + + with open(search_file_name, "r") as f: + index_buf = f.read() + key_str='' + version_list = ''' + + + + + + + ''' + index_buf = index_buf.replace(key_str, version_list) + + with open(search_file_name, "w") as f: + f.write(index_buf) + def main(folder, version): folder_name=os.path.basename(folder) for index_file in glob.glob('{}/**/*.html'.format(folder),recursive = True): update_version_link(version, folder_name, index_file) - + update_search(folder) def help(me): print("python {} html_folder version".format(me))