aboutsummaryrefslogtreecommitdiffstats
path: root/lv2specgen
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2019-03-24 21:22:36 +0100
committerDavid Robillard <d@drobilla.net>2019-03-24 21:52:36 +0100
commit3451af94fb05cd7d545718c84afcb4fe081a8f85 (patch)
treec07665ea5741a7d862a885ae4c48b9e65009d11b /lv2specgen
parent4ded00e4e689d5aa8a057957a9015ce9194ef737 (diff)
downloadlv2-3451af94fb05cd7d545718c84afcb4fe081a8f85.tar.xz
Use lighter and more consistent documentation style
Diffstat (limited to 'lv2specgen')
-rwxr-xr-xlv2specgen/lv2specgen.py106
-rw-r--r--lv2specgen/template.html130
2 files changed, 119 insertions, 117 deletions
diff --git a/lv2specgen/lv2specgen.py b/lv2specgen/lv2specgen.py
index c8612e1..dd77b9c 100755
--- a/lv2specgen/lv2specgen.py
+++ b/lv2specgen/lv2specgen.py
@@ -466,30 +466,14 @@ def getTermLink(uri, subject=None, predicate=None):
return '<a href="%s" %s>%s</a>' % (uri, extra, niceName(uri))
-def rdfsClassInfo(term, m):
- """Generate rdfs-type information for Classes: ranges, and domains."""
- global classranges
- global classdomains
+def owlRestrictionInfo(term, m):
+ """Generate OWL restriction information for Classes"""
doc = ""
- # Find subClassOf information
restrictions = []
- superclasses = []
- for st in findStatements(m, term, rdfs.subClassOf, None):
- if not isBlank(getObject(st)):
- uri = getObject(st)
- if not uri in superclasses:
- superclasses.append(uri)
- else:
- meta_type = findOne(m, getObject(st), rdf.type, None)
- restrictions.append(getSubject(meta_type))
-
- if len(superclasses) > 0:
- doc += "\n<tr><th>Subclass of</th>"
- first = True
- for superclass in sorted(superclasses):
- doc += getProperty(getTermLink(superclass), first)
- first = False
+ for s in findStatements(m, term, rdfs.subClassOf, None):
+ if findOne(m, getObject(s), rdf.type, owl.Restriction):
+ restrictions.append(getObject(s))
for r in sorted(restrictions):
props = findStatements(m, r, None, None)
@@ -501,38 +485,49 @@ def rdfsClassInfo(term, m):
elif getPredicate(p) == rdfs.comment:
comment = getObject(p)
if onProp is not None:
- doc += '<tr><th>Restriction on %s</th><td>' % getTermLink(onProp)
+ doc += '<dl><dt>Restriction on %s</dt>\n' % getTermLink(onProp)
prop_str = ''
- last_pred = None
- first = True
for p in findStatements(m, r, None, None):
if (getPredicate(p) == owl.onProperty
or getPredicate(p) == rdfs.comment
or (getPredicate(p) == rdf.type and getObject(p) == owl.Restriction)
or getPredicate(p) == lv2.documentation):
- last_pred = None
continue
- if getPredicate(p) != last_pred:
- prop_str += '<tr><th>%s</th>\n' % getTermLink(getPredicate(p))
- first = True
+ prop_str += getTermLink(getPredicate(p))
+
if isResource(getObject(p)):
- prop_str += getProperty(getTermLink(getObject(p)), first)
- first = False
+ prop_str += ' ' + getTermLink(getObject(p))
elif isLiteral(getObject(p)):
- prop_str += getProperty(getLiteralString(getObject(p)), first)
- first = False
+ prop_str += ' ' + getLiteralString(getObject(p))
- last_pred = getPredicate(p)
+ if comment is not None:
+ prop_str += '\n<div>%s</div>\n' % getLiteralString(comment)
- prop_str += endProperties(first)
+ doc += '<dd>%s</dd></dl>' % prop_str if prop_str else '';
- if prop_str != '':
- doc += '<table class=\"restriction\">%s</table>\n' % prop_str
- if comment is not None:
- doc += "<span>%s</span>\n" % getLiteralString(comment)
- doc += '</td></tr>'
+ return doc
+
+def rdfsClassInfo(term, m):
+ """Generate rdfs-type information for Classes: ranges, and domains."""
+ global classranges
+ global classdomains
+ doc = ""
+
+ # Find subClassOf information
+ superclasses = set()
+ for st in findStatements(m, term, rdfs.subClassOf, None):
+ if not isBlank(getObject(st)):
+ uri = getObject(st)
+ superclasses |= set([uri])
+
+ if len(superclasses) > 0:
+ doc += "\n<tr><th>Subclass of</th>"
+ first = True
+ for superclass in sorted(superclasses):
+ doc += getProperty(getTermLink(superclass), first)
+ first = False
# Find out about properties which have rdfs:domain of t
d = classdomains.get(str(term), "")
@@ -683,27 +678,15 @@ def docTerms(category, list, m, classlist, proplist, instalist):
is_deprecated = isDeprecated(m, term)
doc += '<div class="spectermbody">'
- if label != '' or comment != '' or is_deprecated:
- doc += '<div class="description">'
-
- if label != '':
- doc += "<div property=\"rdfs:label\" class=\"label\">%s</div>" % label
-
- if is_deprecated:
- doc += '<div class="warning">DEPRECATED</div>'
-
- if comment != '':
- doc += "<div property=\"rdfs:comment\">%s</div>" % comment
-
- if label != '' or comment != '' or is_deprecated:
- doc += "</div>"
terminfo = ""
+ extrainfo = ""
if category == 'Property':
terminfo += owlInfo(term, m)
terminfo += rdfsPropertyInfo(term, m)
if category == 'Class':
terminfo += rdfsClassInfo(term, m)
+ extrainfo += owlRestrictionInfo(term, m)
if category == 'Instance':
terminfo += rdfsInstanceInfo(term, m)
@@ -712,6 +695,23 @@ def docTerms(category, list, m, classlist, proplist, instalist):
if (len(terminfo) > 0): # to prevent empty list (bug #882)
doc += '\n<table class="terminfo">%s</table>\n' % terminfo
+ if label != '' or comment != '' or is_deprecated:
+ doc += '<div class="description">'
+
+ if label != '':
+ doc += "<div property=\"rdfs:label\" class=\"label\">%s</div>" % label
+
+ if is_deprecated:
+ doc += '<div class="warning">Deprecated</div>'
+
+ if comment != '':
+ doc += "<div class=\"comment\" property=\"rdfs:comment\">%s</div>" % comment
+
+ doc += extrainfo
+
+ if label != '' or comment != '' or is_deprecated:
+ doc += "</div>"
+
doc += '</div>'
doc += "\n</div>\n\n"
diff --git a/lv2specgen/template.html b/lv2specgen/template.html
index 5056aef..9d25d80 100644
--- a/lv2specgen/template.html
+++ b/lv2specgen/template.html
@@ -17,77 +17,79 @@
</head>
<body>
- <!-- HEADER -->
- <div id="topbar">
- <div id="header">
- <div id="titlebox">
- <h1 id="title">@NAME@</h1>
- <div id="subtitle"><a href="@URI@">@URI@</a></div>
- <div id="shortdesc">@SHORT_DESC@</div>
+ <!-- HEADER -->
+ <div id="topbar">
+ <div id="header">
+ <div id="titlebox">
+ <h1 id="title">@NAME@</h1>
+ <div id="shortdesc">@SHORT_DESC@</div>
+ </div>
+ <div id="metabox">
+ <table id="meta">
+ <tr><th>ID</th><td><a href="@URI@">@URI@</a></td></tr>
+ <tr><th>Version</th><td>@VERSION@</td></tr>
+ <tr><th>Date</th><td>@DATE@</td></tr>
+ @MAIL@
+ @AUTHORS@
+ </table>
+ </div>
</div>
- <table id="meta">
- <!--<tr><th>URI</th><td><a href="@URI@">@URI@</a></td></tr>
- <tr><th>Version</th><td>@REVISION@</td></tr>-->
- <!--<tr><th>Prefixes</th><td>@PREFIXES@</td></tr>-->
- <tr><th>Version</th><td>@VERSION@</td></tr>
- <tr><th>Date</th><td>@DATE@</td></tr>
- @MAIL@
- @AUTHORS@
- </table>
</div>
- <ul id="contents">
- <!-- <li><a href="#sec-description">Description</a></li> -->
- <li><a href="#sec-index">Index</a></li>
- <li><a href="#sec-reference">Reference</a></li>
- <li><a href="#sec-history">History</a></li>
- @CONTENT_LINKS@
- </ul>
- </div>
- <!-- DESCRIPTION -->
- <!--<h2 class="sec" id="sec-description">Description</h2>-->
- <div class="content">@COMMENT@</div>
+ <div id="content">
+ <div id="contentsbox">
+ <!-- Contents: -->
+ <ul id="contents">
+ <!-- <li><a href="#sec-description">Description</a></li> -->
+ <li><a href="#sec-reference">Reference</a></li>
+ <li><a href="#sec-history">History</a></li>
+ @CONTENT_LINKS@
+ </ul>
+ </div>
+ <hr class="contentssep" />
- <!-- INDEX -->
- <h2 class="sec" id="sec-index">Index</h2>
- <div class="content" id="index">
- @INDEX@
- </div>
+ <!-- DESCRIPTION -->
+ <!--<h2 class="sec" id="sec-description">Description</h2>-->
+ <div class="section">@COMMENT@</div>
- <!-- DOCUMENTATION -->
- <h2 class="sec" id="sec-reference">Reference</h2>
- <div class="content">
- @REFERENCE@
- </div>
+ <!-- REFERENCE -->
+ <h2 class="sec" id="sec-reference">Reference</h2>
+ <div class="section">
+ <div id="indexbox">
+ @INDEX@
+ @REFERENCE@
+ </div>
+ </div>
- <!-- HISTORY -->
- <h2 class="sec" id="sec-history">History</h2>
- <div class="content">
- @HISTORY@
- </div>
+ <!-- HISTORY -->
+ <h2 class="sec" id="sec-history">History</h2>
+ <div class="section">
+ @HISTORY@
+ </div>
- <!-- FOOTER -->
- <div id="footer">
- <div>
- This document is available under the
- <a about="" rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/">
- Creative Commons Attribution-ShareAlike License
- </a>
- </div>
- <div>
- Valid
- <a about="" rel="dct:conformsTo" resource="http://www.w3.org/TR/rdfa-syntax"
- href="http://validator.w3.org/check?uri=referer">
- XHTML+RDFa
- </a>
- and
- <a about="" rel="dct:conformsTo" resource="http://www.w3.org/TR/CSS2"
- href="http://jigsaw.w3.org/css-validator/check/referer">
- CSS
- </a>
- generated from @FILENAME@ by <a href="http://drobilla.net/software/lv2specgen">lv2specgen</a>
- </div>
- </div>
+ <!-- FOOTER -->
+ <div id="footer">
+ <div>
+ This document is available under the
+ <a about="" rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/">
+ Creative Commons Attribution-ShareAlike License
+ </a>
+ </div>
+ <div>
+ Valid
+ <a about="" rel="dct:conformsTo" resource="http://www.w3.org/TR/rdfa-syntax"
+ href="http://validator.w3.org/check?uri=referer">
+ XHTML+RDFa
+ </a>
+ and
+ <a about="" rel="dct:conformsTo" resource="http://www.w3.org/TR/CSS2"
+ href="http://jigsaw.w3.org/css-validator/check/referer">
+ CSS
+ </a>
+ generated from @FILENAME@ by <a href="http://drobilla.net/software/lv2specgen">lv2specgen</a>
+ </div>
+ </div>
+ </div>
</body>
</html>