"childCount" : len(nodeType["layout"]) } meths = mapByCategory(nodeTypes, { "family" : createFamilyMethod, "terminal" : createTerminalMethod, "tree" : createTreeMethod }) content = templates.toyParserFile % "\n\n\t".join(meths) write( content, toyParserOutputPath ) def createExecutor(nodeTypes) : def createCase(typename) : return templates.executorCase % nodeTypes[typename] cases = map(createCase, nodeTypes["expression"]["members"]) content = templates.executorFile % "\n\t\t\t".join(cases) write( content, executorOutputPath ) #----- entry point nodeTypes = getNodeTypesDict() setupNodeTypes(nodeTypes) lib.each( lambda x: x(nodeTypes), [ createNodeClasses, createDesibleParserMethods, createDesibleSerializerMethods, createIvanGrammar, createIvanParser, createToyParser, createExecutor ])
htmlDocument = createHtmlDocument(docbookDocument) #note: Python's DOM implementation refuses to output a DTD #note: Python's DOM implementation only outputs an @xmlns when the attribute is explicitly added lib.writeXmlDocument(htmlDocument, xhtmlOutputPath) #create HTML document from XHTML document #xxx tidy refuses to output HTML #note: wrapping will wrap text in <code> elements, so it's disabled #note: tidy adds newlines to <code> elements, which show up as gaps subprocess.call([ "tidy", "--quiet", "yes", "--output-file", htmlOutputPath, "--char-encoding", "utf8", "--input-xml", "yes", "--output-html", "yes", "--doctype", "strict", "--indent", "auto", "--indent-spaces", "4", "--wrap", "0", xhtmlOutputPath ]) print "done\n" #entry point result = subprocess.call(['python', 'process docbook.py']) if result != 0 : exit(1) lib.each(createHtmlFile, fileBases)