aboutsummaryrefslogtreecommitdiffstats
path: root/lv2specgen
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-11-09 08:09:44 +0000
committerDavid Robillard <d@drobilla.net>2011-11-09 08:09:44 +0000
commit6e44b54cfbd5cf285599f4bc2004da2248061e3b (patch)
treed720cf91170c321ad3f8b3eaed6101ff3efd1760 /lv2specgen
parent63811d5fedd978f2c3c1b0a4ea7b745955570bbb (diff)
downloadlv2-6e44b54cfbd5cf285599f4bc2004da2248061e3b.tar.xz
Link Atom classes to C type identifiers.
Define C types for all Atom classes where a useful C type is possible.
Diffstat (limited to 'lv2specgen')
-rwxr-xr-xlv2specgen/lv2specgen.py25
1 files changed, 16 insertions, 9 deletions
diff --git a/lv2specgen/lv2specgen.py b/lv2specgen/lv2specgen.py
index 7f86686..428a6ef 100755
--- a/lv2specgen/lv2specgen.py
+++ b/lv2specgen/lv2specgen.py
@@ -210,7 +210,21 @@ if have_pygments:
(r'(?=\s*\.)', Text, '#pop'),
],
}
+
+def linkify(string):
+ "Add links to code documentation for identifiers"
+ if string in linkmap.keys():
+ # Exact match for complete string
+ return linkmap[string]
+
+ rgx = re.compile('([^a-zA-Z0-9_:])(' + \
+ '|'.join(map(re.escape, linkmap)) + \
+ ')([^a-aA-Z0-9_:])')
+
+ def translateCodeLink(match):
+ return match.group(1) + linkmap[match.group(2)] + match.group(3)
+ return rgx.sub(translateCodeLink, string)
def getComment(m, urinode, classlist):
c = findOne(m, urinode, lv2.documentation, None)
@@ -246,14 +260,7 @@ def getComment(m, urinode, classlist):
markup = code_rgx.sub(code_str, markup, 1)
# Add links to code documentation for identifiers
- rgx = re.compile('([^a-zA-Z0-9_:])(' + \
- '|'.join(map(re.escape, linkmap)) + \
- ')([^a-aA-Z0-9_:])')
-
- def translateCodeLink(match):
- return match.group(1) + linkmap[match.group(2)] + match.group(3)
-
- markup = rgx.sub(translateCodeLink, markup)
+ markup = linkify(markup)
# Replace ext:ClassName with links to appropriate fragment
rgx = re.compile(spec_pre + ':([A-Z][a-zA-Z0-9_-]*)')
@@ -513,7 +520,7 @@ def extraInfo(term, m):
if isResource(getObject(p)):
doc += getProperty(getTermLink(getObject(p), term, getPredicate(p)), first)
elif isLiteral(getObject(p)):
- doc += getProperty(str(getObject(p)), first)
+ doc += getProperty(linkify(str(getObject(p))), first)
elif isBlank(getObject(p)):
doc += getProperty(str(blankNodeDesc(getObject(p), m)), first)
else: