diff options
Diffstat (limited to 'lv2specgen')
-rw-r--r-- | lv2specgen/DTD/xhtml-datatypes-1.mod.1 | 103 | ||||
-rw-r--r-- | lv2specgen/DTD/xhtml-metaAttributes-1.mod | 154 | ||||
-rw-r--r-- | lv2specgen/DTD/xhtml-rdfa-1.dtd | 472 | ||||
-rw-r--r-- | lv2specgen/DTD/xhtml-rdfa-model-1.mod | 249 | ||||
-rwxr-xr-x | lv2specgen/lv2specgen.py | 334 | ||||
-rw-r--r-- | lv2specgen/template.html | 130 |
6 files changed, 1173 insertions, 269 deletions
diff --git a/lv2specgen/DTD/xhtml-datatypes-1.mod.1 b/lv2specgen/DTD/xhtml-datatypes-1.mod.1 new file mode 100644 index 0000000..dde43e8 --- /dev/null +++ b/lv2specgen/DTD/xhtml-datatypes-1.mod.1 @@ -0,0 +1,103 @@ +<!-- ...................................................................... --> +<!-- XHTML Datatypes Module .............................................. --> +<!-- file: xhtml-datatypes-1.mod + + This is XHTML, a reformulation of HTML as a modular XML application. + Copyright 1998-2005 W3C (MIT, ERCIM, Keio), All Rights Reserved. + Revision: $Id: xhtml-datatypes-1.mod,v 4.1 2001/04/06 19:23:32 altheim Exp $ SMI + + This DTD module is identified by the PUBLIC and SYSTEM identifiers: + + PUBLIC "-//W3C//ENTITIES XHTML Datatypes 1.0//EN" + SYSTEM "http://www.w3.org/MarkUp/DTD/xhtml-datatypes-1.mod" + + Revisions: + (none) + ....................................................................... --> + +<!-- Datatypes + + defines containers for the following datatypes, many of + these imported from other specifications and standards. +--> + +<!-- Length defined for cellpadding/cellspacing --> + +<!-- nn for pixels or nn% for percentage length --> +<!ENTITY % Length.datatype "CDATA" > + +<!-- space-separated list of link types --> +<!ENTITY % LinkTypes.datatype "NMTOKENS" > + +<!-- single or comma-separated list of media descriptors --> +<!ENTITY % MediaDesc.datatype "CDATA" > + +<!-- pixel, percentage, or relative --> +<!ENTITY % MultiLength.datatype "CDATA" > + +<!-- one or more digits (NUMBER) --> +<!ENTITY % Number.datatype "CDATA" > + +<!-- integer representing length in pixels --> +<!ENTITY % Pixels.datatype "CDATA" > + +<!-- script expression --> +<!ENTITY % Script.datatype "CDATA" > + +<!-- textual content --> +<!ENTITY % Text.datatype "CDATA" > + +<!-- Placeholder Compact URI-related types --> +<!ENTITY % CURIE.datatype "CDATA" > +<!ENTITY % CURIEs.datatype "CDATA" > +<!ENTITY % SafeCURIE.datatype "CDATA" > +<!ENTITY % SafeCURIEs.datatype "CDATA" > +<!ENTITY % URIorSafeCURIE.datatype "CDATA" > +<!ENTITY % URIorSafeCURIEs.datatype "CDATA" > + +<!-- Imported Datatypes ................................ --> + +<!-- a single character from [ISO10646] --> +<!ENTITY % Character.datatype "CDATA" > + +<!-- a character encoding, as per [RFC2045] --> +<!ENTITY % Charset.datatype "CDATA" > + +<!-- a space separated list of character encodings, as per [RFC2045] --> +<!ENTITY % Charsets.datatype "CDATA" > + +<!-- Color specification using color name or sRGB (#RRGGBB) values --> +<!ENTITY % Color.datatype "CDATA" > + +<!-- media type, as per [RFC2045] --> +<!ENTITY % ContentType.datatype "CDATA" > + +<!-- comma-separated list of media types, as per [RFC2045] --> +<!ENTITY % ContentTypes.datatype "CDATA" > + +<!-- date and time information. ISO date format --> +<!ENTITY % Datetime.datatype "CDATA" > + +<!-- formal public identifier, as per [ISO8879] --> +<!ENTITY % FPI.datatype "CDATA" > + +<!-- a language code, as per [RFC3066] or its successor --> +<!ENTITY % LanguageCode.datatype "CDATA" > + +<!-- a comma separated list of language code ranges --> +<!ENTITY % LanguageCodes.datatype "CDATA" > + +<!-- a qualified name , as per [XMLNS] or its successor --> +<!ENTITY % QName.datatype "CDATA" > +<!ENTITY % QNames.datatype "CDATA" > + +<!-- a Uniform Resource Identifier, see [URI] --> +<!ENTITY % URI.datatype "CDATA" > + +<!-- a space-separated list of Uniform Resource Identifiers, see [URI] --> +<!ENTITY % URIs.datatype "CDATA" > + +<!-- a relative URI reference consisting of an initial '#' and a fragment ID --> +<!ENTITY % URIREF.datatype "CDATA" > + +<!-- end of xhtml-datatypes-1.mod --> diff --git a/lv2specgen/DTD/xhtml-metaAttributes-1.mod b/lv2specgen/DTD/xhtml-metaAttributes-1.mod new file mode 100644 index 0000000..b434e39 --- /dev/null +++ b/lv2specgen/DTD/xhtml-metaAttributes-1.mod @@ -0,0 +1,154 @@ +<!-- ...................................................................... --> +<!-- XHTML MetaAttributes Module ......................................... --> +<!-- file: xhtml-metaAttributes-1.mod + + This is XHTML-RDFa, modules to annotate XHTML family documents. + Copyright 2007-2008 W3C (MIT, ERCIM, Keio), All Rights Reserved. + Revision: $Id: xhtml-metaAttributes-1.mod,v 1.6 2008/08/01 20:01:00 smccarro Exp $ + + This DTD module is identified by the PUBLIC and SYSTEM identifiers: + + PUBLIC "-//W3C//ENTITIES XHTML MetaAttributes 1.0//EN" + SYSTEM "http://www.w3.org/MarkUp/DTD/xhtml-metaAttributes-1.mod" + + Revisions: + (none) + ....................................................................... --> + +<!ENTITY % XHTML.global.attrs.prefixed "IGNORE" > + +<!-- Placeholder Compact URI-related types --> +<!ENTITY % CURIE.datatype "CDATA" > +<!ENTITY % CURIEs.datatype "CDATA" > +<!ENTITY % SafeCURIE.datatype "CDATA" > +<!ENTITY % SafeCURIEs.datatype "CDATA" > +<!ENTITY % URIorSafeCURIE.datatype "CDATA" > +<!ENTITY % URIorSafeCURIEs.datatype "CDATA" > + +<!-- Common Attributes + + This module declares a collection of meta-information related + attributes. + + %NS.decl.attrib; is declared in the XHTML Qname module. + + This file also includes declarations of "global" versions of the + attributes. The global versions of the attributes are for use on + elements in other namespaces. +--> + +<!ENTITY % about.attrib + "about %URIorSafeCURIE.datatype; #IMPLIED" +> + +<![%XHTML.global.attrs.prefixed;[ +<!ENTITY % XHTML.global.about.attrib + "%XHTML.prefix;:about %URIorSafeCURIE.datatype; #IMPLIED" +> +]]> + +<!ENTITY % typeof.attrib + "typeof %CURIEs.datatype; #IMPLIED" +> + +<![%XHTML.global.attrs.prefixed;[ +<!ENTITY % XHTML.global.typeof.attrib + "%XHTML.prefix;:typeof %CURIEs.datatype; #IMPLIED" +> +]]> + +<!ENTITY % property.attrib + "property %CURIEs.datatype; #IMPLIED" +> + +<![%XHTML.global.attrs.prefixed;[ +<!ENTITY % XHTML.global.property.attrib + "%XHTML.prefix;:property %CURIEs.datatype; #IMPLIED" +> +]]> + +<!ENTITY % resource.attrib + "resource %URIorSafeCURIE.datatype; #IMPLIED" +> + +<![%XHTML.global.attrs.prefixed;[ +<!ENTITY % XHTML.global.resource.attrib + "%XHTML.prefix;:resource %URIorSafeCURIE.datatype; #IMPLIED" +> +]]> + +<!ENTITY % content.attrib + "content CDATA #IMPLIED" +> + +<![%XHTML.global.attrs.prefixed;[ +<!ENTITY % XHTML.global.content.attrib + "%XHTML.prefix;:content CDATA #IMPLIED" +> +]]> + +<!ENTITY % datatype.attrib + "datatype %CURIE.datatype; #IMPLIED" +> + +<![%XHTML.global.attrs.prefixed;[ +<!ENTITY % XHTML.global.datatype.attrib + "%XHTML.prefix;:datatype %CURIE.datatype; #IMPLIED" +> +]]> + +<!ENTITY % rel.attrib + "rel %CURIEs.datatype; #IMPLIED" +> + +<![%XHTML.global.attrs.prefixed;[ +<!ENTITY % XHTML.global.rel.attrib + "%XHTML.prefix;:rel %CURIEs.datatype; #IMPLIED" +> +]]> + +<!ENTITY % rev.attrib + "rev %CURIEs.datatype; #IMPLIED" +> + +<![%XHTML.global.attrs.prefixed;[ +<!ENTITY % XHTML.global.rev.attrib + "%XHTML.prefix;:rev %CURIEs.datatype; #IMPLIED" +> +]]> + +<!ENTITY % Metainformation.extra.attrib "" > + +<!ENTITY % Metainformation.attrib + "%about.attrib; + %content.attrib; + %datatype.attrib; + %typeof.attrib; + %property.attrib; + %rel.attrib; + %resource.attrib; + %rev.attrib; + %Metainformation.extra.attrib;" +> + +<!ENTITY % XHTML.global.metainformation.extra.attrib "" > + +<![%XHTML.global.attrs.prefixed;[ + +<!ENTITY % XHTML.global.metainformation.attrib + "%XHTML.global.about.attrib; + %XHTML.global.content.attrib; + %XHTML.global.datatype.attrib; + %XHTML.global.typeof.attrib; + %XHTML.global.property.attrib; + %XHTML.global.rel.attrib; + %XHTML.global.resource.attrib; + %XHTML.global.rev.attrib; + %XHTML.global.metainformation.extra.attrib;" +> +]]> + +<!ENTITY % XHTML.global.metainformation.attrib "" > + + +<!-- end of xhtml-metaAttributes-1.mod --> diff --git a/lv2specgen/DTD/xhtml-rdfa-1.dtd b/lv2specgen/DTD/xhtml-rdfa-1.dtd new file mode 100644 index 0000000..26ed117 --- /dev/null +++ b/lv2specgen/DTD/xhtml-rdfa-1.dtd @@ -0,0 +1,472 @@ +<!-- ....................................................................... --> +<!-- XHTML 1.1 + RDFa DTD ................................................. --> +<!-- file: xhtml-rdfa-1.dtd +--> + +<!-- XHTML 1.1 + RDFa DTD + + This is an example markup language combining XHTML 1.1 and the RDFa + modules. + + XHTML+RDFa + Copyright 1998-2008 World Wide Web Consortium + (Massachusetts Institute of Technology, European Research Consortium + for Informatics and Mathematics, Keio University). + All Rights Reserved. + + Permission to use, copy, modify and distribute the XHTML DTD and its + accompanying documentation for any purpose and without fee is hereby + granted in perpetuity, provided that the above copyright notice and + this paragraph appear in all copies. The copyright holders make no + representation about the suitability of the DTD for any purpose. + + It is provided "as is" without expressed or implied warranty. + +--> +<!-- This is the driver file for version 1 of the XHTML + RDFa DTD. + + Please use this public identifier to identify it: + + "-//W3C//DTD XHTML+RDFa 1.0//EN" +--> +<!ENTITY % XHTML.version "XHTML+RDFa 1.0" > + +<!-- Use this URI to identify the default namespace: + + "http://www.w3.org/1999/xhtml" + + See the Qualified Names module for information + on the use of namespace prefixes in the DTD. + + Note that XHTML namespace elements are not prefixed by default, + but the XHTML namespace prefix is defined as "xhtml" so that + other markup languages can extend this one and use the XHTML + prefixed global attributes if required. + +--> +<!ENTITY % NS.prefixed "IGNORE" > +<!ENTITY % XHTML.prefix "xhtml" > + +<!-- Be sure to include prefixed global attributes - we don't need + them, but languages that extend XHTML 1.1 might. +--> +<!ENTITY % XHTML.global.attrs.prefixed "INCLUDE" > + +<!-- Reserved for use with the XLink namespace: +--> +<!ENTITY % XLINK.xmlns "" > +<!ENTITY % XLINK.xmlns.attrib "" > + +<!-- For example, if you are using XHTML 1.1 directly, use the public + identifier in the DOCTYPE declaration, with the namespace declaration + on the document element to identify the default namespace: + + <?xml version="1.0"?> + <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" + "xhtml-rdfa-1.dtd"> + <html xmlns="http://www.w3.org/1999/xhtml" + xml:lang="en"> + ... + </html> + + Revisions: + (none) +--> + +<!-- reserved for future use with document profiles --> +<!ENTITY % XHTML.profile "" > + +<!-- ensure XHTML Notations are disabled --> +<!ENTITY % xhtml-notations.module "IGNORE" > + +<!-- Bidirectional Text features + This feature-test entity is used to declare elements + and attributes used for bidirectional text support. +--> +<!ENTITY % XHTML.bidi "INCLUDE" > + +<!-- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: --> + +<!-- Pre-Framework Redeclaration placeholder .................... --> +<!-- this serves as a location to insert markup declarations + into the DTD prior to the framework declarations. +--> +<!ENTITY % xhtml-prefw-redecl.module "IGNORE" > +<!ENTITY % xhtml-prefw-redecl.mod "" > +<![%xhtml-prefw-redecl.module;[ +%xhtml-prefw-redecl.mod; +<!-- end of xhtml-prefw-redecl.module -->]]> + +<!-- we need the datatypes now --> +<!ENTITY % xhtml-datatypes.module "INCLUDE" > +<![%xhtml-datatypes.module;[ +<!ENTITY % xhtml-datatypes.mod + PUBLIC "-//W3C//ENTITIES XHTML Datatypes 1.0//EN" + "xhtml-datatypes-1.mod" > +%xhtml-datatypes.mod;]]> + +<!-- bring in the RDFa attributes cause we need them in Common --> +<!ENTITY % xhtml-metaAttributes.module "INCLUDE" > +<![%xhtml-metaAttributes.module;[ +<!ENTITY % xhtml-metaAttributes.mod + PUBLIC "-//W3C//ENTITIES XHTML MetaAttributes 1.0//EN" + "xhtml-metaAttributes-1.mod" > +%xhtml-metaAttributes.mod;]]> + +<!ENTITY % xhtml-events.module "INCLUDE" > + +<!ENTITY % Common.extra.attrib + "href %URI.datatype; #IMPLIED + %Metainformation.attrib;" +> +<!-- adding the lang attribute into the I18N collection --> + +<!ENTITY % lang.attrib + "xml:lang %LanguageCode.datatype; #IMPLIED + lang %LanguageCode.datatype; #IMPLIED" +> + +<!-- Inline Style Module ........................................ --> +<!ENTITY % xhtml-inlstyle.module "INCLUDE" > +<![%xhtml-inlstyle.module;[ +<!ENTITY % xhtml-inlstyle.mod + PUBLIC "-//W3C//ELEMENTS XHTML Inline Style 1.0//EN" + "xhtml-inlstyle-1.mod" > +%xhtml-inlstyle.mod;]]> + +<!-- declare Document Model module instantiated in framework +--> +<!ENTITY % xhtml-model.mod + PUBLIC "-//W3C//ENTITIES XHTML+RDFa Document Model 1.0//EN" + "xhtml-rdfa-model-1.mod" > + +<!-- Modular Framework Module (required) ......................... --> +<!ENTITY % xhtml-framework.module "INCLUDE" > +<![%xhtml-framework.module;[ +<!ENTITY % xhtml-framework.mod + PUBLIC "-//W3C//ENTITIES XHTML Modular Framework 1.0//EN" + "xhtml-framework-1.mod" > +%xhtml-framework.mod;]]> + +<!-- Post-Framework Redeclaration placeholder ................... --> +<!-- this serves as a location to insert markup declarations + into the DTD following the framework declarations. +--> +<!ENTITY % xhtml-postfw-redecl.module "IGNORE" > +<!ENTITY % xhtml-postfw-redecl.mod ""> +<![%xhtml-postfw-redecl.module;[ +%xhtml-postfw-redecl.mod; +<!-- end of xhtml-postfw-redecl.module -->]]> + + + +<!-- Text Module (Required) ..................................... --> +<!ENTITY % xhtml-text.module "INCLUDE" > +<![%xhtml-text.module;[ +<!ENTITY % xhtml-text.mod + PUBLIC "-//W3C//ELEMENTS XHTML Text 1.0//EN" + "xhtml-text-1.mod" > +%xhtml-text.mod;]]> + +<!-- Hypertext Module (required) ................................. --> +<!ENTITY % a.attlist "IGNORE" > +<!ENTITY % xhtml-hypertext.module "INCLUDE" > +<![%xhtml-hypertext.module;[ +<!ENTITY % xhtml-hypertext.mod + PUBLIC "-//W3C//ELEMENTS XHTML Hypertext 1.0//EN" + "xhtml-hypertext-1.mod" > +%xhtml-hypertext.mod;]]> +<!ATTLIST %a.qname; + %Common.attrib; + charset %Charset.datatype; #IMPLIED + type %ContentType.datatype; #IMPLIED + hreflang %LanguageCode.datatype; #IMPLIED + accesskey %Character.datatype; #IMPLIED + tabindex %Number.datatype; #IMPLIED +> + +<!-- Lists Module (required) .................................... --> +<!ENTITY % xhtml-list.module "INCLUDE" > +<![%xhtml-list.module;[ +<!ENTITY % xhtml-list.mod + PUBLIC "-//W3C//ELEMENTS XHTML Lists 1.0//EN" + "xhtml-list-1.mod" > +%xhtml-list.mod;]]> + +<!-- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: --> + +<!-- Edit Module ................................................ --> +<!ENTITY % xhtml-edit.module "INCLUDE" > +<![%xhtml-edit.module;[ +<!ENTITY % xhtml-edit.mod + PUBLIC "-//W3C//ELEMENTS XHTML Editing Elements 1.0//EN" + "xhtml-edit-1.mod" > +%xhtml-edit.mod;]]> + +<!-- BIDI Override Module ....................................... --> +<!ENTITY % xhtml-bdo.module "%XHTML.bidi;" > +<![%xhtml-bdo.module;[ +<!ENTITY % xhtml-bdo.mod + PUBLIC "-//W3C//ELEMENTS XHTML BIDI Override Element 1.0//EN" + "xhtml-bdo-1.mod" > +%xhtml-bdo.mod;]]> + +<!-- Ruby Module ................................................ --> +<!ENTITY % Ruby.common.attlists "INCLUDE" > +<!ENTITY % Ruby.common.attrib "%Common.attrib;" > +<!ENTITY % xhtml-ruby.module "INCLUDE" > +<![%xhtml-ruby.module;[ +<!ENTITY % xhtml-ruby.mod + PUBLIC "-//W3C//ELEMENTS XHTML Ruby 1.0//EN" + "http://www.w3.org/TR/ruby/xhtml-ruby-1.mod" > +%xhtml-ruby.mod;]]> + +<!-- Presentation Module ........................................ --> +<!ENTITY % xhtml-pres.module "INCLUDE" > +<![%xhtml-pres.module;[ +<!ENTITY % xhtml-pres.mod + PUBLIC "-//W3C//ELEMENTS XHTML Presentation 1.0//EN" + "xhtml-pres-1.mod" > +%xhtml-pres.mod;]]> + +<!ENTITY % link.attlist "IGNORE" > +<!-- Link Element Module ........................................ --> +<!ENTITY % xhtml-link.module "INCLUDE" > +<![%xhtml-link.module;[ +<!ENTITY % xhtml-link.mod + PUBLIC "-//W3C//ELEMENTS XHTML Link Element 1.0//EN" + "xhtml-link-1.mod" > +%xhtml-link.mod;]]> + +<!ATTLIST %link.qname; + %Common.attrib; + charset %Charset.datatype; #IMPLIED + hreflang %LanguageCode.datatype; #IMPLIED + type %ContentType.datatype; #IMPLIED + media %MediaDesc.datatype; #IMPLIED +> + +<!-- Document Metainformation Module ............................ --> +<!ENTITY % meta.attlist "IGNORE" > +<!ENTITY % xhtml-meta.module "INCLUDE" > +<![%xhtml-meta.module;[ +<!ENTITY % xhtml-meta.mod + PUBLIC "-//W3C//ELEMENTS XHTML Metainformation 1.0//EN" + "xhtml-meta-1.mod" > +%xhtml-meta.mod;]]> +<!ATTLIST %meta.qname; + %Common.attrib; + http-equiv NMTOKEN #IMPLIED + name NMTOKEN #IMPLIED + scheme CDATA #IMPLIED +> + +<!-- Base Element Module ........................................ --> +<!ENTITY % xhtml-base.module "INCLUDE" > +<![%xhtml-base.module;[ +<!ENTITY % xhtml-base.mod + PUBLIC "-//W3C//ELEMENTS XHTML Base Element 1.0//EN" + "xhtml-base-1.mod" > +%xhtml-base.mod;]]> + +<!-- Scripting Module ........................................... --> +<!ENTITY % script.attlist "IGNORE" > +<!ENTITY % xhtml-script.module "INCLUDE" > +<![%xhtml-script.module;[ +<!ENTITY % xhtml-script.mod + PUBLIC "-//W3C//ELEMENTS XHTML Scripting 1.0//EN" + "xhtml-script-1.mod" > +%xhtml-script.mod;]]> + +<!ATTLIST %script.qname; + %XHTML.xmlns.attrib; + %id.attrib; + %Metainformation.attrib; + href %URI.datatype; #IMPLIED + xml:space ( preserve ) #FIXED 'preserve' + charset %Charset.datatype; #IMPLIED + type %ContentType.datatype; #REQUIRED + src %URI.datatype; #IMPLIED + defer ( defer ) #IMPLIED +> + +<!-- Style Sheets Module ......................................... --> +<!ENTITY % style.attlist "IGNORE" > +<!ENTITY % xhtml-style.module "INCLUDE" > +<![%xhtml-style.module;[ +<!ENTITY % xhtml-style.mod + PUBLIC "-//W3C//ELEMENTS XHTML Style Sheets 1.0//EN" + "xhtml-style-1.mod" > +%xhtml-style.mod;]]> +<!ATTLIST %style.qname; + %XHTML.xmlns.attrib; + %id.attrib; + %title.attrib; + %I18n.attrib; + %Metainformation.attrib; + href %URI.datatype; #IMPLIED + xml:space ( preserve ) #FIXED 'preserve' + type %ContentType.datatype; #REQUIRED + media %MediaDesc.datatype; #IMPLIED +> + +<!-- Image Module ............................................... --> +<!ENTITY % xhtml-image.module "INCLUDE" > +<![%xhtml-image.module;[ +<!ENTITY % xhtml-image.mod + PUBLIC "-//W3C//ELEMENTS XHTML Images 1.0//EN" + "xhtml-image-1.mod" > +%xhtml-image.mod;]]> + +<!-- Client-side Image Map Module ............................... --> +<!ENTITY % area.attlist "IGNORE" > + +<!ENTITY % xhtml-csismap.module "INCLUDE" > +<![%xhtml-csismap.module;[ +<!ENTITY % xhtml-csismap.mod + PUBLIC "-//W3C//ELEMENTS XHTML Client-side Image Maps 1.0//EN" + "xhtml-csismap-1.mod" > +%xhtml-csismap.mod;]]> + +<!ATTLIST %area.qname; + %Common.attrib; + shape %Shape.datatype; 'rect' + coords %Coords.datatype; #IMPLIED + nohref ( nohref ) #IMPLIED + alt %Text.datatype; #REQUIRED + tabindex %Number.datatype; #IMPLIED + accesskey %Character.datatype; #IMPLIED +> + +<!-- Server-side Image Map Module ............................... --> +<!ENTITY % xhtml-ssismap.module "INCLUDE" > +<![%xhtml-ssismap.module;[ +<!ENTITY % xhtml-ssismap.mod + PUBLIC "-//W3C//ELEMENTS XHTML Server-side Image Maps 1.0//EN" + "xhtml-ssismap-1.mod" > +%xhtml-ssismap.mod;]]> + +<!-- Param Element Module ....................................... --> +<!ENTITY % param.attlist "IGNORE" > +<!ENTITY % xhtml-param.module "INCLUDE" > +<![%xhtml-param.module;[ +<!ENTITY % xhtml-param.mod + PUBLIC "-//W3C//ELEMENTS XHTML Param Element 1.0//EN" + "xhtml-param-1.mod" > +%xhtml-param.mod;]]> + +<!ATTLIST %param.qname; + %XHTML.xmlns.attrib; + %id.attrib; + %Metainformation.attrib; + href %URI.datatype; #IMPLIED + name CDATA #REQUIRED + value CDATA #IMPLIED + valuetype ( data | ref | object ) 'data' + type %ContentType.datatype; #IMPLIED +> +<!-- Embedded Object Module ..................................... --> +<!ENTITY % xhtml-object.module "INCLUDE" > +<![%xhtml-object.module;[ +<!ENTITY % xhtml-object.mod + PUBLIC "-//W3C//ELEMENTS XHTML Embedded Object 1.0//EN" + "xhtml-object-1.mod" > +%xhtml-object.mod;]]> + +<!-- Tables Module ............................................... --> +<!ENTITY % xhtml-table.module "INCLUDE" > +<![%xhtml-table.module;[ +<!ENTITY % xhtml-table.mod + PUBLIC "-//W3C//ELEMENTS XHTML Tables 1.0//EN" + "xhtml-table-1.mod" > +%xhtml-table.mod;]]> + +<!-- Forms Module ............................................... --> +<!ENTITY % xhtml-form.module "INCLUDE" > +<![%xhtml-form.module;[ +<!ENTITY % xhtml-form.mod + PUBLIC "-//W3C//ELEMENTS XHTML Forms 1.0//EN" + "xhtml-form-1.mod" > +%xhtml-form.mod;]]> + +<!-- Target Attribute Module .................................... --> +<!ENTITY % xhtml-target.module "INCLUDE" > +<![%xhtml-target.module;[ +<!ENTITY % xhtml-target.mod + PUBLIC "-//W3C//ELEMENTS XHTML Target 1.0//EN" + "xhtml-target-1.mod" > +%xhtml-target.mod;]]> + +<!-- Legacy Markup ............................................... --> +<!ENTITY % xhtml-legacy.module "IGNORE" > +<![%xhtml-legacy.module;[ +<!ENTITY % xhtml-legacy.mod + PUBLIC "-//W3C//ELEMENTS XHTML Legacy Markup 1.0//EN" + "xhtml-legacy-1.mod" > +%xhtml-legacy.mod;]]> + +<!-- Document Structure Module (required) ....................... --> +<!ENTITY % html.attlist "IGNORE" > +<!ENTITY % head.attlist "IGNORE" > +<!ENTITY % title.attlist "IGNORE" > +<!ENTITY % xhtml-struct.module "INCLUDE" > +<![%xhtml-struct.module;[ +<!ENTITY % xhtml-struct.mod + PUBLIC "-//W3C//ELEMENTS XHTML Document Structure 1.0//EN" + "xhtml-struct-1.mod" > +%xhtml-struct.mod;]]> +<!ENTITY % profile.attrib + "profile %URI.datatype; '%XHTML.profile;'" +> +<!ENTITY % XHTML.version.attrib + "version %FPI.datatype; #FIXED '%XHTML.version;'" +> +<!ATTLIST %html.qname; + %Common.attrib; + %XSI.schemaLocation.attrib; + %XHTML.version.attrib; +> +<!ATTLIST %head.qname; + %Common.attrib; + %profile.attrib; +> +<!ATTLIST %title.qname; + %Common.attrib; +> + +<!-- end of XHTML-RDFa DTD ................................................ --> +<!-- ....................................................................... --> + +<!-- Add xmlns attributes to validate lv2specgen output --> +<!-- This is a pretty dirty hack, but avoids needing to write a bunch of code to + mangle DTDs to appease validation --> + +<!ATTLIST html xmlns:dc CDATA #IMPLIED> +<!ATTLIST html xmlns:dct CDATA #IMPLIED> +<!ATTLIST html xmlns:rdf CDATA #IMPLIED> +<!ATTLIST html xmlns:rdfs CDATA #IMPLIED> + +<!ATTLIST html xmlns:atom CDATA #IMPLIED> +<!ATTLIST html xmlns:bufsz CDATA #IMPLIED> +<!ATTLIST html xmlns:da CDATA #IMPLIED> +<!ATTLIST html xmlns:dman CDATA #IMPLIED> +<!ATTLIST html xmlns:ev CDATA #IMPLIED> +<!ATTLIST html xmlns:ia CDATA #IMPLIED> +<!ATTLIST html xmlns:log CDATA #IMPLIED> +<!ATTLIST html xmlns:lv2 CDATA #IMPLIED> +<!ATTLIST html xmlns:midi CDATA #IMPLIED> +<!ATTLIST html xmlns:morph CDATA #IMPLIED> +<!ATTLIST html xmlns:opts CDATA #IMPLIED> +<!ATTLIST html xmlns:param CDATA #IMPLIED> +<!ATTLIST html xmlns:patch CDATA #IMPLIED> +<!ATTLIST html xmlns:pg CDATA #IMPLIED> +<!ATTLIST html xmlns:pprops CDATA #IMPLIED> +<!ATTLIST html xmlns:pset CDATA #IMPLIED> +<!ATTLIST html xmlns:rsz CDATA #IMPLIED> +<!ATTLIST html xmlns:state CDATA #IMPLIED> +<!ATTLIST html xmlns:time CDATA #IMPLIED> +<!ATTLIST html xmlns:ui CDATA #IMPLIED> +<!ATTLIST html xmlns:umap CDATA #IMPLIED> +<!ATTLIST html xmlns:units CDATA #IMPLIED> +<!ATTLIST html xmlns:urid CDATA #IMPLIED> +<!ATTLIST html xmlns:work CDATA #IMPLIED> diff --git a/lv2specgen/DTD/xhtml-rdfa-model-1.mod b/lv2specgen/DTD/xhtml-rdfa-model-1.mod new file mode 100644 index 0000000..ad010ee --- /dev/null +++ b/lv2specgen/DTD/xhtml-rdfa-model-1.mod @@ -0,0 +1,249 @@ +<!-- ....................................................................... --> +<!-- XHTML+RDFa Document Model Module ..................................... --> +<!-- file: xhtml-rdfa-model-1.mod + + This is XHTML+RDFa. + Copyright 1998-2008 W3C (MIT, ERCIM, Keio), All Rights Reserved. + Revision: $Id: xhtml-rdfa-model-1.mod,v 1.4 2009/06/26 14:05:13 smccarro Exp $ SMI + + This DTD module is identified by the PUBLIC and SYSTEM identifiers: + + PUBLIC "-//W3C//ENTITIES XHTML+RDFa Document Model 1.0//EN" + SYSTEM "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-model-1.mod" + + Revisions: + (none) + ....................................................................... --> + +<!-- XHTML+RDFa Document Model + + This module describes the groupings of elements that make up + common content models for XHTML elements. + + XHTML has three basic content models: + + %Inline.mix; character-level elements + %Block.mix; block-like elements, eg., paragraphs and lists + %Flow.mix; any block or inline elements + + Any parameter entities declared in this module may be used + to create element content models, but the above three are + considered 'global' (insofar as that term applies here). + + The reserved word '#PCDATA' (indicating a text string) is now + included explicitly with each element declaration that is + declared as mixed content, as XML requires that this token + occur first in a content model specification. +--> +<!-- Extending the Model + + While in some cases this module may need to be rewritten to + accommodate changes to the document model, minor extensions + may be accomplished by redeclaring any of the three *.extra; + parameter entities to contain extension element types as follows: + + %Misc.extra; whose parent may be any block or + inline element. + + %Inline.extra; whose parent may be any inline element. + + %Block.extra; whose parent may be any block element. + + If used, these parameter entities must be an OR-separated + list beginning with an OR separator ("|"), eg., "| a | b | c" + + All block and inline *.class parameter entities not part + of the *struct.class classes begin with "| " to allow for + exclusion from mixes. +--> + +<!-- .............. Optional Elements in head .................. --> + +<!ENTITY % HeadOpts.mix + "( %script.qname; | %style.qname; | %meta.qname; + | %link.qname; | %object.qname; )*" +> + +<!-- ................. Miscellaneous Elements .................. --> + +<!-- ins and del are used to denote editing changes +--> +<!ENTITY % Edit.class "| %ins.qname; | %del.qname;" > + +<!-- script and noscript are used to contain scripts + and alternative content +--> +<!ENTITY % Script.class "| %script.qname; | %noscript.qname;" > + +<!ENTITY % Misc.extra "" > + +<!-- These elements are neither block nor inline, and can + essentially be used anywhere in the document body. +--> +<!ENTITY % Misc.class + "%Edit.class; + %Script.class; + %Misc.extra;" +> + +<!-- .................... Inline Elements ...................... --> + +<!ENTITY % InlStruct.class "%br.qname; | %span.qname;" > + +<!ENTITY % InlPhras.class + "| %em.qname; | %strong.qname; | %dfn.qname; | %code.qname; + | %samp.qname; | %kbd.qname; | %var.qname; | %cite.qname; + | %abbr.qname; | %acronym.qname; | %q.qname;" > + +<!ENTITY % InlPres.class + "| %tt.qname; | %i.qname; | %b.qname; | %big.qname; + | %small.qname; | %sub.qname; | %sup.qname;" > + +<!ENTITY % I18n.class "| %bdo.qname;" > + +<!ENTITY % Anchor.class "| %a.qname;" > + +<!ENTITY % InlSpecial.class + "| %img.qname; | %map.qname; + | %object.qname;" > + +<!ENTITY % InlForm.class + "| %input.qname; | %select.qname; | %textarea.qname; + | %label.qname; | %button.qname;" > + +<!ENTITY % Inline.extra "" > + +<!ENTITY % Ruby.class "| %ruby.qname;" > + +<!-- %Inline.class; includes all inline elements, + used as a component in mixes +--> +<!ENTITY % Inline.class + "%InlStruct.class; + %InlPhras.class; + %InlPres.class; + %I18n.class; + %Anchor.class; + %InlSpecial.class; + %InlForm.class; + %Ruby.class; + %Inline.extra;" +> + +<!-- %InlNoRuby.class; includes all inline elements + except ruby, used as a component in mixes +--> +<!ENTITY % InlNoRuby.class + "%InlStruct.class; + %InlPhras.class; + %InlPres.class; + %I18n.class; + %Anchor.class; + %InlSpecial.class; + %InlForm.class; + %Inline.extra;" +> + +<!-- %NoRuby.content; includes all inlines except ruby +--> +<!ENTITY % NoRuby.content + "( #PCDATA + | %InlNoRuby.class; + %Misc.class; )*" +> + +<!-- %InlNoAnchor.class; includes all non-anchor inlines, + used as a component in mixes +--> +<!ENTITY % InlNoAnchor.class + "%InlStruct.class; + %InlPhras.class; + %InlPres.class; + %I18n.class; + %InlSpecial.class; + %InlForm.class; + %Ruby.class; + %Inline.extra;" +> + +<!-- %InlNoAnchor.mix; includes all non-anchor inlines +--> +<!ENTITY % InlNoAnchor.mix + "%InlNoAnchor.class; + %Misc.class;" +> + +<!-- %Inline.mix; includes all inline elements, including %Misc.class; +--> +<!ENTITY % Inline.mix + "%Inline.class; + %Misc.class;" +> + +<!-- ..................... Block Elements ...................... --> + +<!-- In the HTML 4.0 DTD, heading and list elements were included + in the %block; parameter entity. The %Heading.class; and + %List.class; parameter entities must now be included explicitly + on element declarations where desired. +--> + +<!ENTITY % Heading.class + "%h1.qname; | %h2.qname; | %h3.qname; + | %h4.qname; | %h5.qname; | %h6.qname;" > + +<!ENTITY % List.class "%ul.qname; | %ol.qname; | %dl.qname;" > + +<!ENTITY % Table.class "| %table.qname;" > + +<!ENTITY % Form.class "| %form.qname;" > + +<!ENTITY % Fieldset.class "| %fieldset.qname;" > + +<!ENTITY % BlkStruct.class "%p.qname; | %div.qname;" > + +<!ENTITY % BlkPhras.class + "| %pre.qname; | %blockquote.qname; | %address.qname;" > + +<!ENTITY % BlkPres.class "| %hr.qname; " > + +<!ENTITY % BlkSpecial.class + "%Table.class; + %Form.class; + %Fieldset.class;" +> + +<!ENTITY % Block.extra "" > + +<!-- %Block.class; includes all block elements, + used as an component in mixes +--> +<!ENTITY % Block.class + "%BlkStruct.class; + %BlkPhras.class; + %BlkPres.class; + %BlkSpecial.class; + %Block.extra;" +> + +<!-- %Block.mix; includes all block elements plus %Misc.class; +--> +<!ENTITY % Block.mix + "%Heading.class; + | %List.class; + | %Block.class; + %Misc.class;" +> + +<!-- ................ All Content Elements .................. --> + +<!-- %Flow.mix; includes all text content, block and inline +--> +<!ENTITY % Flow.mix + "%Heading.class; + | %List.class; + | %Block.class; + | %Inline.class; + %Misc.class;" +> +<!-- end of xhtml-rdfa-model-1.mod --> diff --git a/lv2specgen/lv2specgen.py b/lv2specgen/lv2specgen.py index 1435f12..75415d4 100755 --- a/lv2specgen/lv2specgen.py +++ b/lv2specgen/lv2specgen.py @@ -59,9 +59,8 @@ except: try: import pygments import pygments.lexers + import pygments.lexers.rdf import pygments.formatters - from pygments.lexer import RegexLexer, include, bygroups - from pygments.token import Text, Comment, Operator, Keyword, Name, String, Literal, Punctuation have_pygments = True except ImportError: print("Error importing pygments, syntax highlighting disabled") @@ -150,8 +149,8 @@ def isLiteral(n): def niceName(uri): global spec_bundle - if uri.startswith(spec_bundle): - return uri[len(spec_bundle):] + if uri.startswith(spec_ns_str): + return uri[len(spec_ns_str):] regexp = re.compile("^(.*[/#])([^/#]+)$") rez = regexp.search(uri) @@ -178,61 +177,6 @@ def getLabel(m, urinode): else: return '' -if have_pygments: - # Based on sw.py by Philip Cooper - class Notation3Lexer(RegexLexer): - """ - Lexer for N3 / Turtle / NT - """ - name = 'N3' - aliases = ['n3', 'turtle'] - filenames = ['*.n3', '*.ttl', '*.nt'] - mimetypes = ['text/rdf+n3','application/x-turtle','application/n3'] - - tokens = { - 'comments': [ - (r'(\s*#.*)', Comment) - ], - 'root': [ - include('comments'), - (r'(\s*@(?:prefix|base|keywords)\s*)(\w*:\s+)?(<[^> ]*>\s*\.\s*)',bygroups(Keyword,Name.Variable,Name.Namespace)), - (r'\s*(<[^>]*\>)', Name.Class, ('triple','predObj')), - (r'(\s*[a-zA-Z_:][a-zA-Z0-9\-_:]*\s)', Name.Class, ('triple','predObj')), - (r'\s*\[\]\s*', Name.Class, ('triple','predObj')), - ], - 'triple' : [ - (r'\s*\.\s*', Text, '#pop') - ], - 'predObj': [ - include('comments'), - (r'\s*a\s*', Name.Keyword, 'object'), - (r'\s*[a-zA-Z_:][a-zA-Z0-9\-_:]*\b\s*', Name.Tag, 'object'), - (r'\s*(<[^>]*\>)', Name.Tag, 'object'), - (r'\s*\]\s*', Text, '#pop'), - (r'(?=\s*\.\s*)', Keyword, '#pop'), - ], - 'objList': [ - include('comments'), - (r'\s*\)', Text, '#pop'), - include('object') - ], - 'object': [ - include('comments'), - (r'\s*\[', Text, 'predObj'), - (r'\s*<[^> ]*>', Name.Tag), - (r'\s*("""(?:.|\n)*?""")(\@[a-z]{2-4}|\^\^<?[a-zA-Z0-9\-\:_#/\.]*>?)?\s*', bygroups(Literal.String,Text)), - (r'\s*".*?[^\\]"(?:\@[a-z]{2-4}|\^\^<?[a-zA-Z0-9\-\:_#/\.]*>?)?\s*', Literal.String), - (r'\s*[0-9]+\.[0-9]*\s*\n?', Literal.Number), - (r'\s*[0-9]+\s*\n?', Literal.Number), - (r'\s*[a-zA-Z0-9\-_\:]+\s*', Name.Tag), - (r'\s*\(', Text, 'objList'), - (r'\s*;\s*\n?', Punctuation, '#pop'), - (r'\s*,\s*\n?', Punctuation), # Added by drobilla so "," is not an error - (r'(?=\s*\])', Text, '#pop'), - (r'(?=\s*\.)', Text, '#pop'), - ], - } - def linkify(string): if linkmap == {}: return string @@ -280,7 +224,7 @@ def getComment(m, urinode, classlist, proplist, instalist): match_str = xml.sax.saxutils.unescape(code.group(1)) code_str = pygments.highlight( match_str, - Notation3Lexer(), + pygments.lexers.rdf.TurtleLexer(), pygments.formatters.HtmlFormatter()) markup = code_rgx.sub(code_str, markup, 1) @@ -326,7 +270,9 @@ def getComment(m, urinode, classlist, proplist, instalist): return text markup = rgx.sub(translateLocalLink, markup) - if have_lxml: + if not have_lxml: + print("warning: No Python lxml module found, output may be invalid") + else: try: # Parse and validate documentation as XHTML Basic 1.1 doc = """<?xml version="1.0" encoding="UTF-8"?> @@ -337,22 +283,22 @@ def getComment(m, urinode, classlist, proplist, instalist): <title>Validation Skeleton Document</title> </head> <body> -%s +""" + markup + """ </body> -</html> -""" % str(markup.decode()) +</html>""" oldcwd = os.getcwd() os.chdir(specgendir) parser = etree.XMLParser(dtd_validation=True, no_network=True) - root = etree.fromstring(doc, parser) - os.chdir(oldcwd) + root = etree.fromstring(doc.encode('utf-8'), parser) except Exception as e: print("Invalid lv2:documentation for %s\n%s" % (urinode, e)) line_num = 1 for line in doc.split('\n'): print('%3d: %s' % (line_num, line)) line_num += 1 + finally: + os.chdir(oldcwd) return markup @@ -368,7 +314,7 @@ def getProperty(val, first=True): "Return a string representing a property value in a property table" doc = '' if not first: - doc += '<tr><td></td>' # Empty cell in header column + doc += '<tr><th></th>' # Empty cell in header column doc += '<td>%s</td></tr>\n' % val return doc @@ -464,31 +410,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: - superclasses.sort() - doc += "\n<tr><th>Sub-class of</th>" - first = True - for superclass in 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) @@ -500,46 +429,56 @@ 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), "") if d: - d.sort() dlist = '' first = True - for k in d: + for k in sorted(d): dlist += getProperty(getTermLink(k), first) first = False doc += "<tr><th>In domain of</th>%s" % dlist @@ -547,10 +486,9 @@ def rdfsClassInfo(term, m): # Find out about properties which have rdfs:range of t r = classranges.get(str(term), "") if r: - r.sort() rlist = '' first = True - for k in r: + for k in sorted(r): rlist += getProperty(getTermLink(k), first) first = False doc += "<tr><th>In range of</th>%s" % rlist @@ -560,7 +498,7 @@ def rdfsClassInfo(term, m): def isSpecial(pred): """Return True if the predicate is "special" and shouldn't be emitted generically""" - return pred in [rdf.type, rdfs.range, rdfs.domain, rdfs.label, rdfs.comment, rdfs.subClassOf, rdfs.subPropertyOf, lv2.documentation] + return pred in [rdf.type, rdfs.range, rdfs.domain, rdfs.label, rdfs.comment, rdfs.subClassOf, rdfs.subPropertyOf, lv2.documentation, owl.withRestrictions] def blankNodeDesc(node, m): @@ -645,7 +583,7 @@ def owlInfo(term, m): def owlTypeInfo(term, propertyType, name): if findOne(m, term, rdf.type, propertyType): - return "<tr><th>OWL Type</th><td>%s</td></tr>\n" % name + return "<tr><th>Type</th><td>%s</td></tr>\n" % name else: return "" @@ -665,56 +603,34 @@ def docTerms(category, list, m, classlist, proplist, instalist): """ A wrapper class for listing all the terms in a specific class (either Properties, or Classes. Category is 'Property' or 'Class', list is a - list of term names (strings), return value is a chunk of HTML. + list of term URI strings, return value is a chunk of HTML. """ doc = "" nspre = spec_pre - for item in list: - t = termName(m, item) - if (t.startswith(spec_ns_str)) and ( - len(t[len(spec_ns_str):].split("/")) < 2): - term = t - t = t.split(spec_ns_str[-1])[1] - curie = "%s:%s" % (nspre, t) - else: - if t.startswith("http://"): - term = t - curie = getShortName(t) - t = getAnchor(t) - else: - term = spec_ns[t] - curie = "%s:%s" % (nspre, t) - - term_uri = term + for term in list: + if not term.startswith(spec_ns_str): + sys.stderr.write("warning: Skipping external term `%s'" % term) + continue - doc += """<div class="specterm" id="%s" about="%s">\n<h3>%s <a href="#%s">%s</a></h3>\n""" % (t, term_uri, category, getAnchor(str(term_uri)), curie) + t = termName(m, term) + curie = term.split(spec_ns_str[-1])[1] + doc += '<div class="specterm" id="%s" about="%s">' % (t, term) + doc += '<h4><a href="#%s">%s</a></h4>' % (getAnchor(term), curie) label = getLabel(m, term) comment = getComment(m, term, 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) @@ -723,6 +639,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" @@ -745,12 +678,12 @@ def getAnchor(uri): return getShortName(uri) -def buildIndex(m, classlist, proplist, instalist=None, filelist=None): - if not (classlist or proplist or instalist or filelist): +def buildIndex(m, classlist, proplist, instalist=None): + if not (classlist or proplist or instalist): return '' - head = '<tr>' - body = '<tr>' + head = '' + body = '' def termLink(m, t): if str(t).startswith(spec_ns_str): @@ -760,11 +693,10 @@ def buildIndex(m, classlist, proplist, instalist=None, filelist=None): return '<a href="%s">%s</a>' % (str(t), str(t)) if (len(classlist) > 0): - head += '<th>Classes</th>' + head += '<th><a href="#ref-classes" />Classes</th>' body += '<td><ul>' - classlist.sort() shown = {} - for c in classlist: + for c in sorted(classlist): if c in shown: continue @@ -786,9 +718,8 @@ def buildIndex(m, classlist, proplist, instalist=None, filelist=None): subclasses = [] for s in findStatements(m, None, rdfs.subClassOf, c): subclasses += [getSubject(s)] - subclasses.sort() - for s in subclasses: + for s in sorted(subclasses): tree += '<li>' + termLink(m, s) tree += class_tree(s) tree += '</li>' @@ -800,37 +731,28 @@ def buildIndex(m, classlist, proplist, instalist=None, filelist=None): body += '</ul></td>\n' if (len(proplist) > 0): - head += '<th>Properties</th>' + head += '<th><a href="#ref-properties" />Properties</th>' body += '<td><ul>' - proplist.sort() - for p in proplist: + for p in sorted(proplist): body += '<li>%s</li>' % termLink(m, p) body += '</ul></td>\n' if (instalist is not None and len(instalist) > 0): - head += '<th>Instances</th>' + head += '<th><a href="#ref-instances" />Instances</th>' body += '<td><ul>' - instalist.sort() - for i in instalist: + for i in sorted(instalist): p = getShortName(i) anchor = getAnchor(i) body += '<li><a href="#%s">%s</a></li>' % (anchor, p) body += '</ul></td>\n' - if (filelist is not None and len(filelist) > 0): - head += '<th>Files</th>' - body += '<td><ul>' - filelist.sort() - for i in filelist: - p = getShortName(i) - anchor = getAnchor(i) - body += '<li><a href="%s">%s</a></li>' % (i, os.path.basename(i)) - body += '</ul></td>\n' - - head += '</tr>' - body += '</tr>' - return '<table class="index"><thead>%s</thead>\n<tbody>%s</tbody></table>' % (head, body) + if head and body: + return '''<table class="index"> +<thead><tr>%s</tr></thead> +<tbody><tr>%s</tr></tbody></table> +''' % (head, body) + return '' def add(where, key, value): if not key in where: @@ -919,7 +841,7 @@ def specAuthors(m, subject): devdoc = '' first = True - for d in dev: + for d in sorted(dev): if not first: devdoc += ', ' devdoc += '<span class="author" property="doap:developer">%s</span>' % d @@ -931,7 +853,7 @@ def specAuthors(m, subject): maintdoc = '' first = True - for m in maint: + for m in sorted(maint): if not first: maintdoc += ', ' maintdoc += '<span class="author" property="doap:maintainer">%s</span>' % m @@ -1164,19 +1086,19 @@ def writeIndex(model, specloc, index_path, root_path, root_uri): # Find relative link target if root_uri and ext_node.startswith(root_uri): - target = ext_node[len(root_uri):] + target = ext_node[len(root_uri):] + '.html' else: - target = os.path.relpath(ext_node, root_path) + target = os.path.relpath(ext_node, root_path) + '.html' + + stem = os.path.splitext(os.path.basename(target))[0] # Specification (comment is to act as a sort key) - if not options.online_docs: - target += '/%s.html' % b row = '<tr><!-- %s --><td><a rel="rdfs:seeAlso" href="%s">%s</a></td>' % ( b, target, name) # API row += '<td><a rel="rdfs:seeAlso" href="../doc/html/group__%s.html">%s</a></td>' % ( - b, b) + stem, name) # Description if shortdesc: @@ -1202,7 +1124,6 @@ def writeIndex(model, specloc, index_path, root_path, root_uri): row += '</tr>' - # index = open(os.path.join(out, 'index_rows', b), 'w') index = open(index_path, 'w') index.write(row) index.close() @@ -1295,27 +1216,21 @@ def specgen(specloc, indir, style_uri, docdir, tags, opts, instances=False, root instalist = sorted(getInstances(m, classlist, proplist), key=lambda x: getShortName(x).lower()) - filelist = [] - see_also_files = specProperties(m, spec, rdfs.seeAlso) - see_also_files.sort() - for f in see_also_files: - uri = str(f) - if uri[:7] == 'file://': - uri = uri[7:] - if uri[:len(abs_bundle_path)] == abs_bundle_path: - uri = uri[len(abs_bundle_path) + 1:] - else: - continue # Skip seeAlso file outside bundle - - filelist += [uri] - - azlist = buildIndex(m, classlist, proplist, instalist, filelist) + azlist = buildIndex(m, classlist, proplist, instalist) # Generate Term HTML - termlist = docTerms('Property', proplist, m, classlist, proplist, instalist) - termlist = docTerms('Class', classlist, m, classlist, proplist, instalist) + termlist + classlist = docTerms('Class', classlist, m, classlist, proplist, instalist) + proplist = docTerms('Property', proplist, m, classlist, proplist, instalist) if instances: - termlist += docTerms('Instance', instalist, m, classlist, proplist, instalist) + instlist = docTerms('Instance', instalist, m, classlist, proplist, instalist) + + termlist = '' + if classlist: + termlist += '<h3><a id="ref-classes" />Classes</h3>' + classlist + if proplist: + termlist += '<h3><a id="ref-properties" />Properties</h3>' + proplist + if instlist: + termlist += '<h3><a id="ref-instances" />Instances</h3>' + instlist name = specProperty(m, spec, doap.name) title = name @@ -1390,6 +1305,19 @@ def specgen(specloc, indir, style_uri, docdir, tags, opts, instances=False, root if index_path is not None: writeIndex(m, specloc, index_path, root_path, root_uri) + # Validate complete output page + try: + oldcwd = os.getcwd() + os.chdir(specgendir) + root = etree.fromstring( + template.replace('"http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd"', + '"DTD/xhtml-rdfa-1.dtd"').encode('utf-8'), + etree.XMLParser(dtd_validation=True, no_network=True)) + except Exception as e: + sys.stderr.write("error: Validation failed for %s: %s" % (specloc, e)) + finally: + os.chdir(oldcwd) + return template @@ -1466,8 +1394,6 @@ if __name__ == "__main__": help='Document instances') opt.add_option('--copy-style', action='store_true', dest='copy_style', help='Copy style from template directory to output directory') - opt.add_option('--online', action='store_true', dest='online_docs', - help='Generate online documentation') (options, args) = opt.parse_args() opts = vars(options) @@ -1498,9 +1424,7 @@ if __name__ == "__main__": # Root link root_path = opts['root_path'] root_uri = opts['root_uri'] - root_link = os.path.relpath(root_path, path) if root_path else '.' - if not options.online_docs: - root_link = os.path.join(root_link, 'index.html') + root_link = os.path.join(root_path, 'index.html') # Generate spec documentation specdoc = specgen( diff --git a/lv2specgen/template.html b/lv2specgen/template.html index 5056aef..6170882 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 lv2specgen + </div> + </div> + </div> </body> </html> |