Skip to content

Commit

Permalink
fix online doc search issue (#1975)
Browse files Browse the repository at this point in the history
Co-authored-by: ZhangJianyu <[email protected]>
  • Loading branch information
NeoZhangJianyu and arthw authored Aug 13, 2024
1 parent 7056720 commit 3845cdc
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 6 deletions.
2 changes: 2 additions & 0 deletions docs/build_docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@
"sphinx.ext.coverage",
"sphinx.ext.autosummary",
"sphinx_md",
"sphinx_rtd_theme",
"autoapi.extension",
"sphinx.ext.napoleon",
"sphinx.ext.githubpages",
"sphinx.ext.linkcode",
"sphinxcontrib.jquery",
]

autoapi_dirs = ["../../neural_compressor"]
Expand Down
16 changes: 10 additions & 6 deletions docs/build_docs/sphinx-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
recommonmark
sphinx==6.1.1
sphinx-autoapi
sphinx-markdown-tables
sphinx-md
sphinx_rtd_theme
recommonmark==0.7.1
setuptools_scm[toml]==8.1.0
sphinx==7.3.7
sphinx-autoapi==3.1.0
sphinx-autobuild==2024.4.16
sphinx-markdown-tables==0.0.17
sphinx-md==0.0.4
sphinx_rtd_theme==2.0.0
sphinxcontrib-jquery==4.1
sphinxemoji==0.3.1
23 changes: 23 additions & 0 deletions docs/build_docs/update_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,34 @@ def update_source_url(version, folder_name, index_file):
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_source_url(version, folder_name, index_file)
update_search(folder)


def help(me):
Expand Down

0 comments on commit 3845cdc

Please sign in to comment.