Skip to content

Commit

Permalink
fix online doc search (#2700)
Browse files Browse the repository at this point in the history
Co-authored-by: arthw <14088817+arthw@users.noreply.github.com>
  • Loading branch information
NeoZhangJianyu and arthw authored May 23, 2024
1 parent f104789 commit d687078
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions docs/build_docs/update_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,38 @@ def update_version_link(version, folder_name, index_file):
<a href="{}versions.html">{}▼</a>
<p>Click link above to switch version</p>
</div>'''.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='<script src="_static/searchtools.js"></script>'
version_list = '''<!--[if lt IE 9]>
<script src="_static/js/html5shiv.min.js"></script>
<![endif]-->
<script src="_static/jquery.js?v=5d32c60e"></script>
<script src="_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="_static/documentation_options.js?v=fc837d61"></script>
<script src="_static/doctools.js?v=9a2dae69"></script>
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="_static/js/theme.js"></script>
<script src="_static/searchtools.js"></script>'''
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))
Expand Down

0 comments on commit d687078

Please sign in to comment.