【发布时间】:2020-04-13 18:54:18
【问题描述】:
我正在使用 sphinx,并创建了多个 rst 文件来组织我的文档。我使用 .. include:: <filepath/filename.rst> 将多个 rst 文件包含到一个配置文件中,但是当使用 :ref:`<reference>` 时,这会保留文件名标题标签,但是当我单击链接时它会隔离页面,但我希望它滚动到同一页面中的引用.当我使用<reference>_ 时,这将滚动到同一文档中的区域,但不再保留标题标签。有没有办法可以保留参考标题标签并在同一页面内滚动,同时仍将文档保留在不同的文件中?
index.rst
Welcome to testing's documentation!
===================================
.. toctree::
:maxdepth: 2
:caption: Contents:
test/config
test/config.rst
.. title:
Hello moto
==========
Using ref maintains header
* :ref:`ref-nested`
Using underscore doesn't maintain header
- nested_
.. include:: nested_test/file.rst
.. include:: nested_test/anotherfile.rst
test/anotherdir/file.rst
.. _nested:
I'm a nested header
-------------------
Hi I'm the created nested header
test/anotherdir/anotherfile.rst
.. _ref-nested:
I'm the ref nested header
-------------------------
I'm the ref nested header
正如您在下面看到的第一个链接(:ref:) 维护给定的标题,但如果您单击它,它将转到一个隔离页面。第二个链接不保留标题,而是使用实际引用,但如果单击它,它将停留在同一页面上并在文档中移动。
以下是两张图片,当使用:ref: 时,它会将页面加载为一个独立的 rst 文件。
【问题讨论】:
-
“转到隔离页面”是什么意思?
-
嗨@mzjn,我继续更新了这个问题。我所说的隔离页面的意思是,当我使用
.. include::时,它在第一个文件中包含另一个文档,但是当我说隔离页面时,而不是在单击链接时向下滚动。它将页面作为单独的文档/视图加载。而不是在整个文档中向下滚动。
标签: python-sphinx restructuredtext