documentation - Python Sphinx anchor on arbitrary line -
how can set anchor reference @ arbitrary line in rest using sphinx?
to more clear, here example:
a title anchor ---------------------- stuff
this create heading a title anchor
, add on-hover ¶
character @ end of line, anchor reference line/heading.
now in following case...
``some arbitrary line`` definition
...i want have anchor some arbitrary line
, same way heading.
you can role called ref
: http://sphinx-doc.org/markup/inline.html#role-ref
specifically read 2nd bullet point addresses happens if reference not placed before title.
for example, in file called example.rst
how use:
.. _arbitrary-anchor: arbitrary line definition
the label "arbitrary-anchor" has unique through out document. reference anchor somewhere in document, this:
lorem ipsum :ref:`here anchor link <arbitrary-anchor>` dolor sit amet
unfortunately, anchor not show when hover on referenced line, should able access using explicit link http://example.com/example.html#arbitrary-anchor
since mention definitions - worth noting there role called term
lets reference definition in glossary.
for example of how use this, see: http://sphinx-doc.org/glossary.html#term-role
and how referenced in 3rd paragraph of: http://sphinx-doc.org/domains.html#domains
lastly, if need insert anchor in middle of paragraph, 1 way creating explicit <a id=#sample>inline anchor</a>
using raw role
: http://docutils.sourceforge.net/docs/ref/rst/roles.html#raw
edit:
there 1 more option. create anchor , hover effect.
.. rst:role:: sample rst role sample definition links anchor :rst:role:`sample rst role`
this funny looking directive i've been using while now. found when looking @ source of page:
http://sphinx-doc.org/markup/inline.html#inline-markup
http://sphinx-doc.org/_sources/markup/inline.txt
the text looks when hover:
the text looks after click on link:
this option less ideal because displays :
left , right of definition. nice because creates anchor , hover on that's not title (so doesn't show in toc well, wanted)
Comments
Post a Comment