Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add link to source code in Sphinx

enter image description here

class torch.FloatStorage[source]
    byte()
        Casts this storage to byte type
    char()
        Casts this storage to char type

Im trying to get some documentation done, i have managed to to get the format like the one shown above, But im not sure how to give that link of source code which is at the end of that function! The link takes the person to the file which contains the code,But im not sure how to do it,

like image 303
Ryan Avatar asked Jan 17 '18 10:01

Ryan


1 Answers

This is achieved thanks to one of the builtin sphinx extension.

The one you are looking for in spinx.ext.viewcode. To enable it, add the string 'sphinx.ext.viewcode' to the list extensions in your conf.py file.

In summary, you should see something like that in conf.py

extensions = [
    # other extensions that you might already use
    # ...
    'sphinx.ext.viewcode',
]
like image 147
Pierre de Buyl Avatar answered Sep 20 '22 08:09

Pierre de Buyl