How can I link to the file: download: on a network drive in Sphinx?

I am doing some design documentation for one of our hardware products. The documentation is intended for internal use and is located on a network drive:

\\ourserver\projects\project1-doc

As we are currently performing version control, we have several such folders:

 \\ourserver\projects\project1-A \\ourserver\projects\project1-B \\ourserver\projects\project1-C 

I want to be able to make the link :download: from the documentation in pdf in one of these folders. Is there any way to make an absolute file path? I have tried many things, for example:

 :download:`schematic <file://///ourserver/projects/project1-C/schematic.pdf>` :download:`schematic //ourserver/projects/project1-C/schematic.pdf>` 

but I could not get it to work with Sphinx. How can I link to this file?

+6
source share
1 answer

The document is hosted on the network, but are you building it through sphinx on the network? When using the directive: download: direct sphinx copies files to the _build / html directory under _downloads and links to them there. Therefore, if you had to create a local sphinx file locally, and he could not find the correct file to copy and link during the build, then it would not create links, the same if the path is wrong.

In any case, since you are linking to files under version control, you probably want to create an absolute path using .. raw :: directives so that you are always linked to the latest version.

 .. raw:: html <p><a class="reference download internal" href="/ourserver/projects/project1-C/schematic.pdf"> <tt class="xref download docutils literal"> Project 1-C Schematic </tt></a><p> 

And if you want to link it to pdf and run it using the created pdf using sphinx. You can use the directive .. raw :: latex.

 .. raw:: latex \href{run:/ourserver/projects/project1-C/schematic.pdf}{Project 1-C Schematic} 

Custom directives can also be created to make this more fluid.

+1
source

All Articles