【发布时间】:2016-12-12 08:51:38
【问题描述】:
Sphinx 配置如何在标题中设置“面包屑”?我有一个 Sphinx 项目,我看到的只是项目名称;如果我跳到子页面,我会迷路,看不到当前页面的路径。
一些例子:
https://docs.python.org/2.7/library/argparse.html
参见第一行:文档 >> Python 标准库 >> 15. 通用操作系统服务
http://docs.scipy.org/doc/numpy/reference/arrays.ndarray.html
查看顶部的圆角矩形
scipy 的源代码似乎在这里:
- https://raw.githubusercontent.com/numpy/numpy/v1.11.1/doc/source/reference/index.rst
- https://raw.githubusercontent.com/numpy/numpy/v1.11.1/doc/source/reference/arrays.rst
- https://raw.githubusercontent.com/numpy/numpy/v1.11.1/doc/source/reference/arrays.ndarray.rst
Sphinx“基本”主题看起来像“relbar”一样内置了这个功能:
来自https://github.com/sphinx-doc/sphinx/blob/master/sphinx/themes/basic/layout.html:
{%- macro relbar() %}
<div class="related" role="navigation" aria-label="related navigation">
<h3>{{ _('Navigation') }}</h3>
<ul>
{%- for rellink in rellinks %}
<li class="right" {% if loop.first %}style="margin-right: 10px"{% endif %}>
<a href="{{ pathto(rellink[0]) }}" title="{{ rellink[1]|striptags|e }}"
{{ accesskey(rellink[2]) }}>{{ rellink[3] }}</a>
{%- if not loop.first %}{{ reldelim2 }}{% endif %}</li>
{%- endfor %}
{%- block rootrellink %}
<li class="nav-item nav-item-0"><a href="{{ pathto(master_doc) }}">{{ shorttitle|e }}</a>{{ reldelim1 }}</li>
{%- endblock %}
{%- for parent in parents %}
<li class="nav-item nav-item-{{ loop.index }}"><a href="{{ parent.link|e }}" {% if loop.last %}{{ accesskey("U") }}{% endif %}>{{ parent.title }}</a>{{ reldelim1 }}</li>
{%- endfor %}
{%- block relbaritems %} {% endblock %}
</ul>
</div>
{%- endmacro %}
另见http://www.sphinx-doc.org/en/stable/templating.html
但我不知道如何启用。
好的,我在这里真的很困惑。我有一些东西要出现,但不是我想要的。
我的项目“MyDoc”有我的 index.rst:
Top Level Page Title Is Here
============================
content goes here
.. toctree::
:maxdepth: 2
introduction
(other files)
然后我有介绍.rst
Introduction
============
content goes here
.. toctree::
:maxdepth: 2
test1
和 test1.rst
Test1
============
blah blah
- 对于 index.html,它在 relbar 中显示 MyDoc。
- 对于 Introduction.html,它在 relbar 中显示 MyDoc。 (我会期待 MyDoc >> 简介)
- 对于 test1.html,它在 relbar 中显示 MyDoc >> Introduction。 (我会期待 MyDoc >> 简介 >> Test1)
我想我很困惑的是为什么它会这样工作。
【问题讨论】:
-
它是开源的,所以你可以去看看他们是怎么做的:github.com/scipy/scipy-sphinx-theme
-
看起来像是
pydoctheme代表 github.com/python/cpython/blob/master/Doc/conf.py -
er... 我想我的意思是
parents在“基本”主题的情况下。它会做面包屑,但不知何故必须设置parents,我似乎不能这样做。