Skip to main content

mystx 主题 - 基于 sphinx-book-theme 的现代 Sphinx 文档主题

Project description

MySTX

repo size PyPI GitHub issues GitHub forks GitHub stars GitHub license contributors Documentation Status Downloads PyPI - Downloads

MySTX 是基于 Sphinx Book Theme 的现代化、可定制的 Sphinx HTML 主题,为技术文档提供优雅美观的展示效果。它结合了现代Web设计理念与优秀的阅读体验,使您的文档既专业又易于阅读。

✨ 特性

  • 🎨 基于 Sphinx Book Theme 的现代化设计风格
  • 🛠️ 灵活的主题配置系统,支持从 TOML 文件加载主题配置选项
  • 📝 完善的 MyST Markdown 和 Jupyter Notebook 支持
  • 🚀 简单易用的主题注册和配置应用流程
  • 📚 丰富的可选扩展,用于增强文档功能

🔧 安装

基本安装

使用 pip 安装 mystx 主题:

pip install mystx

安装文档扩展

如果需要使用文档扩展功能,可以安装可选依赖:

pip install "mystx[doc]"

开发环境安装

对于开发者,可以安装开发依赖:

pip install -ve .[dev]

📋 依赖

核心依赖

  • sphinx-book-theme>=1.1.4 (主题继承)
  • sphinx>=8.0.0 (文档生成引擎)
  • myst-nb (Jupyter Notebook 支持)
  • myst-parser (MyST Markdown 解析器)
  • Python 3.12+ (运行环境)

🚀 快速开始

在您的 Sphinx 项目的 conf.py 文件中,添加以下配置来使用 mystx 主题:

# conf.py
project = "mystx 文档" # 文档项目名称
author = "xinetzone" # 文档作者
# == 国际化与本地化设置 ==================================================================
language = 'zh_CN' # 文档语言(中文简体)
locale_dirs = ['../locales/'] # 翻译文件存放目录
gettext_compact = False # 是否合并子目录的PO文件(False表示不合并)
# 插件
extensions = ['mystx']
html_last_updated_fmt = '%Y-%m-%d, %H:%M:%S'  # 文档的最后更新时间格式
# 排除文件和目录模式
exclude_patterns = [
    "_build",  # 构建输出目录
    "Thumbs.db",  # 缩略图数据库
    ".DS_Store",  # macOS 系统文件
]
static_path = ["_static"]  # 静态资源目录,用于存放CSS、JavaScript、图片等
html_theme = 'mystx'  # 使用的主题名称
html_logo = "_static/images/logo.jpg" # 文档logo
html_title = "Sphinx mystx Theme" # 文档标题
html_copy_source = True # 是否在文档中包含源文件链接
html_favicon = "_static/images/favicon.jpg" # 文档favicon

⚙️ 配置指南

mystx 主题提供了丰富的配置选项,让您可以根据项目需求自定义文档外观和功能。以下是配置指南:

主题选项

mystx 主题支持通过两种方式配置主题选项:

方式一:在 conf.py 文件中配置

在 Sphinx 项目的 conf.py 文件中,使用 html_theme_options 字典配置各种主题选项:

html_theme_options = {
    # 仓库相关配置
    "repository_url": "https://github.com/yourusername/yourproject",  # 项目仓库地址
    "use_repository_button": True,  # 在页眉显示指向存储库的小 GitHub 徽标
    "use_issues_button": True,  # 是否显示问题反馈按钮
    "use_edit_page_button": True,  # 是否显示编辑页面按钮
    "path_to_docs": "doc/",  # 文档目录(相对于项目根目录)
    
    # 导航相关配置
    "home_page_in_toc": false,  # 是否在目录中显示首页
    "show_navbar_depth": 2,  # 导航栏显示的层级深度
    
    # 其他配置
}

方式二:通过 _config.toml 文件配置

您也可以在项目根目录创建 _config.toml 文件,使用 TOML 格式配置主题选项:

[html_theme_options]
# 仓库相关配置
repository_url = "https://github.com/yourusername/yourproject"
use_repository_button = true
use_issues_button = true
use_edit_page_button = true
path_to_docs = "doc/" # 文档目录(相对于项目根目录)

# 导航相关配置
home_page_in_toc = false # 是否在目录中显示首页
show_navbar_depth = 2 # 导航栏显示的层级深度

# 其他配置

您可以根据实际需求选择性配置上述选项,未配置的选项将使用默认值。

📚 文档

请访问 mystx 官方文档 以及 daobook/sphinx-book-themeSphinx Book Theme 文档 了解更多详细信息和使用示例。

🔗 链接

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mystx-0.3.0.tar.gz (22.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mystx-0.3.0-py3-none-any.whl (24.5 kB view details)

Uploaded Python 3

File details

Details for the file mystx-0.3.0.tar.gz.

File metadata

  • Download URL: mystx-0.3.0.tar.gz
  • Upload date:
  • Size: 22.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mystx-0.3.0.tar.gz
Algorithm Hash digest
SHA256 0ca8eacce995a2e1ab5b39c0dcf9764fdee8ddc1bd11e9960620cbe24ba1dadb
MD5 f6cb0e779cf83079b4b0c4bbb15c2845
BLAKE2b-256 1675fa05894e2fba9cf597c488ad179613cd05f37b43d8a026050baac81509c4

See more details on using hashes here.

File details

Details for the file mystx-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: mystx-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 24.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mystx-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ab76b1cf1d9ad8c1fd297f92314052c91183088da77b39408a065269206624e8
MD5 d8dc1197e5311339f981e67c2f8b77e5
BLAKE2b-256 ac2fa4fa02413ec9689f17235469e2a0d6d5d2d3e39da39ffe9485d6b322eb1c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page