After spending a few days going through sphinx and docutils source code, I
was able to find a way to control the text displayed in ref_node when
referenced through `ref` and `numref` roles without having to override the
ref role.
Just update the `sectname` below to whatever text you want to display by
overriding the information in the `domain.labels` and `domain.anonlabels`.
```
def process_docs(app, document):
""' traverse through admonition nodes"
for node in document.traverse(nodes.admonition):
....
domain = cast(StandardDomain, app.env.get_domain('std'))
domain.anonlabels[name] = docname, labelid
domain.labels[name] = docname, labelid, sectname
```
`app.connect('doctree-read', process_docs)`
Hope this is helpful to others too. :-)
On Thursday, October 1, 2020 at 4:52:08 AM UTC+2 [email protected] wrote:
> thinks for your atentione.
> Le 1 oct. 2020 02:48, "joyoussef67" <[email protected]> a écrit :
>
>>
>>
>> في الثلاثاء، 29 سبتمبر 2020 في تمام الساعة 2:34:16 ص UTC+4، كتب
>> [email protected] رسالة نصها:
>>
>>> I have created a simple directive which can be referenced through the
>>> ref role. I register this directive as an explicit target through
>>> `self.state.document.note_explicit_target(node)`.
>>>
>>> When I reference the directive through the ref role, I want to be able
>>> to control the href text displayed depending on a few attributes of the
>>> target node. Is there a to override `process_link` for the `ref` role?
>>> What's the best way to accomplish this?
>>>
>>> Would be happy to provide more info if necessary. :-)
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "sphinx-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/sphinx-users/7fe26bc6-368c-4edb-8ecf-3e8466afbc3dn%40googlegroups.com
>>
>> <https://groups.google.com/d/msgid/sphinx-users/7fe26bc6-368c-4edb-8ecf-3e8466afbc3dn%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>
--
You received this message because you are subscribed to the Google Groups
"sphinx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/sphinx-users/87a5928e-8d90-45ca-a405-c2f41bb7c5ffn%40googlegroups.com.