From 1548ec12d52edbeda14448d66f4db18dd57271cf Mon Sep 17 00:00:00 2001 From: zhengshanshan Date: Fri, 24 May 2024 10:22:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=8D=A2=E4=B8=BB=E9=A2=98=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E6=94=B9makefile=E6=96=87=E4=BB=B6=EF=BC=8C=E5=8F=AF?= =?UTF-8?q?=E4=BB=A5=E6=94=AF=E6=8C=81=E7=94=BB=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 22 ++++- source/_static/custom.css | 70 +++++++++++++++ source/_static/init_mermaid.js | 3 + source/_static/topbar.css | 103 ++++++++++++++++++---- source/_templates/_layout.html | 26 ------ source/_templates/versions.html | 150 ++++++++++++++++++++++++-------- source/conf.py | 40 +++++---- 7 files changed, 316 insertions(+), 98 deletions(-) create mode 100644 source/_static/custom.css create mode 100644 source/_static/init_mermaid.js delete mode 100644 source/_templates/_layout.html diff --git a/Makefile b/Makefile index 3101695..b438183 100644 --- a/Makefile +++ b/Makefile @@ -8,6 +8,7 @@ SPHINXBUILD ?= sphinx-build SPHINXMULTIVERSION ?= sphinx-multiversion SOURCEDIR = source BUILDDIR = build +WEB_DOCS_BUILDER_URL ?= https://ai.b-bug.org/~zhengshanshan/web-docs-builder # Put it first so that "make" without argument is like "make help". help: @@ -19,8 +20,25 @@ help: # Catch-all target: route all unknown targets to Sphinx using the new # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). -%: Makefile +%: Makefile $(SOURCEDIR)/_templates/versions.html $(SOURCEDIR)/_static/topbar.css $(SOURCEDIR)/_static/custom.css $(SOURCEDIR)/_static/init_mermaid.js @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) -mhtml: +mhtml: Makefile $(SOURCEDIR)/_templates/versions.html $(SOURCEDIR)/_static/topbar.css $(SOURCEDIR)/_static/custom.css $(SOURCEDIR)/_static/init_mermaid.js @$(SPHINXMULTIVERSION) "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +_templates: + mkdir -p $(SOURCEDIR)/_templates + +$(SOURCEDIR)/_templates/versions.html: + wget $(WEB_DOCS_BUILDER_URL)/_templates/$(@F) -O $@ + +$(SOURCEDIR)/_static/topbar.css: + wget $(WEB_DOCS_BUILDER_URL)/_static/$(@F) -O $@ + +$(SOURCEDIR)/_static/custom.css: + wget $(WEB_DOCS_BUILDER_URL)/_static/$(@F) -O $@ + +$(SOURCEDIR)/_static/init_mermaid.js: + wget $(WEB_DOCS_BUILDER_URL)/_static/$(@F) -O $@ + + diff --git a/source/_static/custom.css b/source/_static/custom.css new file mode 100644 index 0000000..6404d7c --- /dev/null +++ b/source/_static/custom.css @@ -0,0 +1,70 @@ +nav.bd-links li>a:active, .logo__title:hover, nav.bd-links li>a:hover { + color:#4d8eef !important; + text-decoration: none; +} +body { + overflow-y: scroll !important; + scrollbar-width: none !important; /* Firefox */ + -ms-overflow-style: none !important; /* IE 和 Edge */ +} +/* 针对Webkit内核浏览器(如Chrome和Safari)隐藏滚动条 */ +body::-webkit-scrollbar { + width: 0 !important; /* 隐藏垂直滚动条 */ + height: 0 !important; /* 隐藏水平滚动条 */ +} +.bd-sidebar-primary { +/* 使元素可滚动 */ +overflow-y: scroll; /* 垂直滚动条 */ +overflow-x: hidden; /* 隐藏水平滚动条,如果不需要的话 */ + +/* 隐藏滚动条但保持滚动功能 */ +scrollbar-width: none; /* Firefox */ +-ms-overflow-style: none; /* Internet Explorer 和 Edge */ +} + +/* 针对Webkit内核的浏览器(如Chrome、Safari)隐藏滚动条 */ +.bd-sidebar-primary::-webkit-scrollbar { +display: none; /* 隐藏滚动条 */ +} +.search-button-field:hover { + border:1px solid #4d8eef !important; +} +.toc-entry a.nav-link:active, .toc-entry a.nav-link:hover { +color: #0d6efd; +text-decoration: none; +} +.toc-entry a.nav-link.active:hover { +color: #0d6efd !important; +} +.bd-sidebar-primary label.toctree-toggle { +height: 20px; +width: 20px; +opacity: 0.8; +} +html[data-theme=dark], html[data-theme=light] { +--pst-color-secondary: #0d6efd !important; +} +.navbar-brand:hover:hover, .navbar-brand:visited:hover:hover { +text-decoration: none !important; +} +.bd-sidebar-primary label.toctree-toggle { +height: 20px; +width: 20px; +} +#pst-back-to-top { +background-color: #0d6efd; +} +.form-control:focus, .form-control:focus-visible { +outline: 1px solid #0d6efd; +} +.bd-search .search-button__kbd-shortcut { +display: none; +} +.bd-search svg{ +position: absolute; +left: -1000px; +} +.bd-search { +padding-left: 0; +border: none; +} \ No newline at end of file diff --git a/source/_static/init_mermaid.js b/source/_static/init_mermaid.js new file mode 100644 index 0000000..e9d4342 --- /dev/null +++ b/source/_static/init_mermaid.js @@ -0,0 +1,3 @@ +document.addEventListener('DOMContentLoaded', function() { + mermaid.initialize({startOnLoad:true}); +}); diff --git a/source/_static/topbar.css b/source/_static/topbar.css index 63bf49a..bd66107 100644 --- a/source/_static/topbar.css +++ b/source/_static/topbar.css @@ -1,13 +1,18 @@ /* Customize for top bar (testing and outdated docs)*/ +:target { + scroll-margin-top: 50px; +} + .wy-nav-side { - margin-top: 47px !important; + min-height: calc(100% - 50px); + top: 50px; } .wy-nav-content-wrap { - margin-top: 47px !important; + margin-top: 50px !important; } /* The navigation bar */ @@ -24,16 +29,11 @@ nav.navbar { nav.navbar a { float: left; display: block; - color: #f2f2f2; + color: rgba(255,255,255,0.5); text-align: center; padding: 14px 16px; text-decoration: none; -} - -/* Change background on mouse-over */ -nav.navbar a:hover { - background: #ddd; - color: black; + text-wrap: nowrap; } .jn_container-view { @@ -43,7 +43,7 @@ nav.navbar a:hover { position: fixed; left: 0; top: 0; - z-index: 1501 + z-index: 1501; } .jn_menu-container { @@ -60,20 +60,44 @@ nav.navbar a:hover { width: 157px; height: 28px; background: url(img/logo.2f7049e2.svg) no-repeat 100%; - background-size: auto 100% + background-size: auto 100%; } .jn_menu-container .menu-list { display: flex; + height: 100%; font-size: 16px; - color: hsla(0, 0%, 100%, .4); - margin-left: 125px + color: rgba(255,255,255,0.4); + margin-left: 78px; + max-width: 506px; } -.jn_menu-container .menu-item { - margin-right: 40px; +.menu-list .menu-item { + margin-right: 30px; height: 100%; - cursor: pointer + cursor: pointer; + display: flex; + align-items: center; +} + +@media (max-width: 768px) { + .logo { + display: none; + } + + .menu-list .menu-item { + margin-right: 0; + } + + .jn_menu-container .menu-list { + margin-left: 0; + justify-content: space-around; + flex-grow: 1; + } + + nav.navbar a { + padding: 3px; + } } .jn_menu-container .menu-item.active a { @@ -85,7 +109,7 @@ nav.navbar a:hover { } .jn_menu-container .active, -.jn_menu-container .menu-item:hover { +.jn_menu-container .menu-item a:hover { color: #fff } @@ -106,3 +130,48 @@ nav.navbar a:hover { display: block; cursor: pointer } + +.menu-doc a { + color: #f2f2f2 !important; +} + +.model-list { + position: absolute; + top: 50px; + background: #0d0d0d; + display: none; + cursor: pointer; + flex-direction: column; +} + +.menu-doc:hover > .model-list { + display: flex; + align-items: center; +} + +.document-select { + padding: 10px !important; + color: #fff; + text-align: start !important; + text-wrap: wrap !important; +} + +.document-select:hover { + background-color: #249ee8 !important; +} + +.expanded-menu { + position: relative; +} +.expanded-menu-container { + display: none; + flex-direction: column; + position: absolute; + top: 0; + right: -120px; + width: 120px; + background-color: #0d0d0d; +} +.expanded-menu:hover .expanded-menu-container { + display: flex; +} diff --git a/source/_templates/_layout.html b/source/_templates/_layout.html deleted file mode 100644 index 9fa8aad..0000000 --- a/source/_templates/_layout.html +++ /dev/null @@ -1,26 +0,0 @@ -{% extends "sphinx_rtd_theme/layout.html" %} - -{%block extrabody %} - - - -{{ super() }} - -{% endblock extrabody %} diff --git a/source/_templates/versions.html b/source/_templates/versions.html index 9325933..1c905c7 100644 --- a/source/_templates/versions.html +++ b/source/_templates/versions.html @@ -1,36 +1,116 @@ -{%- if current_version %} -
- - Versions - {{ current_version.name }} - - -
- {%- if versions.tags %} -
-
Tags
- {%- for item in versions.tags %} -
{{ item.name }}
- {%- endfor %} -
- {%- endif %} - {%- if versions.branches %} -
-
Branches
- {%- for item in versions.branches %} -
{{ item.name }}
- {%- endfor %} -
-
-
External links
-
- CanMV -
-
- CanMV Docs -
-
- {%- endif %} + + {%- if current_version %} +
+ + + {{ current_version.name }} + + +
+ + {%- if versions.tags %} +
+
Tags
+ {%- for item in versions.tags %} +
{{ item.name }}
+ {%- endfor %} +
+ {%- endif %} + {%- if versions.branches %} +
+
Branches
+ {%- for item in versions.branches %} +
{{ item.name }}
+ {%- endfor %} +
+
+
External links
+
+ K210 CanMV +
+
+ K210 CanMV Docs +
+
+ K230 Docs +
+
+ K230 CanMV Docs +
+
+ {%- endif %} +
-
-{%- endif %} + {%- endif %} + + \ No newline at end of file diff --git a/source/conf.py b/source/conf.py index 79d8201..4108f43 100644 --- a/source/conf.py +++ b/source/conf.py @@ -4,7 +4,6 @@ # https://www.sphinx-doc.org/en/master/usage/configuration.html import sys, os -import sphinx_rtd_theme sys.path.append(os.path.abspath('exts')) @@ -20,11 +19,24 @@ # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration extensions = [ + 'sphinx_copybutton', 'myst_parser', - 'sphinx_rtd_dark_mode', - 'sphinx_multiversion' + 'sphinx_multiversion', + 'sphinxcontrib.mermaid' ] +html_js_files = [ + 'https://cdnjs.cloudflare.com/ajax/libs/mermaid/8.13.8/mermaid.min.js', + 'init_mermaid.js', +] + +html_static_path = ['_static'] + +source_suffix = { + '.rst': 'restructuredtext', + '.md': 'markdown', +} + templates_path = ['_templates'] exclude_patterns = [] @@ -44,27 +56,19 @@ # html_show_sphinx = False # html_theme = 'alabaster' -html_theme = "sphinx_rtd_theme" +html_theme = "sphinx_book_theme" html_static_path = ['_static'] +html_sidebars = { + '**':['navbar-logo.html','search-field.html','sbt-sidebar-nav.html', 'versions.html'], +} +html_copy_source = True +html_show_sourcelink = False # if want to add top nav for canann, enable this. # html_css_files = ['topbar.css'] - -default_dark_mode = True +html_css_files = ['topbar.css', 'custom.css'] html_theme_options = { - # 'analytics_id': 'G-XXXXXXXXXX', # Provided by Google in your dashboard - # 'analytics_anonymize_ip': False, - # 'logo_only': False, - 'display_version': True, - 'prev_next_buttons_location': 'bottom', - 'style_external_links': False, - 'vcs_pageview_mode': '', - # 'style_nav_header_background': '#2980B9', - # Toc options 'collapse_navigation': True, - 'sticky_navigation': True, 'navigation_depth': 7, - 'includehidden': True, - 'titles_only': False }