Sphinx Book Theme 使用教程

Sphinx Book Theme 使用教程

sphinx-book-themeA clean book theme for scientific explanations and documentation with Sphinx项目地址:https://gitcode.com/gh_mirrors/sp/sphinx-book-theme

1. 项目的目录结构及介绍

Sphinx Book Theme 的目录结构如下:

sphinx-book-theme/
├── docs/
│   ├── _static/
│   ├── _templates/
│   ├── conf.py
│   ├── index.rst
│   └── Makefile
├── sphinx_book_theme/
│   ├── static/
│   ├── templates/
│   ├── __init__.py
│   ├── theme.conf
│   └── util.py
├── .gitignore
├── LICENSE
├── MANIFEST.in
├── README.md
├── setup.cfg
└── setup.py

目录结构介绍

  • docs/: 包含项目的文档文件,如配置文件、静态资源和模板。
    • _static/: 存放静态文件,如图片、CSS 和 JavaScript 文件。
    • _templates/: 存放自定义模板文件。
    • conf.py: Sphinx 配置文件。
    • index.rst: 文档的入口文件。
    • Makefile: 用于构建文档的 Makefile。
  • sphinx_book_theme/: 主题的核心代码。
    • static/: 主题的静态资源文件。
    • templates/: 主题的模板文件。
    • __init__.py: 模块初始化文件。
    • theme.conf: 主题配置文件。
    • util.py: 工具函数文件。
  • .gitignore: Git 忽略文件列表。
  • LICENSE: 项目许可证。
  • MANIFEST.in: 打包清单文件。
  • README.md: 项目说明文件。
  • setup.cfg: 安装配置文件。
  • setup.py: 安装脚本。

2. 项目的启动文件介绍

Sphinx Book Theme 的启动文件是 docs/conf.py。这个文件包含了 Sphinx 文档项目的配置信息,如主题设置、扩展插件、路径配置等。

conf.py 主要配置项

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

project = 'Sphinx Book Theme'
copyright = '2021, Executable Books'
author = 'Executable Books'

extensions = [
    'sphinx.ext.autodoc',
    'sphinx.ext.viewcode',
    'sphinx.ext.intersphinx',
]

templates_path = ['_templates']
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']

html_theme = 'sphinx_book_theme'
html_theme_options = {
    'path_to_docs': 'docs',
    'repository_url': 'https://github.com/executablebooks/sphinx-book-theme',
    'use_repository_button': True,
}

html_static_path = ['_static']

3. 项目的配置文件介绍

Sphinx Book Theme 的配置文件主要包括 conf.pytheme.conf

conf.py

如上所述,conf.py 是 Sphinx 文档项目的配置文件,包含了项目的基本信息、扩展插件、主题设置等。

theme.conf

theme.conf 是主题的配置文件,定义了主题的样式和行为。

[theme]
inherit = basic
stylesheet = sphinx_book_theme.css
pygments_style = tango

主要配置项

  • inherit: 继承的基本主题。
  • stylesheet: 主题的 CSS 文件。
  • pygments_style: 代码高亮样式。

通过这些配置文件,可以自定义和调整 Sphinx Book Theme 的外观和行为。

sphinx-book-themeA clean book theme for scientific explanations and documentation with Sphinx项目地址:https://gitcode.com/gh_mirrors/sp/sphinx-book-theme

  • 8
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

宣勇磊Tanya

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值