Search code examples
restructuredtext

How do I change an rst code snippet :ref:`foo` to display as Foo?


An rst document has :ref:function-calls and displays it on readthedocs as function-calls, but it is the beginning of a sentence. How do I change it to display as "Function calls"?

Context: https://viper.readthedocs.io/en/latest/structure-of-a-contract.html#functions


Solution

  • According to the Sphinx documentation of the role :ref::

    Labels that aren’t placed before a section title can still be referenced to, but you must give the link an explicit title, using this syntax:

    :ref:`Link title <label-name>`
    

    So try:

    :ref:`Function calls <function-calls>`