diff options
author | David Robillard <d@drobilla.net> | 2011-11-14 01:23:22 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2011-11-14 01:23:22 +0000 |
commit | db32487a23a07dcf62686480aa8642c4795f3787 (patch) | |
tree | be0af6d7a0b7bc7984520551f01ebfceba7fa761 /lv2specgen | |
parent | 708a01ffb58ed30bb813fbfedca19d16d33ac887 (diff) | |
download | lv2-db32487a23a07dcf62686480aa8642c4795f3787.tar.xz |
Make all lv2:documentation valid XHTML Basic 1.1.
Validate lv2:documentation in lv2specgen (if lxml is available).
Diffstat (limited to 'lv2specgen')
-rwxr-xr-x | lv2specgen/lv2specgen.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/lv2specgen/lv2specgen.py b/lv2specgen/lv2specgen.py index 428a6ef..5c62701 100755 --- a/lv2specgen/lv2specgen.py +++ b/lv2specgen/lv2specgen.py @@ -47,6 +47,12 @@ import sys import xml.sax.saxutils try: + from lxml import etree + have_lxml = True +except: + have_lxml = False + +try: import pygments import pygments.lexers import pygments.formatters @@ -70,6 +76,7 @@ spec_url = None spec_ns_str = None spec_ns = None spec_pre = None +specgendir = None ns_list = { "http://www.w3.org/1999/02/22-rdf-syntax-ns#" : "rdf", "http://www.w3.org/2000/01/rdf-schema#" : "rdfs", @@ -230,6 +237,29 @@ def getComment(m, urinode, classlist): c = findOne(m, urinode, lv2.documentation, None) if c: markup = getLiteralString(getObject(c)) + if have_lxml: + try: + # Parse and validate documentation as XHTML Basic 1.1 + doc = """<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN" + "DTD/xhtml-basic11.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> + <head xml:lang="en" profile="profile"> + <title>Validation Skeleton Document</title> + </head> + <body> +%s + </body> +</html> +""" % str(markup.decode()) + + oldcwd = os.getcwd() + os.chdir(specgendir) + parser = etree.XMLParser(dtd_validation=True, no_network=True) + root = etree.fromstring(doc, parser) + os.chdir(oldcwd) + except Exception as e: + print("Invalid lv2:documentation for %s\n%s" % (urinode, e)) # Syntax highlight all C code if have_pygments: @@ -894,6 +924,9 @@ def specgen(specloc, indir, docdir, style_uri, doc_base, doclinks, instances=Fal global spec_ns global spec_pre global ns_list + global specgendir + + specgendir = os.path.abspath(indir) # Template temploc = os.path.join(indir, "template.html") |