Changeset 2125
- Timestamp:
- 06/16/09 21:30:37 (15 months ago)
- Location:
- trunk/lv2specgen
- Files:
-
- 2 modified
-
lv2specgen.py (modified) (5 diffs)
-
template.html (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/lv2specgen/lv2specgen.py
r2120 r2125 106 106 107 107 108 def termlink(string):109 """FOAF specific: function which replaces <code>foaf:*</code> with a110 link to the term in the document."""111 return re.sub(r"<code>" + spec_pre + r":(\w+)</code>", r"""<code><a href="#term_\1">""" + spec_pre + r""":\1</a></code>""", string)112 113 114 108 def return_name(m, urinode): 115 109 "Trims the namespace out of a term to give a name to the term." … … 147 141 f = open("%s/%s.en" % (termdir, t), "r") 148 142 doc = f.read() 149 doc = termlink(doc) 143 # replace <code>prefix:foo</code> with a link to foo in the document 144 doc = re.sub(r"<code>" + spec_pre + r":(\w+)</code>", 145 r"""<code><a href="#term_\1">""" + spec_pre + r""":\1</a></code>""", doc) 150 146 except: 151 147 return "" # "<p>No detailed documentation for this term.</p>" … … 260 256 # Find subClassOf information 261 257 o = m.find_statements( RDF.Statement(term, rdfs.subClassOf, None) ) 258 restrictions = [] 262 259 if o.current(): 263 260 superclasses = [] … … 267 264 if (not uri in superclasses): 268 265 superclasses.append(uri) 266 else: 267 meta_types = m.find_statements(RDF.Statement(o.current().object, rdf.type, None)) 268 restrictions.append(meta_types.current().subject) 269 269 270 if len(superclasses) > 0: 270 271 doc += "<dt>Sub-class of</dt>" 271 272 for superclass in superclasses: 272 273 doc += "<dd>%s</dd>" % getTermLink(superclass) 274 275 for r in restrictions: 276 props = m.find_statements(RDF.Statement(r, None, None)) 277 onProp = None 278 comment = None 279 for p in props: 280 if p.predicate == owl.onProperty: 281 onProp = p.object 282 elif p.predicate == rdfs.comment: 283 comment = p.object 284 if onProp != None: 285 doc += '<div class="restriction"><dt>Restriction on property %s</dt><dd>' % getTermLink(onProp.uri) 286 if comment != None: 287 doc += "<p>%s</p>\n" % comment 288 props = m.find_statements(RDF.Statement(r, None, None)) 289 doc += "<dl>" 290 for p in props: 291 if p.predicate != owl.onProperty and p.predicate != rdfs.comment and not( 292 p.predicate == rdf.type and p.object == owl.Restriction): 293 doc += "<dt>%s</dt><dd>%s</dd>" % (getTermLink(p.predicate.uri), getTermLink(p.object.uri)) 294 doc += "</dl></dd></div>" 273 295 274 296 # Find out about properties which have rdfs:domain of t … … 307 329 continue 308 330 if p.predicate != last_pred: 309 doc += '<dt>%s</dt>\n' % niceName(str(p.predicate.uri))331 doc += '<dt>%s</dt>\n' % getTermLink(str(p.predicate.uri)) 310 332 if p.object.is_resource(): 311 333 doc += '<dd>%s</dd>\n' % getTermLink(str(p.object.uri), term, p.predicate) -
trunk/lv2specgen/template.html
r2120 r2125 32 32 .subtitle { margin: 0; padding: 0; font-style: italic } 33 33 .index { padding: 1ex; border: dotted gray 2px; background-color: #eee; } 34 .restriction { border: dotted 2px silver; padding: 0.5ex; margin-bottom: 0.25ex; } 35 34 36 35 37 dl { padding: 0; margin: 0 } 36 dt { padding-top: 1ex; font-weight: bold } 38 dt { font-weight: bold ; } 39 dd { margin-bottom: 0.25ex; } 37 40 38 41 hr {
