From ba92af715f52281d4b015cbff4651448e3a44bc3 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 8 May 2014 12:07:02 +0000 Subject: Improve documentation. --- lv2specgen/lv2specgen.py | 66 +++++++++++++++++++++++++++--------------------- 1 file changed, 37 insertions(+), 29 deletions(-) (limited to 'lv2specgen/lv2specgen.py') diff --git a/lv2specgen/lv2specgen.py b/lv2specgen/lv2specgen.py index 3040049..1c4b93c 100755 --- a/lv2specgen/lv2specgen.py +++ b/lv2specgen/lv2specgen.py @@ -866,15 +866,23 @@ def specProperties(m, subject, predicate): def specAuthors(m, subject): "Return an HTML description of the authors of the spec." + + subjects = [subject]; + p = findOne(m, subject, lv2.project, None) + if p: + subjects += [getObject(p)] + dev = set() - for i in findStatements(m, subject, doap.developer, None): - for j in findStatements(m, getObject(i), foaf.name, None): - dev.add(getLiteralString(getObject(j))) + for s in subjects: + for i in findStatements(m, s, doap.developer, None): + for j in findStatements(m, getObject(i), foaf.name, None): + dev.add(getLiteralString(getObject(j))) maint = set() - for i in findStatements(m, subject, doap.maintainer, None): - for j in findStatements(m, getObject(i), foaf.name, None): - maint.add(getLiteralString(getObject(j))) + for s in subjects: + for i in findStatements(m, s, doap.maintainer, None): + for j in findStatements(m, getObject(i), foaf.name, None): + maint.add(getLiteralString(getObject(j))) doc = '' @@ -1053,7 +1061,7 @@ def load_tags(path, docdir): return linkmap -def specgen(specloc, indir, style_uri, docdir, tags, opts, instances=False, offline=False): +def specgen(specloc, indir, style_uri, docdir, tags, opts, instances=False): """The meat and potatoes: Everything starts here.""" global spec_url @@ -1086,14 +1094,21 @@ def specgen(specloc, indir, style_uri, docdir, tags, opts, instances=False, offl spec_url = getOntologyNS(m) spec = rdflib.URIRef(spec_url) - # Parse all seeAlso files in the bundle - for uri in specProperties(m, spec, rdfs.seeAlso): - if uri[:7] == 'file://': - path = uri[7:] - if (path != os.path.abspath(specloc) - and path.endswith('.ttl')): + # Load all seeAlso files recursively + seeAlso = set() + done = False + while not done: + done = True + for uri in specProperties(m, spec, rdfs.seeAlso): + if uri[:7] == 'file://': + path = uri[7:] + if (path != os.path.abspath(specloc) and + path.endswith('ttl') and + path not in seeAlso): + seeAlso.add(path) m.parse(path, format='n3') - + done = False + spec_ns_str = spec_url if (spec_ns_str[-1] != "/" and spec_ns_str[-1] != "#"): spec_ns_str += "#" @@ -1140,7 +1155,7 @@ def specgen(specloc, indir, style_uri, docdir, tags, opts, instances=False, offl termlist += docTerms('Instance', instalist, m, classlist, proplist, instalist) template = template.replace('@NAME@', specProperty(m, spec, doap.name)) - template = template.replace('@SUBTITLE@', specProperty(m, spec, doap.shortdesc)) + template = template.replace('@SHORT_DESC@', specProperty(m, spec, doap.shortdesc)) template = template.replace('@URI@', spec) template = template.replace('@PREFIX@', spec_pre) if spec_pre == 'lv2': @@ -1175,7 +1190,7 @@ def specgen(specloc, indir, style_uri, docdir, tags, opts, instances=False, offl if date_string == "": date_string = "Undated" - version_string = "%s.%s (%s)" % (version[0], version[1], date_string) + version_string = "%s.%s" % (version[0], version[1]) experimental = (version[0] == 0 or version[1] % 2 == 1) if experimental: version_string += ' EXPERIMENTAL' @@ -1183,7 +1198,7 @@ def specgen(specloc, indir, style_uri, docdir, tags, opts, instances=False, offl if isDeprecated(m, rdflib.URIRef(spec_url)): version_string += ' DEPRECATED' - template = template.replace('@REVISION@', version_string) + template = template.replace('@VERSION@', version_string) file_list = '' see_also_files = specProperties(m, spec, rdfs.seeAlso) @@ -1197,24 +1212,16 @@ def specgen(specloc, indir, style_uri, docdir, tags, opts, instances=False, offl else: continue # Skip seeAlso file outside bundle - - if offline: - entry = uri - else: - entry = '%s' % (uri, uri) + entry = '%s' % (uri, uri) if uri.endswith('.h') or uri.endswith('.hpp'): name = os.path.basename(uri) - entry += ' - Documentation ' % ( + entry += ' (docs) ' % ( docdir + '/' + name.replace('.', '_8') + '.html') file_list += '
  • %s
  • ' % entry - else: + elif not uri.endswith('.doap.ttl'): file_list += '
  • %s
  • ' % entry - files = '' - if file_list: - files += '
  • Files
  • ' % file_list - - template = template.replace('@FILES@', files) + template = template.replace('@FILES@', file_list) comment = getComment(m, rdflib.URIRef(spec_url), classlist, proplist, instalist) if comment != '': @@ -1222,6 +1229,7 @@ def specgen(specloc, indir, style_uri, docdir, tags, opts, instances=False, offl else: template = template.replace('@COMMENT@', '') + template = template.replace('@DATE@', datetime.datetime.utcnow().strftime('%F')) template = template.replace('@TIME@', datetime.datetime.utcnow().strftime('%F %H:%M UTC')) return template -- cgit v1.2.1