简体   繁体   English

如何将索引中的外部文件和部分包含到 sphinx 目录中?

[英]How to include both external files and sections from the index into the sphinx toc?

I am building my python package documentation with sphinx but I having some trouble to add to the table of contents both entries from other files in the docs folder and other sections present on the index.rst.我正在使用 sphinx 构建我的 python package 文档,但是我在将 docs 文件夹中其他文件的条目和 index.rst 上的其他部分的条目添加到目录时遇到了一些麻烦。

These are my docs folder contents:这些是我的 docs 文件夹内容:

$ ls docs/
api_reference.rst  _build  conf.py  index.rst  make.bat  Makefile  _static  _templates

And these are the first lines from index.rst:这些是 index.rst 的第一行:

Welcome to SPIN's documentation!
================================

This is the Sorting Points Into Neighborhoods clustering method documentation.

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

   :ref:`Introduction`
   api_reference

.. _introduction: 

Introduction
============

Sorting Points Into Neighborhoods, aka SPIN, is clustering
technique that only relies on the data and does not map any function on the
original space of the data points. :ref:`Introduction`

The second reference to the introduction section works but the first, on the toctree doesn't.对介绍部分的第二个引用有效,但在 toctree 上的第一个无效。

How could I add both the api-reference and the introduction to the table of contents?如何将 api-reference 和介绍都添加到目录中?

toctree entries are filenames (with or without a file extension). toctree条目是文件名(带或不带文件扩展名)。 Cross-references such as :ref:`Introduction` do not work. :ref:`Introduction`之类的交叉引用不起作用。

I suggest that you put the introduction in a separate file and add the filename to the toctree .我建议您将介绍放在一个单独的文件中,并将文件名添加到toctree

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM