docs: polish doc styling and add copy buttons

This commit is contained in:
ob-yalian
2026-03-26 14:42:28 +08:00
parent b332fae572
commit d7463e4aef
5 changed files with 609 additions and 6 deletions
+5
View File
@@ -54,6 +54,7 @@ master_doc = 'index'
# ones. # ones.
extensions = ['recommonmark', extensions = ['recommonmark',
'sphinx_markdown_tables', 'sphinx_markdown_tables',
'sphinx_copybutton',
'sphinx.ext.autosectionlabel', 'sphinx.ext.autosectionlabel',
'language_switch', 'language_switch',
# 'myst_parser', # 'myst_parser',
@@ -183,6 +184,10 @@ html_last_updated_fmt = "%Y-%m-%d %H:%M:%S"
# 是否显示页面下方的由sphinx创建, 默认为True # 是否显示页面下方的由sphinx创建, 默认为True
html_show_sphinx = False html_show_sphinx = False
copybutton_exclude = '.linenos, .gp, .go'
copybutton_prompt_text = r'>>> |\.\.\. |\$ |# '
copybutton_prompt_is_regexp = True
# Function to copy video files to output directory # Function to copy video files to output directory
def setup(app): def setup(app):
app.connect('build-finished', copy_videos) app.connect('build-finished', copy_videos)
+299 -3
View File
@@ -43,7 +43,303 @@
.lang-switch { .lang-switch {
top: 10px !important; top: 10px !important;
right: 10px !important; right: 10px !important;
font-size: 0.8em !important; font-size: 0.8em !important;
padding: 6px 8px !important; padding: 6px 8px !important;
} }
} }
/* Markdown-like reading experience for the main content area. */
.wy-body-for-nav {
background: #f6f8fa !important;
}
.wy-nav-content-wrap {
background: #f6f8fa !important;
}
.wy-nav-content {
max-width: 960px !important;
margin: 28px auto !important;
padding: 40px 56px 56px !important;
background: #ffffff !important;
border: 1px solid #d8dee4 !important;
border-radius: 18px !important;
box-shadow: 0 1px 3px rgba(31, 35, 40, 0.08), 0 12px 32px rgba(31, 35, 40, 0.08) !important;
}
.wy-nav-content .rst-content {
color: #24292f !important;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif !important;
font-size: 16px !important;
line-height: 1.75 !important;
}
.wy-nav-content .rst-content h1,
.wy-nav-content .rst-content h2,
.wy-nav-content .rst-content h3,
.wy-nav-content .rst-content h4,
.wy-nav-content .rst-content h5,
.wy-nav-content .rst-content h6 {
color: #1f2328 !important;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif !important;
font-weight: 700 !important;
letter-spacing: -0.02em !important;
}
.wy-nav-content .rst-content h1 {
font-size: 2.15rem !important;
line-height: 1.25 !important;
margin: 0 0 1rem !important;
padding-bottom: 0.45rem !important;
border-bottom: 1px solid #d8dee4 !important;
}
.wy-nav-content .rst-content h2 {
font-size: 1.7rem !important;
line-height: 1.35 !important;
margin-top: 2.3rem !important;
margin-bottom: 1rem !important;
padding-bottom: 0.35rem !important;
border-bottom: 1px solid #d8dee4 !important;
}
.wy-nav-content .rst-content h3 {
font-size: 1.35rem !important;
line-height: 1.4 !important;
margin-top: 1.8rem !important;
margin-bottom: 0.8rem !important;
}
.wy-nav-content .rst-content h4 {
font-size: 1.1rem !important;
line-height: 1.45 !important;
margin-top: 1.4rem !important;
margin-bottom: 0.6rem !important;
}
.wy-nav-content .rst-content p,
.wy-nav-content .rst-content ul,
.wy-nav-content .rst-content ol,
.wy-nav-content .rst-content dl,
.wy-nav-content .rst-content table,
.wy-nav-content .rst-content blockquote {
margin-bottom: 1rem !important;
}
.wy-nav-content .rst-content ul,
.wy-nav-content .rst-content ol {
padding-left: 1.4rem !important;
}
.wy-nav-content .rst-content li {
margin: 0.35rem 0 !important;
}
.wy-nav-content .rst-content li > p {
margin-bottom: 0.45rem !important;
}
.wy-nav-content .rst-content a {
color: #0969da !important;
}
.wy-nav-content .rst-content a:hover {
color: #0550ae !important;
}
.wy-nav-content .rst-content code,
.wy-nav-content .rst-content tt,
.wy-nav-content .rst-content .literal {
color: #cf222e !important;
background: #f6f8fa !important;
border: 1px solid #d0d7de !important;
border-radius: 6px !important;
padding: 0.12em 0.38em !important;
font-size: 0.92em !important;
}
.wy-nav-content .rst-content div[class^="highlight-"] {
background: #f6f8fa !important;
border: 1px solid #d8dee4 !important;
border-radius: 10px !important;
overflow: hidden !important;
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5) !important;
}
.wy-nav-content .rst-content div[class^="highlight-"] > .highlight {
position: relative !important;
border: 0 !important;
border-radius: inherit !important;
background: transparent !important;
overflow: visible !important;
}
.wy-nav-content .rst-content pre,
.wy-nav-content .rst-content div[class^="highlight"] pre {
background: transparent !important;
border: 0 !important;
border-radius: 0 !important;
padding: 16px 18px !important;
line-height: 1.55 !important;
box-shadow: none !important;
}
.wy-nav-content .rst-content pre code,
.wy-nav-content .rst-content div[class^="highlight"] pre code {
background: transparent !important;
border: 0 !important;
padding: 0 !important;
color: inherit !important;
}
.wy-nav-content .highlight,
.wy-nav-content div[class^="highlight"] {
position: relative !important;
}
.wy-nav-content .copybtn,
.wy-nav-content button.copybtn {
position: absolute !important;
top: 12px !important;
right: 12px !important;
display: inline-flex !important;
align-items: center !important;
justify-content: center !important;
width: 2.25rem !important;
height: 2.25rem !important;
min-width: 2.25rem !important;
padding: 0 !important;
border: 1px solid #d0d7de !important;
border-radius: 8px !important;
background: rgba(255, 255, 255, 0.94) !important;
color: #57606a !important;
box-shadow: 0 1px 2px rgba(31, 35, 40, 0.08) !important;
box-sizing: border-box !important;
line-height: 1 !important;
opacity: 0.96 !important;
transition: all 0.18s ease !important;
}
.wy-nav-content .copybtn svg,
.wy-nav-content button.copybtn svg {
width: 1rem !important;
height: 1rem !important;
padding: 0 !important;
margin: 0 !important;
flex: 0 0 auto !important;
}
.wy-nav-content .copybtn:hover,
.wy-nav-content button.copybtn:hover {
background: #ffffff !important;
color: #1f2328 !important;
border-color: #8c959f !important;
}
.wy-nav-content .copybtn:focus,
.wy-nav-content button.copybtn:focus {
outline: 2px solid rgba(9, 105, 218, 0.28) !important;
outline-offset: 2px !important;
}
.wy-nav-content .copybtn[data-copied="true"],
.wy-nav-content button.copybtn[data-copied="true"] {
color: #1a7f37 !important;
border-color: rgba(26, 127, 55, 0.32) !important;
}
.wy-nav-content .rst-content blockquote {
color: #57606a !important;
background: #f6f8fa !important;
border-left: 4px solid #d0d7de !important;
border-radius: 0 10px 10px 0 !important;
padding: 0.35rem 1rem !important;
}
.wy-nav-content .rst-content blockquote p:last-child {
margin-bottom: 0 !important;
}
.wy-nav-content .rst-content table.docutils,
.wy-nav-content .rst-content table.docutils td,
.wy-nav-content .rst-content table.docutils th {
border-color: #d0d7de !important;
}
.wy-nav-content .rst-content table.docutils {
border-radius: 10px !important;
overflow: hidden !important;
}
.wy-nav-content .rst-content thead th {
background: #f6f8fa !important;
}
.wy-nav-content .rst-content img {
border-radius: 12px !important;
box-shadow: 0 4px 18px rgba(31, 35, 40, 0.12) !important;
}
.wy-nav-content .wy-breadcrumbs {
color: #57606a !important;
margin-bottom: 1.2rem !important;
padding-bottom: 0.85rem !important;
border-bottom: 1px solid #d8dee4 !important;
}
.wy-nav-content .wy-breadcrumbs a {
color: #57606a !important;
}
.wy-nav-content .headerlink {
opacity: 0.35 !important;
}
.wy-nav-content .headerlink:hover {
opacity: 0.9 !important;
}
.wy-nav-content .rst-content .admonition,
.wy-nav-content .rst-content .note,
.wy-nav-content .rst-content .warning,
.wy-nav-content .rst-content .important,
.wy-nav-content .rst-content .tip {
background: #ffffff !important;
border: 1px solid #d0d7de !important;
border-left: 4px solid #0969da !important;
border-radius: 12px !important;
box-shadow: none !important;
}
.wy-nav-content .rst-content .warning,
.wy-nav-content .rst-content .important {
border-left-color: #bf8700 !important;
}
.wy-nav-content .rst-content .admonition-title,
.wy-nav-content .rst-content .note .admonition-title,
.wy-nav-content .rst-content .warning .admonition-title,
.wy-nav-content .rst-content .important .admonition-title,
.wy-nav-content .rst-content .tip .admonition-title {
background: transparent !important;
color: #1f2328 !important;
font-weight: 700 !important;
}
@media (max-width: 768px) {
.wy-nav-content {
margin: 0 !important;
padding: 24px 18px 32px !important;
border: 0 !important;
border-radius: 0 !important;
box-shadow: none !important;
}
.wy-nav-content .rst-content h1 {
font-size: 1.8rem !important;
}
.wy-nav-content .rst-content h2 {
font-size: 1.45rem !important;
}
}
+5
View File
@@ -54,6 +54,7 @@ master_doc = 'index'
# ones. # ones.
extensions = ['recommonmark', extensions = ['recommonmark',
'sphinx_markdown_tables', 'sphinx_markdown_tables',
'sphinx_copybutton',
'sphinx.ext.autosectionlabel', 'sphinx.ext.autosectionlabel',
'language_switch', 'language_switch',
# 'myst_parser', # 'myst_parser',
@@ -181,6 +182,10 @@ html_last_updated_fmt = "%Y年%m月%d日 %H:%M:%S"
# 是否显示页面下方的由sphinx创建, 默认为True # 是否显示页面下方的由sphinx创建, 默认为True
html_show_sphinx = False html_show_sphinx = False
copybutton_exclude = '.linenos, .gp, .go'
copybutton_prompt_text = r'>>> |\.\.\. |\$ |# '
copybutton_prompt_is_regexp = True
# Function to copy video files to output directory # Function to copy video files to output directory
def setup(app): def setup(app):
app.connect('build-finished', copy_videos) app.connect('build-finished', copy_videos)
+1
View File
@@ -2,4 +2,5 @@ sphinx>=4.0.0
sphinx_rtd_theme>=1.0.0 sphinx_rtd_theme>=1.0.0
recommonmark>=0.7.1 recommonmark>=0.7.1
sphinx-markdown-tables>=0.0.15 sphinx-markdown-tables>=0.0.15
sphinx-copybutton>=0.5.2
myst-parser>=0.18.0 myst-parser>=0.18.0
+299 -3
View File
@@ -43,7 +43,303 @@
.lang-switch { .lang-switch {
top: 10px !important; top: 10px !important;
right: 10px !important; right: 10px !important;
font-size: 0.8em !important; font-size: 0.8em !important;
padding: 6px 8px !important; padding: 6px 8px !important;
} }
} }
/* Markdown-like reading experience for the main content area. */
.wy-body-for-nav {
background: #f6f8fa !important;
}
.wy-nav-content-wrap {
background: #f6f8fa !important;
}
.wy-nav-content {
max-width: 960px !important;
margin: 28px auto !important;
padding: 40px 56px 56px !important;
background: #ffffff !important;
border: 1px solid #d8dee4 !important;
border-radius: 18px !important;
box-shadow: 0 1px 3px rgba(31, 35, 40, 0.08), 0 12px 32px rgba(31, 35, 40, 0.08) !important;
}
.wy-nav-content .rst-content {
color: #24292f !important;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif !important;
font-size: 16px !important;
line-height: 1.75 !important;
}
.wy-nav-content .rst-content h1,
.wy-nav-content .rst-content h2,
.wy-nav-content .rst-content h3,
.wy-nav-content .rst-content h4,
.wy-nav-content .rst-content h5,
.wy-nav-content .rst-content h6 {
color: #1f2328 !important;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif !important;
font-weight: 700 !important;
letter-spacing: -0.02em !important;
}
.wy-nav-content .rst-content h1 {
font-size: 2.15rem !important;
line-height: 1.25 !important;
margin: 0 0 1rem !important;
padding-bottom: 0.45rem !important;
border-bottom: 1px solid #d8dee4 !important;
}
.wy-nav-content .rst-content h2 {
font-size: 1.7rem !important;
line-height: 1.35 !important;
margin-top: 2.3rem !important;
margin-bottom: 1rem !important;
padding-bottom: 0.35rem !important;
border-bottom: 1px solid #d8dee4 !important;
}
.wy-nav-content .rst-content h3 {
font-size: 1.35rem !important;
line-height: 1.4 !important;
margin-top: 1.8rem !important;
margin-bottom: 0.8rem !important;
}
.wy-nav-content .rst-content h4 {
font-size: 1.1rem !important;
line-height: 1.45 !important;
margin-top: 1.4rem !important;
margin-bottom: 0.6rem !important;
}
.wy-nav-content .rst-content p,
.wy-nav-content .rst-content ul,
.wy-nav-content .rst-content ol,
.wy-nav-content .rst-content dl,
.wy-nav-content .rst-content table,
.wy-nav-content .rst-content blockquote {
margin-bottom: 1rem !important;
}
.wy-nav-content .rst-content ul,
.wy-nav-content .rst-content ol {
padding-left: 1.4rem !important;
}
.wy-nav-content .rst-content li {
margin: 0.35rem 0 !important;
}
.wy-nav-content .rst-content li > p {
margin-bottom: 0.45rem !important;
}
.wy-nav-content .rst-content a {
color: #0969da !important;
}
.wy-nav-content .rst-content a:hover {
color: #0550ae !important;
}
.wy-nav-content .rst-content code,
.wy-nav-content .rst-content tt,
.wy-nav-content .rst-content .literal {
color: #cf222e !important;
background: #f6f8fa !important;
border: 1px solid #d0d7de !important;
border-radius: 6px !important;
padding: 0.12em 0.38em !important;
font-size: 0.92em !important;
}
.wy-nav-content .rst-content div[class^="highlight-"] {
background: #f6f8fa !important;
border: 1px solid #d8dee4 !important;
border-radius: 10px !important;
overflow: hidden !important;
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5) !important;
}
.wy-nav-content .rst-content div[class^="highlight-"] > .highlight {
position: relative !important;
border: 0 !important;
border-radius: inherit !important;
background: transparent !important;
overflow: visible !important;
}
.wy-nav-content .rst-content pre,
.wy-nav-content .rst-content div[class^="highlight"] pre {
background: transparent !important;
border: 0 !important;
border-radius: 0 !important;
padding: 16px 18px !important;
line-height: 1.55 !important;
box-shadow: none !important;
}
.wy-nav-content .rst-content pre code,
.wy-nav-content .rst-content div[class^="highlight"] pre code {
background: transparent !important;
border: 0 !important;
padding: 0 !important;
color: inherit !important;
}
.wy-nav-content .highlight,
.wy-nav-content div[class^="highlight"] {
position: relative !important;
}
.wy-nav-content .copybtn,
.wy-nav-content button.copybtn {
position: absolute !important;
top: 12px !important;
right: 12px !important;
display: inline-flex !important;
align-items: center !important;
justify-content: center !important;
width: 2.25rem !important;
height: 2.25rem !important;
min-width: 2.25rem !important;
padding: 0 !important;
border: 1px solid #d0d7de !important;
border-radius: 8px !important;
background: rgba(255, 255, 255, 0.94) !important;
color: #57606a !important;
box-shadow: 0 1px 2px rgba(31, 35, 40, 0.08) !important;
box-sizing: border-box !important;
line-height: 1 !important;
opacity: 0.96 !important;
transition: all 0.18s ease !important;
}
.wy-nav-content .copybtn svg,
.wy-nav-content button.copybtn svg {
width: 1rem !important;
height: 1rem !important;
padding: 0 !important;
margin: 0 !important;
flex: 0 0 auto !important;
}
.wy-nav-content .copybtn:hover,
.wy-nav-content button.copybtn:hover {
background: #ffffff !important;
color: #1f2328 !important;
border-color: #8c959f !important;
}
.wy-nav-content .copybtn:focus,
.wy-nav-content button.copybtn:focus {
outline: 2px solid rgba(9, 105, 218, 0.28) !important;
outline-offset: 2px !important;
}
.wy-nav-content .copybtn[data-copied="true"],
.wy-nav-content button.copybtn[data-copied="true"] {
color: #1a7f37 !important;
border-color: rgba(26, 127, 55, 0.32) !important;
}
.wy-nav-content .rst-content blockquote {
color: #57606a !important;
background: #f6f8fa !important;
border-left: 4px solid #d0d7de !important;
border-radius: 0 10px 10px 0 !important;
padding: 0.35rem 1rem !important;
}
.wy-nav-content .rst-content blockquote p:last-child {
margin-bottom: 0 !important;
}
.wy-nav-content .rst-content table.docutils,
.wy-nav-content .rst-content table.docutils td,
.wy-nav-content .rst-content table.docutils th {
border-color: #d0d7de !important;
}
.wy-nav-content .rst-content table.docutils {
border-radius: 10px !important;
overflow: hidden !important;
}
.wy-nav-content .rst-content thead th {
background: #f6f8fa !important;
}
.wy-nav-content .rst-content img {
border-radius: 12px !important;
box-shadow: 0 4px 18px rgba(31, 35, 40, 0.12) !important;
}
.wy-nav-content .wy-breadcrumbs {
color: #57606a !important;
margin-bottom: 1.2rem !important;
padding-bottom: 0.85rem !important;
border-bottom: 1px solid #d8dee4 !important;
}
.wy-nav-content .wy-breadcrumbs a {
color: #57606a !important;
}
.wy-nav-content .headerlink {
opacity: 0.35 !important;
}
.wy-nav-content .headerlink:hover {
opacity: 0.9 !important;
}
.wy-nav-content .rst-content .admonition,
.wy-nav-content .rst-content .note,
.wy-nav-content .rst-content .warning,
.wy-nav-content .rst-content .important,
.wy-nav-content .rst-content .tip {
background: #ffffff !important;
border: 1px solid #d0d7de !important;
border-left: 4px solid #0969da !important;
border-radius: 12px !important;
box-shadow: none !important;
}
.wy-nav-content .rst-content .warning,
.wy-nav-content .rst-content .important {
border-left-color: #bf8700 !important;
}
.wy-nav-content .rst-content .admonition-title,
.wy-nav-content .rst-content .note .admonition-title,
.wy-nav-content .rst-content .warning .admonition-title,
.wy-nav-content .rst-content .important .admonition-title,
.wy-nav-content .rst-content .tip .admonition-title {
background: transparent !important;
color: #1f2328 !important;
font-weight: 700 !important;
}
@media (max-width: 768px) {
.wy-nav-content {
margin: 0 !important;
padding: 24px 18px 32px !important;
border: 0 !important;
border-radius: 0 !important;
box-shadow: none !important;
}
.wy-nav-content .rst-content h1 {
font-size: 1.8rem !important;
}
.wy-nav-content .rst-content h2 {
font-size: 1.45rem !important;
}
}