Search code examples
code-coveragepython-sphinxrestructuredtexttoctree

How to include a link to index.html of content generated by another program in reST


My RST directory looks like this:

.
|-- Makefile
|-- build
|   |-- doctrees
|   `-- html
|       |-- codecov          <-- Generated by coverage.py
|          |-- index.html
|       | ....               <-- Generated by Sphinx
|-- make.bat
`-- source
    |-- _static
    |-- changelog.rst
    |-- conf.py
    |-- contact.rst
    |-- getting_started.rst
    |-- index.rst
    `-- introduction.rst

In my index.rst, I would like to create a relative link titled Code Coverage that points to codecov/index.html. I am not sure how to do that because it is outside my source folder. The 'codecov' folder is auto generated when I run code coverage in python. How to accomplish this?

.. toctree::
   :caption: Table of Contents
   :maxdepth: 2

   introduction
   getting_started
   changelog
   contact


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

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

Solution

  • You have at least two options.

    1. Use an external link.
    `Code Coverage <../_build/codecov/index.html>`_
    
    1. Put this in a toctree directive.
    .. toctree::
    
        Code Coverage <https://www.example.com/_build/codecov/index.html>
    
    

    There may be other options, but let's see if either satisfies your need.