230603-Sphinx配置Pydata-Sphinx-Theme主题+调整sidebar宽度

  • 前后对比

在这里插入图片描述
在这里插入图片描述

  • 宽度设置

在这里插入图片描述

  • 定义布局
/* Change the default width of primary sidebar */
.bd-sidebar-primary {
    
     
    width: 15%;
}

/* Change the default width of secondary sidebar */
.bd-sidebar-secondary {
    
    
    width: 15%;
} 

/* Maximum the main content */
.bd-main .bd-content .bd-article-container {
    
    
    max-width: 100%;
    /* default is 60em */
}

/* Set full page width  */
.bd-page-width {
    
    
    max-width: 100%;
    /* default is 88rem */
}


  • 配置文件
# -*- coding: utf-8 -*-
#
# python3-cookbook documentation build configuration file, created by
# sphinx-quickstart on Tue Aug 19 03:21:45 2014.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.

import os
import sys
sys.path.insert(0, os.path.abspath('../..'))


# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
# sys.path.insert(0, os.path.abspath('.'))

# -- General configuration ------------------------------------------------

# If your documentation needs a minimal Sphinx version, state it here.
# needs_sphinx = '1.0'

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
# extensions = ['chinese_search','sphinx.ext.mathjax','sphinx_sitemap', 'sphinx_multiversion', 'nbsphinx', 'sphinx_copybutton', 'sphinx_favicon']
extensions = [
    # 'chinese_search',
    'sphinx.ext.mathjax',
    # 'sphinx_sitemap',
    'sphinx_multiversion',
    'sphinx.ext.mathjax',
    'sphinx-prompt',
    'sphinxemoji.sphinxemoji',
    'sphinx_copybutton',
    'sphinx_favicon',
    'nbsphinx',
    'myst_parser',
    'crate.sphinx.csv',
    'sphinx_panels',
    'sphinx_tabs.tabs',
    'sphinx_design',
    'ablog',
    'sphinx_togglebutton',
    
    'sphinx.ext.autodoc',
    'sphinx.ext.napoleon',
    'sphinx.ext.viewcode',
    'sphinx.ext.doctest',
    'sphinx.ext.intersphinx',
    'sphinx.ext.todo',
    'sphinx.ext.coverage'
    ]



myst_enable_extensions = ["colon_fence"]

# sphinx_tabs_valid_builders = ['linkcheck']
# sphinx_tabs_disable_tab_closing = True

# def setup(app):
#    app.add_lexer('alias', MyCustomLexer())

# sphinx_tabs_disable_css_loading = True


favicons = [
    {
    
    
        "sizes": "16x16",
        "href": "https://profile-avatar.csdnimg.cn/334f3ec1c2484587b63913c30e39182b_qq_33039859.jpg",
    },
    {
    
    
        "sizes": "32x32",
        "href": "https://profile-avatar.csdnimg.cn/334f3ec1c2484587b63913c30e39182b_qq_33039859.jpg",
    },
    {
    
    
        "rel": "apple-touch-icon",
        "sizes": "180x180",
        "href": "like_me.jpeg",  # use a local file in _static
    },
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# The suffix of source filenames.
# source_parsers = {
    
    
#   '.md': 'recommonmark.parser.CommonMarkParser',
# }
source_suffix = ['.rst']

# The encoding of source files.
# source_encoding = 'utf-8-sig'

# The master toctree document.
master_doc = 'index'

# General information about the project.
project = 'Sphinx Magic'
copyright = 'GuokLiu'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '3.0'
# The full version, including alpha/beta/rc tags.
release = '1.0.0'

exclude_patterns = []

html_theme = 'default'


latex_elements = {
    
      # The paper size ('letterpaper' or 'a4paper').
    'papersize': 'a4paper',  # The font size ('10pt', '11pt' or '12pt').
    'pointsize': '12pt', 'classoptions': ',oneside', 'babel': '',  # 必须
    'inputenc': '',  # 必须
    'utf8extra': '',  # 必须
    # Additional stuff for the LaTeX preamble.
    'preamble': r"""
\usepackage{xeCJK}
\usepackage{indentfirst}
\setlength{\parindent}{2em}
\setCJKmainfont{WenQuanYi Micro Hei}
\setCJKmonofont[Scale=0.9]{WenQuanYi Micro Hei Mono}
\setCJKfamilyfont{song}{WenQuanYi Micro Hei}
\setCJKfamilyfont{sf}{WenQuanYi Micro Hei}
\XeTeXlinebreaklocale "zh"
\XeTeXlinebreakskip = 0pt plus 1pt
"""}


# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# on_rtd is whether we are on readthedocs.org, this line of code grabbed from docs.readthedocs.org
# on_rtd = os.environ.get('READTHEDOCS', None) == 'True'

# if not on_rtd:  # only import and set the theme if we're building docs locally
#     import sphinx_rtd_theme
#     html_theme = 'sphinx_rtd_theme'
#    #  html_theme = 'alabaster'
#     html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
# otherwise, readthedocs.org uses their theme by default, so no need to specify it
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
html_theme = 'pydata_sphinx_theme'
html_static_path = ['_static']
html_css_files = ['css/custom.css',]

html_theme_options = {
    
    
    "logo": {
    
    
        "image_light": "https://profile-avatar.csdnimg.cn/334f3ec1c2484587b63913c30e39182b_qq_33039859.jpg",
        "image_dark": "https://profile-avatar.csdnimg.cn/334f3ec1c2484587b63913c30e39182b_qq_33039859.jpg",
        "link": "https://blog.csdn.net/qq_33039859?type=blog",
        "alt_text": "alt_text",
        "text": "KSH: Knowledge Sharing Hub"
    },
    "icon_links": [
        {
    
    
            "name": "GitHub",
            "url": "https://github.com/<your-org>/<your-repo>",
            "icon": "fa-brands fa-square-github",
            "type": "fontawesome",
        },
        {
    
    
            "name": "GitLab",
            "url": "https://gitlab.com/<your-org>/<your-repo>",
            "icon": "fa-brands fa-square-gitlab",
            "type": "fontawesome",
        },
        {
    
    
            "name": "Twitter",
            "url": "https://twitter.com/<your-handle>",
            "icon": "fa-brands fa-square-twitter",
            # The default for `type` is `fontawesome` so it is not actually required in any of the above examples as it is shown here
        },
        {
    
    
            "name": "Mastodon",
            "url": "https://<your-host>@<your-handle>",
            "icon": "fa-brands fa-mastodon",
        },
    ],

}


# html_sidebars = {
    
    
#     "<page_pattern>": ["list", "of", "templates"]
# }

# html_sidebars = {
    
    
#     "**": ["sidebar-nav-bs", "sidebar-ethical-ads"]
# }

language = 'zh_CN'
# html_search_language = 'zh_CN'

_exts = "../exts"
sys.path.append(os.path.abspath(_exts))

html_js_files = [
    'js/readmore.js',
    'js/baidutongji.js',
]


author = 'GuokLiu'
copyright = '青葱的凯歌'
exclude_patterns = ['_build']
master_doc = 'index'
project = 'Sphinx Magic'

# Options for extensions.
html_baseurl = 'https://magic.iswbm.com'
# html_extra_path = ["robots.txt"]

# html_sidebars = {
    
    
#     '**': [
#         'versioning.html',
#     ],
# }
smv_latest_version = 'v3.0'
sitemap_url_scheme = "{link}"

猜你喜欢

转载自blog.csdn.net/qq_33039859/article/details/131023578
今日推荐