0

I would like to create a reStructuredText document providing a hyperlink to a C source file or a OS configuration file hosted on GitHub in the same repo as the documentation. The link would have to bork both on GitHub (pointing to a file in the same repo) and Read the Docs (preferably pointing to GitHub).

For example:

Source file link `main.c </src/main.c>`_.

This file works as expected on GitHub, but it points nowhere on Read the Docs.

Absolute links would work properly, but are not practical since they would have to be modified one by one if the repo address is changed or if another branch is used.

Source file link `mani.c <https://github.com/Me/MyRepo/blob/master/src/main.c>`_.

Something useful is mentioned here using :source:, but I do not know how to get it to work on Read the Docs. And based on my tests it would not work on GitHub.

Thanks.

Edit:

I added example code on GitHub and a Read the Docs page created from it.

  • I added example code on [GitHub](https://github.com/jeras/readthedocs-source-links) and a [Read the Docs page](http://read-the-docs-issue-with-source-links-demo.readthedocs.io/en/latest/) created from it . – Iztok Jeras May 31 '17 at 11:06

1 Answers1

0

Try a relative link, for example, main.c <src/main.c>_.

Steve Piercy
  • 13,693
  • 1
  • 44
  • 57