From a87331accdaec222af6fe84cac0c703e334e5a5f Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 17 Nov 2011 05:16:53 +0000 Subject: Add change log and release links to RDF. Add "Version History" section to generated documentation. Move doap metadata to separate file. --- lv2specgen/lv2specgen.py | 67 +++++++++++++++++++++++++++++++++++++++++++++--- lv2specgen/template.html | 19 +++++++++++++- 2 files changed, 82 insertions(+), 4 deletions(-) (limited to 'lv2specgen') diff --git a/lv2specgen/lv2specgen.py b/lv2specgen/lv2specgen.py index eb60e7c..f04a329 100755 --- a/lv2specgen/lv2specgen.py +++ b/lv2specgen/lv2specgen.py @@ -90,7 +90,8 @@ ns_list = { "http://www.w3.org/2003/01/geo/wgs84_pos#" : "geo", "http://www.w3.org/2004/02/skos/core#" : "skos", "http://lv2plug.in/ns/lv2core#" : "lv2", - "http://usefulinc.com/ns/doap#" : "doap" + "http://usefulinc.com/ns/doap#" : "doap", + "http://ontologi.es/doap-changeset#" : "dcs" } rdf = rdflib.Namespace('http://www.w3.org/1999/02/22-rdf-syntax-ns#') @@ -98,6 +99,7 @@ rdfs = rdflib.Namespace('http://www.w3.org/2000/01/rdf-schema#') owl = rdflib.Namespace('http://www.w3.org/2002/07/owl#') lv2 = rdflib.Namespace('http://lv2plug.in/ns/lv2core#') doap = rdflib.Namespace('http://usefulinc.com/ns/doap#') +dcs = rdflib.Namespace('http://ontologi.es/doap-changeset#') foaf = rdflib.Namespace('http://xmlns.com/foaf/0.1/') @@ -864,6 +866,55 @@ def specAuthors(m, subject): return 'Authors' + doc + '' +def specHistory(m, subject): + entries = {} + for r in findStatements(m, None, doap.release, None): + release = getObject(r) + revNode = findOne(m, release, doap.revision, None) + if not revNode: + print "error: doap:release has no doap:revision" + continue + + rev = getLiteralString(getObject(revNode)) + + created = findOne(m, release, doap.created, None) + if not created: + print "error: doap:release has no doap:created" + continue + + dist = findOne(m, release, doap['file-release'], None) + if dist: + entry = '
Version %s' % (getObject(dist), rev) + else: + entry = '
Version %s' % rev + #print "warning: doap:release has no doap:file-release" + + entry += ' (%s)
' % ( + getLiteralString(getObject(created))) + + changeset = findOne(m, release, dcs.changeset, None) + if changeset: + entry += '
\n' + + entries[rev] = entry + + history = '
' + for e in sorted(entries.keys(), reverse=True): + history += entries[e] + history += '
' + return history + + def specVersion(m, subject): """ Return a (minorVersion, microVersion, date) tuple @@ -948,8 +999,19 @@ def specgen(specloc, indir, docdir, style_uri, doc_base, doclinks, instances=Fal m.parse(manifest_path, format='n3') m.parse(specloc, format='n3') + bundle_path = os.path.split(specloc[specloc.find(':') + 1:])[0] + abs_bundle_path = os.path.abspath(bundle_path) spec_url = getOntologyNS(m) + # Parse all seeAlso files in the bundle + for uri in specProperties(m, spec_url, rdfs.seeAlso): + if uri[:7] == 'file://': + path = uri[7:] + if (path.startswith(abs_bundle_path) + and path != os.path.abspath(specloc) + and path.endswith('.ttl')): + m.parse(path, format='n3') + spec_ns_str = spec_url if (spec_ns_str[-1] != "/" and spec_ns_str[-1] != "#"): spec_ns_str += "#" @@ -1012,6 +1074,7 @@ def specgen(specloc, indir, docdir, style_uri, doc_base, doclinks, instances=Fal template = template.replace('@FILENAME@', filename) template = template.replace('@HEADER@', basename + '.h') template = template.replace('@MAIL@', 'devel@lists.lv2plug.in') + template = template.replace('@HISTORY@', specHistory(m, spec_url)) version = specVersion(m, spec_url) # (minor, micro, date) date_string = version[2] @@ -1028,7 +1091,6 @@ def specgen(specloc, indir, docdir, style_uri, doc_base, doclinks, instances=Fal template = template.replace('@REVISION@', version_string) - bundle_path = os.path.split(specloc[specloc.find(':') + 1:])[0] header_path = bundle_path + '/' + basename + '.h' other_files = '' @@ -1045,7 +1107,6 @@ def specgen(specloc, indir, docdir, style_uri, doc_base, doclinks, instances=Fal header = basename + '.h' other_files += ', %s' % (header, header) - abs_bundle_path = os.path.abspath(bundle_path) see_also_files = specProperties(m, spec_url, rdfs.seeAlso) for f in see_also_files: uri = str(f) diff --git a/lv2specgen/template.html b/lv2specgen/template.html index 8906e6f..6065af6 100644 --- a/lv2specgen/template.html +++ b/lv2specgen/template.html @@ -32,8 +32,19 @@ @FILES@ - + +
+

Contents

+ +
+ +

Description

@COMMENT@
@@ -48,6 +59,12 @@ @REFERENCE@ + +

Version History

+
+ @HISTORY@ +
+