Source

sphinx / sphinx / roles.py

Diff from to

File sphinx/roles.py

     return [retnode], []
 
 
+_abbr_re = re.compile('\((.*)\)$')
+
+def abbr_role(typ, rawtext, text, lineno, inliner, options={}, content=[]):
+    text = utils.unescape(text)
+    m = _abbr_re.search(text)
+    if m is None:
+        return [addnodes.abbreviation(text, text)], []
+    abbr = text[:m.start()].strip()
+    expl = m.group(1)
+    return [addnodes.abbreviation(abbr, abbr, explanation=expl)], []
+
+
 specific_docroles = {
     'data': xfileref_role,
     'exc': xfileref_role,
     'menuselection': menusel_role,
     'file': emph_literal_role,
     'samp': emph_literal_role,
+    'abbr': abbr_role,
 }
 
 for rolename, func in specific_docroles.iteritems():