Docs: change default title for value xref

When we use zuul:value to xref, the default title text for the link
is the full target name (eg "pipeline.trigger.github.event.pull_request")
which is a bit verbose.  Normally, we would just want the final element
as the title for a value (so a sentence might read "When a <pull_request>
event is received...").

Change-Id: I42cd678d9bb97058d5fbe255791cbc476d5057bb
This commit is contained in:
James E. Blair 2017-08-04 13:53:02 -07:00
parent 91c9dde0cb
commit 074c28deb0
1 changed files with 14 additions and 2 deletions

View File

@ -204,6 +204,17 @@ class ZuulStatDirective(ZuulConfigObject):
return sig
class ZuulAbbreviatedXRefRole(XRefRole):
def process_link(self, env, refnode, has_explicit_title, title,
target):
title, target = super(ZuulAbbreviatedXRefRole, self).process_link(
env, refnode, has_explicit_title, title, target)
if not has_explicit_title:
title = title.split('.')[-1]
return title, target
class ZuulDomain(Domain):
name = 'zuul'
label = 'Zuul'
@ -218,8 +229,9 @@ class ZuulDomain(Domain):
roles = {
'attr': XRefRole(innernodeclass=nodes.inline, # type: ignore
warn_dangling=True),
'value': XRefRole(innernodeclass=nodes.inline, # type: ignore
warn_dangling=True),
'value': ZuulAbbreviatedXRefRole(
innernodeclass=nodes.inline, # type: ignore
warn_dangling=True),
'var': XRefRole(innernodeclass=nodes.inline, # type: ignore
warn_dangling=True),
'stat': XRefRole(innernodeclass=nodes.inline, # type: ignore