【问题标题】:How to change titles in a toctree using glob?如何使用 glob 更改目录树中的标题?
【发布时间】:2020-09-29 10:22:17
【问题描述】:

我在我的 sphinx 项目中使用了一个带有 glob 选项的目录树,我想显示与我的文件的 H1 或文件名不同的标题,并使用 Titlesonly 作为目录树的选项。

这是我的代码快照:

在 index.md 中有我项目的 README.md 文件

```{toctree}
---
maxdepth: 1
glob:
---
src/*/*

我想显示“Project Root”,例如“audit”,而不是“Projet audit @shared”文件的标题

这是 README.md 的快照

# Projet audit @shared

* Project Root: `audit`

【问题讨论】:

标签: markdown python-sphinx glob toctree myst


【解决方案1】:

您不能使用 glob 指定文档标题。 showing custom titles in reST is described in the documentation 的语法。

参赛作品

toctree 中的文档标题将自动从引用文档的标题中读取。如果这不是您想要的,您可以使用与 reST 超链接(和 Sphinx 的 cross-referencing syntax)类似的语法指定明确的标题和目标。这看起来像:

.. toctree::

    intro
    All about strings <strings>
    datatypes

【讨论】:

  • 没错,glob 会自动放置标题。我使用了一个明确的标题和目标,使用与 reST 超链接类似的语法,但用于 Markdown 页面。谢谢
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-10-02
  • 1970-01-01
  • 2015-05-18
  • 1970-01-01
  • 2012-06-18
  • 2019-03-29
相关资源
最近更新 更多