Changeset 2118
- Timestamp:
- 06/16/09 14:57:39 (9 months ago)
- Location:
- trunk
- Files:
-
- 3 modified
-
lv2/ext/port_groups/lv2_port_groups.ttl (modified) (2 diffs)
-
lv2specgen/lv2specgen.py (modified) (24 diffs)
-
lv2specgen/template.html (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/lv2/ext/port_groups/lv2_port_groups.ttl
r2112 r2118 22 22 # OTHER DEALINGS IN THE SOFTWARE. 23 23 24 @prefix pg: <http://lv2plug.in/ns/ dev/port-groups#> .24 @prefix pg: <http://lv2plug.in/ns/ext/port-groups#> . 25 25 @prefix lv2: <http://lv2plug.in/ns/lv2core#> . 26 26 @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . … … 31 31 @prefix foaf: <http://xmlns.com/foaf/0.1/> . 32 32 33 <http://lv2plug.in/ns/ dev/port-groups> a lv2:Specification ;33 <http://lv2plug.in/ns/ext/port-groups> a lv2:Specification ; 34 34 doap:license <http://usefulinc.com/doap/licenses/mit> ; 35 35 doap:name "LV2 Port Groups" ; 36 rdfs:comment "Defines meaningfulgroupings of LV2 ports" ;36 rdfs:comment "Defines semantic groupings of LV2 ports" ; 37 37 doap:maintainer [ 38 38 a foaf:Person ; -
trunk/lv2specgen/lv2specgen.py
r2114 r2118 3 3 # 4 4 # lv2specgen, an LV2 extension specification page generator 5 #6 5 # Copyright (c) 2009 Dave Robillard <dave@drobilla.net> 7 6 # … … 80 79 } 81 80 82 rdf = RDF.NS('http://www.w3.org/1999/02/22-rdf-syntax-ns#')81 rdf = RDF.NS('http://www.w3.org/1999/02/22-rdf-syntax-ns#') 83 82 rdfs = RDF.NS('http://www.w3.org/2000/01/rdf-schema#') 84 owl = RDF.NS('http://www.w3.org/2002/07/owl#')85 vs = RDF.NS('http://www.w3.org/2003/06/sw-vocab-status/ns#')86 lv2 = RDF.NS('http://lv2plug.in/ns/lv2core#')83 owl = RDF.NS('http://www.w3.org/2002/07/owl#') 84 vs = RDF.NS('http://www.w3.org/2003/06/sw-vocab-status/ns#') 85 lv2 = RDF.NS('http://lv2plug.in/ns/lv2core#') 87 86 doap = RDF.NS('http://usefulinc.com/ns/doap#') 88 87 foaf = RDF.NS('http://xmlns.com/foaf/0.1/') … … 177 176 k = getTermLink(str(st.object.uri), term, rdfs.subPropertyOf) 178 177 rlist += "<dd>%s</dd>" % k 179 doc += "<dt> sub-property-of:</dt> %s" % rlist178 doc += "<dt>Sub-property of</dt> %s" % rlist 180 179 181 180 #domain stuff … … 193 192 domainsdoc += "<dd>%s</dd>" % getTermLink(str(d.object.uri), term, rdfs.domain) 194 193 if (len(domainsdoc)>0): 195 doc += "<dt>Domain :</dt> %s" % domainsdoc194 doc += "<dt>Domain</dt> %s" % domainsdoc 196 195 197 196 #range stuff … … 209 208 rangesdoc += "<dd>%s</dd>" % getTermLink(str(r.object.uri), term, rdfs.range) 210 209 if (len(rangesdoc)>0): 211 doc += "<dt>Range :</dt> %s" % rangesdoc210 doc += "<dt>Range</dt> %s" % rangesdoc 212 211 213 212 return doc … … 259 258 doc = "" 260 259 261 #patch to control incoming strings (FIXME, why??? drop it!)262 try:263 term.uri264 except:265 term = RDF.Node(RDF.Uri(term))266 267 260 # Find subClassOf information 268 261 o = m.find_statements( RDF.Statement(term, rdfs.subClassOf, None) ) 269 262 if o.current(): 270 doc += "<dt>sub-class-of:</dt>"271 263 superclasses = [] 272 264 for st in o: … … 275 267 if (not uri in superclasses): 276 268 superclasses.append(uri) 277 for superclass in superclasses: 278 doc += "<dd>%s</dd>" % getTermLink(superclass) 269 if len(superclasses) > 0: 270 doc += "<dt>Sub-class of</dt>" 271 for superclass in superclasses: 272 doc += "<dd>%s</dd>" % getTermLink(superclass) 279 273 280 274 # Find out about properties which have rdfs:domain of t … … 284 278 for k in d: 285 279 dlist += "<dd>%s</dd>" % getTermLink(k) 286 doc += "<dt> in-domain-of:</dt>" + dlist280 doc += "<dt>In domain of</dt>" + dlist 287 281 288 282 # Find out about properties which have rdfs:range of t … … 292 286 for k in r: 293 287 rlist += "<dd>%s</dd>" % getTermLink(k) 294 doc += "<dt> in-range-of:</dt>" + rlist288 doc += "<dt>In range of</dt>" + rlist 295 289 296 290 return doc 291 292 293 def isSpecial(pred): 294 """Return True if the predicate is "special" and shouldn't be emitted generically""" 295 return pred == rdf.type or pred == rdfs.range or pred == rdfs.domain or pred == rdfs.label or pred == rdfs.comment 296 297 298 def extraInfo(term,m): 299 """Generate information about misc. properties of a term""" 300 doc = "" 301 properties = m.find_statements(RDF.Statement(term, None, None)) 302 #if properties: 303 # doc += '<dl>\n' 304 last_pred = '' 305 for p in properties: 306 if isSpecial(p.predicate) or p.object.is_blank(): 307 continue 308 if p.predicate != last_pred: 309 doc += '<dt>%s</dt>\n' % niceName(str(p.predicate.uri)) 310 if p.object.is_resource(): 311 doc += '<dd>%s</dd>\n' % getTermLink(str(p.object.uri), term, p.predicate) 312 elif p.object.is_literal(): 313 doc += '<dd>%s</dd>\n' % str(p.object) 314 last_pred = p.predicate 315 #if properties: 316 # doc += '</dl>\n' 317 return doc 318 297 319 298 320 def rdfsInstanceInfo(term,m): … … 302 324 t = m.find_statements( RDF.Statement(RDF.Node(RDF.Uri(term)), rdf.type, None) ) 303 325 if t.current(): 304 doc += "<dt> RDF Type:</dt>"326 doc += "<dt>Type</dt>" 305 327 while t.current(): 306 328 doc += "<dd>%s</dd>" % getTermLink(str(t.current().object.uri), RDF.Node(RDF.Uri(term)), rdf.type) 307 329 t.next() 308 330 331 doc += extraInfo(RDF.Node(RDF.Uri(term)), m) 332 309 333 return doc 310 334 … … 326 350 o = m.find_statements( RDF.Statement(term, rdf.type, owl.DatatypeProperty) ) 327 351 if o.current(): 328 res += "<dt>OWL Type :</dt><dd>DatatypeProperty</dd>\n"352 res += "<dt>OWL Type</dt><dd>DatatypeProperty</dd>\n" 329 353 330 354 # Object Property ( owl.ObjectProperty ) 331 355 o = m.find_statements( RDF.Statement(term, rdf.type, owl.ObjectProperty) ) 332 356 if o.current(): 333 res += "<dt>OWL Type :</dt><dd>ObjectProperty</dd>\n"357 res += "<dt>OWL Type</dt><dd>ObjectProperty</dd>\n" 334 358 335 359 # Annotation Property ( owl.AnnotationProperty ) 336 360 o = m.find_statements( RDF.Statement(term, rdf.type, owl.AnnotationProperty) ) 337 361 if o.current(): 338 res += "<dt>OWL Type :</dt><dd>AnnotationProperty</dd>\n"362 res += "<dt>OWL Type</dt><dd>AnnotationProperty</dd>\n" 339 363 340 364 # IFPs ( owl.InverseFunctionalProperty ) 341 365 o = m.find_statements( RDF.Statement(term, rdf.type, owl.InverseFunctionalProperty) ) 342 366 if o.current(): 343 res += "<dt>OWL Type :</dt><dd>InverseFunctionalProperty (uniquely identifying property)</dd>\n"367 res += "<dt>OWL Type</dt><dd>InverseFunctionalProperty (uniquely identifying property)</dd>\n" 344 368 345 369 # Symmertic Property ( owl.SymmetricProperty ) 346 370 o = m.find_statements( RDF.Statement(term, rdf.type, owl.SymmetricProperty) ) 347 371 if o.current(): 348 res += "<dt>OWL Type :</dt><dd>SymmetricProperty</dd>\n"372 res += "<dt>OWL Type</dt><dd>SymmetricProperty</dd>\n" 349 373 350 374 return res … … 378 402 term_uri = term 379 403 380 doc += """<div class="specterm" id="term_%s" about="%s">\n<h3>%s :<a href="%s">%s</a></h3>\n""" % (t, term_uri, category, term_uri, curie)404 doc += """<div class="specterm" id="term_%s" about="%s">\n<h3>%s <a href="%s">%s</a></h3>\n""" % (t, term_uri, category, term_uri, curie) 381 405 382 406 label, comment = get_rdfs(m, term) 383 407 status = get_status(m, term) 384 doc += "<p><em>%s</em></p>" % label 408 if label!='': 409 doc += "<span property=\"rdfs:label\" class=\"subtitle\">%s</span>" % label 385 410 if comment!='': 386 411 doc += "<p property=\"rdfs:comment\">%s</p>" % comment … … 393 418 if category=='Instance': 394 419 terminfo += rdfsInstanceInfo(term,m) 420 421 terminfo += extraInfo(term,m) 422 395 423 if (len(terminfo)>0): #to prevent empty list (bug #882) 396 424 doc += "\n<dl>%s</dl>\n" % terminfo 425 397 426 doc += htmlDocInfo(t) 398 doc += "<p style=\"float: right; font-size: small;\">[<a href=\"#sec-glance\">back to top</a>]</p>\n\n"399 427 doc += "\n\n</div>\n\n" 400 428 … … 416 444 417 445 418 def build azlist(classlist, proplist, instalist=None):446 def buildIndex(classlist, proplist, instalist=None): 419 447 """ 420 448 Builds the A-Z list of terms. Args are a list of classes (strings) and 421 449 a list of props (strings) 422 450 """ 423 azlist = '<d iv style="padding: 1em; border: dotted; background-color: #ddd;">'451 azlist = '<dl class="index">' 424 452 425 453 if (len(classlist)>0): 426 azlist += "< p>Classes:"454 azlist += "<dt>Classes</dt><dd>" 427 455 classlist.sort() 428 456 for c in classlist: … … 430 458 c = c.split(spec_ns_str[-1])[1] 431 459 azlist = """%s <a href="#term_%s">%s</a>, """ % (azlist, c, c) 432 azlist = """%s \n</p>""" % azlist460 azlist = """%s</dd>\n""" % azlist 433 461 434 462 if (len(proplist)>0): 435 azlist += "< p>Properties:"463 azlist += "<dt>Properties</dt><dd>" 436 464 proplist.sort() 437 465 for p in proplist: … … 439 467 p = p.split(spec_ns_str[-1])[1] 440 468 azlist = """%s <a href="#term_%s">%s</a>, """ % (azlist, p, p) 441 azlist = """%s \n</p>""" % azlist469 azlist = """%s</dd>\n""" % azlist 442 470 443 471 if (instalist!=None and len(instalist)>0): 444 azlist += "< p>Instances:"472 azlist += "<dt>Instances</dt><dd>" 445 473 for i in instalist: 446 474 p = getShortName(i) 447 475 anchor = getAnchor(i) 448 476 azlist = """%s <a href="#term_%s">%s</a>, """ % (azlist, anchor, p) 449 azlist = """%s\n</p>""" % azlist 450 451 azlist = """%s\n</div>""" % azlist 452 return azlist 453 454 455 def build_simple_list(classlist, proplist, instalist=None): 456 """ 457 Builds a simple <ul> A-Z list of terms. Args are a list of classes (strings) and 458 a list of props (strings) 459 """ 460 461 azlist = """<div style="padding: 5px; border: dotted; background-color: #ddd;">""" 462 azlist = """%s\n<p>Classes:""" % azlist 463 azlist += """\n<ul>""" 464 465 classlist.sort() 466 for c in classlist: 467 azlist += """\n <li><a href="#term_%s">%s</a></li>""" % (c.replace(" ", ""), c) 468 azlist = """%s\n</ul></p>""" % azlist 469 470 azlist = """%s\n<p>Properties:""" % azlist 471 azlist += """\n<ul>""" 472 proplist.sort() 473 for p in proplist: 474 azlist += """\n <li><a href="#term_%s">%s</a></li>""" % (p.replace(" ", ""), p) 475 azlist = """%s\n</ul></p>""" % azlist 476 477 #FIXME: instances 478 479 azlist = """%s\n</div>""" % azlist 477 azlist = """%s</dd>\n""" % azlist 478 479 azlist = """%s\n</dl>""" % azlist 480 480 return azlist 481 481 … … 528 528 return classlist, proplist 529 529 530 530 531 def specProperty(m, subject, predicate): 531 532 "Return the rdfs:comment of the spec." … … 534 535 return str(c.object) 535 536 return '' 537 536 538 537 539 def specAuthors(m, subject): … … 542 544 ret += '<div class="author" property="dc:creator">' + j.object.literal_value['string'] + '</div>\n' 543 545 return ret 546 544 547 545 548 def getInstances(model, classes, properties): … … 599 602 instalist.sort(lambda x, y: cmp(getShortName(x).lower(), getShortName(y).lower())) 600 603 601 if mode == "spec": 602 # Build HTML list of terms. 603 azlist = buildazlist(classlist, proplist, instalist) 604 elif mode == "list": 605 # Build simple <ul> list of terms. 606 azlist = build_simple_list(classlist, proplist, instalist) 604 azlist = buildIndex(classlist, proplist, instalist) 607 605 608 606 # Generate Term HTML … … 623 621 template = re.sub(r"\$VersionInfo\$", owlVersionInfo(m).encode("utf-8"), template) 624 622 625 # NOTE: This works with the assumtpion that all "%" in the template are escaped to "%%" and it 626 # contains the same number of "%s" as the number of parameters in % ( ...parameters here... ) 627 template = template % (azlist, termlist.encode("utf-8")); 628 template += ("<!-- generated from %s by %s at %s -->" % 629 (os.path.basename(specloc), os.path.basename(sys.argv[0]), time.strftime('%X %x %Z'))) 630 623 template = template.replace('@INDEX@', azlist) 624 template = template.replace('@REFERENCE@', termlist.encode("utf-8")) 631 625 template = template.replace('@NAME@', specProperty(m, spec_url, doap.name)) 632 626 template = template.replace('@URI@', spec_url) … … 638 632 template = template.replace('@AUTHORS@', specAuthors(m, spec_url)) 639 633 634 template += ("<!-- generated from %s by %s at %s -->" % 635 (os.path.basename(specloc), os.path.basename(sys.argv[0]), time.strftime('%X %x %Z'))) 636 640 637 return template 641 638 … … 648 645 f.close() 649 646 except Exception, e: 650 print "Error writ ting infile \"" + path + "\": " + str(e)647 print "Error writing to file \"" + path + "\": " + str(e) 651 648 652 649 … … 695 692 """ % (script, script) 696 693 sys.exit(-1) 694 697 695 698 696 if __name__ == "__main__": -
trunk/lv2specgen/template.html
r2114 r2118 13 13 <meta name="generator" content="lv2specgen" /> 14 14 <!--<link rel="stylesheet" type="text/css" href="./style.css" />--> 15 <style type="text/css"> 16 17 /* BEGIN STYLE */ 18 19 body { 20 color: black; 21 background: white; 22 } 23 24 :link { color: #00C; background: transparent } 25 :visited { color: #609; background: transparent } 26 a:active { color: #C00; background: transparent } 27 28 h1, h2, h3, h4, h5, h6 { text-align: left; background-color: #eee; padding: 0.25ex } 29 h2, h3, h4, h5, h6 { margin-top: 2.5ex; } 30 h1, h2, h3 { color: #005A9C; } 31 32 .subtitle { margin: 0; padding: 0; font-style: italic } 33 .index { padding: 1ex; border: dotted gray 2px; background-color: #eee; } 34 35 dl { padding: 0; margin: 0 } 36 dt { padding-top: 1ex; font-weight: bold } 37 38 hr { 39 color: silver; 40 background-color: silver; 41 height: 1px; 42 border: 0; 43 margin-top: 3ex; 44 margin-bottom: 3ex 45 } 46 47 div.head { margin-bottom: 1em } 48 div.head h1 { margin-top: 2em; clear: both } 49 div.head table { margin-left: 2em; margin-top: 2em } 50 51 pre { margin-left: 2em } 52 /* 53 p { 54 margin-top: 0.6em; 55 margin-bottom: 0.6em; 56 } 57 */ 58 59 @media aural { 60 h1, h2, h3 { stress: 20; richness: 90 } 61 p.copyright { volume: x-soft; speech-rate: x-fast } 62 dt { pause-before: 20% } 63 pre { speak-punctuation: code } 64 } 65 66 /* END STYLE */ 67 68 </style> 15 69 </head> 16 70 <body> … … 30 84 <hr /> 31 85 <h2 id="abstract">Abstract</h2> 32 <p>This specification defines the "@NAME@" extension (with URI 33 <a href="@URI@">@URI@</a>) to the 34 <a href="http://lv2plug.in/ns/lv2core">LV2</a> specification.</p> 86 <p>@COMMENT@</p> 87 35 88 <h2 id="status">About this Document</h2> 36 <p>This document is an <a href="http://validator.w3.org/check/referer?outline=1&verbose=1" 37 title="Valid XHTML 1.0 Strict">XHTML+RDFa</a> 89 <p>This document describes “@NAME@” (<a href="@URI@">@URI@</a>), an extension to 90 <a href="http://lv2plug.in/ns/lv2core">LV2</a>.</p> 91 <p>This is an <a href="http://validator.w3.org/check/referer?outline=1&verbose=1" 92 title="Valid XHTML+RDFa">XHTML+RDFa</a> 38 93 page automatically generated from <a href="./@FILENAME@">@FILENAME@</a> by 39 94 <a href="http://drobilla.net/software/lv2specgen">lv2specgen</a>. … … 45 100 46 101 <p>Comments are welcome, please direct discussion to <a href="mailto:@MAIL@">@MAIL@</a>.</p> 47 <h2 id="contents"> Table ofContents</h2>102 <h2 id="contents">Contents</h2> 48 103 <ol id="toc"> 49 <li><a href="#desc">Description</a></li>50 104 <li><a href="#sec-glance">Index</a></li> 51 <li><a href="#reference">Reference</a></li> 52 </ol> 53 <h3>Appendices</h3> 54 <ol id="appendix"> 105 <li><a href="#reference">Documentation</a></li> 55 106 <li><a href="#references">References</a></li> 56 107 </ol> … … 58 109 59 110 <!-- ===================================================================== --> 60 <h2 id="desc">1 Description</h2> 61 <p>@COMMENT@</p> 62 63 <!-- ===================================================================== --> 64 <h2 id="sec-glance">2. Index</h2> 65 <p>An alphabetical index of @NAME@ terms, by class (concepts) and by property 66 (relationships, attributes), are given below. All the terms are hyperlinked 67 to their detailed description for quick reference.</p> 111 <h2 id="sec-glance">1. Index</h2> 68 112 <!-- The following is the script-generated index --> 69 %s113 @INDEX@ 70 114 <!-- End of the generated index --> 71 115 72 116 <!-- ===================================================================== --> 73 <h2 id="reference"> 3. Reference</h2>117 <h2 id="reference">2. Reference</h2> 74 118 <!-- The following is the script-generated class/property/instance reference --> 75 %s119 @REFERENCE@ 76 120 <!-- End of the generated reference --> 77 121 78 122 <!-- ===================================================================== --> 79 <h2 id="references">A References</h2> 123 <hr /> 124 <h2 id="references">3. References</h2> 80 125 <dl> 81 126 <dt class="label" id="ref-rfc2119">IETF RFC 2119</dt>
