From 074c28deb0ac0f349600b1f37afe8f4a5dc5e199 Mon Sep 17 00:00:00 2001 From: "James E. Blair" Date: Fri, 4 Aug 2017 13:53:02 -0700 Subject: [PATCH] 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 event is received..."). Change-Id: I42cd678d9bb97058d5fbe255791cbc476d5057bb --- zuul/sphinx/zuul.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/zuul/sphinx/zuul.py b/zuul/sphinx/zuul.py index bbd03e9051..0ac33b8ea8 100644 --- a/zuul/sphinx/zuul.py +++ b/zuul/sphinx/zuul.py @@ -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