gpt4 book ai didi

python - 如何打印标题中的文档版本?

转载 作者:行者123 更新时间:2023-11-30 21:59:35 28 4
gpt4 key购买 nike

我刚刚使用 sphinx-quickstart.exealabaster 主题创建了一个 Sphinx 文档。

我想在标题中的某个位置打印文档的版本。

我在conf.py中填充了versionrelease变量

# -*- coding: utf-8 -*-
#
# Configuration file for the Sphinx documentation builder.

# -- Project information -----------------------------------------------------

project = 'MWE'
copyright = '2019, and1er'
author = 'and1er'

# The short X.Y version
version = '2.4.12'
# The full version, including alpha/beta/rc tags
release = 'beta'

extensions = [
]

templates_path = ['_templates']
source_suffix = '.rst'

master_doc = 'index'
language = None
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
pygments_style = 'sphinx'

html_theme = 'alabaster'

html_static_path = ['_static']
htmlhelp_basename = 'MWEdoc'

index.rst

.. MWE documentation master file, created by
sphinx-quickstart on Tue Feb 5 14:51:07 2019.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.

Welcome to MWE's documentation!
===============================

.. toctree::
:maxdepth: 2
:caption: Contents:

Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

生成的文档没有 2.4.12beta 字符串。

Resulting document

最佳答案

是否|版本| substitution适合你吗?

UPD更新的 MWE

index.rst

.. MWE documentation master file, created by
sphinx-quickstart on Tue Feb 5 14:51:07 2019.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.

Welcome to MWE's documentation!
===============================

.. toctree::
:maxdepth: 2
:caption: Contents:

Document version:
|version|
|release|


Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

The expected result

关于python - 如何打印标题中的文档版本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54534034/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com