Use version number in file links in Sphinx -
in sphinx, file links can generated using following syntax:
`name_of_file.js <some/location/name_of_file.js>`_
in conf.py file, version
variable defined can use in .rst files such:
|version|
including version file link using syntax not allowed:
`name_of_file.|version|.min.js <some/location/name_of_file.|version|.min.js>`_
so, how can generate links files named name_of_file.<version_num>.min.js
, use version number conf.py?
i had need similar , after experimentation have workaround this. warned, crummy solution works.
the short answer:
you need split parts of link left , right of |version| , use raw html along |version|
. .rst this:
example of link version in |link-pre|\ |version|\ |link-post| .. |link-pre| raw:: html <a href="some/location/name_of_file. .. |link-post| raw:: html .min.js">name_of_file.min.js</a>
the long answer
there couple of hurdles need overcome:
problem 1: now, |version|
substitution definition. when use substitution reference in document, has lead space
|version|
.
so in regular rst sentence, not link, can't name_of_file.|version|.min.js
. need name_of_file.\ |version|.min.js
, i.e, escape space
\
problem 2: nested inline markup not supported in rest: http://docutils.sourceforge.net/faq.html#is-nested-inline-markup-possible
so can't make substitution, |version|
, within link \`name_of_file.|version|.min.js`\
. why have use raw-html , break parts, , create 2 more substitution definitions |link-pre|
, |link-post|
, replaced raw-html in generated output.
i tried using inline :raw-html:
role did not help, unfortunately solution turned out verbose.
Comments
Post a Comment