public void endElement(String uri, String localName, String qName) throws SAXException { if ("tag".equals(qName)) { if (tagInfo != null) { tagInfoMap.put(tagInfo.getName(), tagInfo); if (generateCode) { System.out.println("this.put(\"" + tagInfo.getName() + "\", tagInfo);\n"); } } tagInfo = null; } else if (!"tags".equals(qName)) { dependencyName = null; } }
public void characters(char[] ch, int start, int length) throws SAXException { if (tagInfo != null) { String value = new String(ch, start, length).trim(); if ("fatal-tags".equals(dependencyName)) { tagInfo.defineFatalTags(value); if (generateCode) { System.out.println("tagInfo.defineFatalTags(\"" + value + "\");"); } } else if ("req-enclosing-tags".equals(dependencyName)) { tagInfo.defineRequiredEnclosingTags(value); if (generateCode) { System.out.println("tagInfo.defineRequiredEnclosingTags(\"" + value + "\");"); } } else if ("forbidden-tags".equals(dependencyName)) { tagInfo.defineForbiddenTags(value); if (generateCode) { System.out.println("tagInfo.defineForbiddenTags(\"" + value + "\");"); } } else if ("allowed-children-tags".equals(dependencyName)) { tagInfo.defineAllowedChildrenTags(value); if (generateCode) { System.out.println("tagInfo.defineAllowedChildrenTags(\"" + value + "\");"); } } else if ("higher-level-tags".equals(dependencyName)) { tagInfo.defineHigherLevelTags(value); if (generateCode) { System.out.println("tagInfo.defineHigherLevelTags(\"" + value + "\");"); } } else if ("close-before-copy-inside-tags".equals(dependencyName)) { tagInfo.defineCloseBeforeCopyInsideTags(value); if (generateCode) { System.out.println("tagInfo.defineCloseBeforeCopyInsideTags(\"" + value + "\");"); } } else if ("close-inside-copy-after-tags".equals(dependencyName)) { tagInfo.defineCloseInsideCopyAfterTags(value); if (generateCode) { System.out.println("tagInfo.defineCloseInsideCopyAfterTags(\"" + value + "\");"); } } else if ("close-before-tags".equals(dependencyName)) { tagInfo.defineCloseBeforeTags(value); if (generateCode) { System.out.println("tagInfo.defineCloseBeforeTags(\"" + value + "\");"); } } } }
public static void writePage(String docfile, String relative, String outfile) { HDF hdf = DroidDoc.makeHDF(); /* System.out.println("docfile='" + docfile + "' relative='" + relative + "'" + "' outfile='" + outfile + "'"); */ String filedata = readFile(docfile); // The document is properties up until the line "@jd:body". // Any blank lines are ignored. int start = -1; int lineno = 1; Matcher lines = LINE.matcher(filedata); String line = null; while (lines.find()) { line = lines.group(1); if (line.length() > 0) { if (line.equals("@jd:body")) { start = lines.end(); break; } Matcher prop = PROP.matcher(line); if (prop.matches()) { String key = prop.group(1); String value = prop.group(2); hdf.setValue(key, value); } else { break; } } lineno++; } if (start < 0) { System.err.println(docfile + ":" + lineno + ": error parsing docfile"); if (line != null) { System.err.println(docfile + ":" + lineno + ":" + line); } System.exit(1); } // if they asked to only be for a certain template, maybe skip it String fromTemplate = hdf.getValue("template.which", ""); String fromPage = hdf.getValue("page.onlyfortemplate", ""); if (!"".equals(fromPage) && !fromTemplate.equals(fromPage)) { return; } // and the actual text after that String commentText = filedata.substring(start); Comment comment = new Comment(commentText, null, new SourcePositionInfo(docfile, lineno, 1)); TagInfo[] tags = comment.tags(); TagInfo.makeHDF(hdf, "root.descr", tags); hdf.setValue("commentText", commentText); // write the page using the appropriate root template, based on the // whichdoc value supplied by build String fromWhichmodule = hdf.getValue("android.whichmodule", ""); if (fromWhichmodule.equals("online-pdk")) { // leaving this in just for temporary compatibility with pdk doc hdf.setValue("online-pdk", "true"); // add any conditional login for root template here (such as // for custom left nav based on tab etc. ClearPage.write(hdf, "docpage.cs", outfile); } else { if (outfile.indexOf("sdk/") != -1) { hdf.setValue("sdk", "true"); if ((outfile.indexOf("index.html") != -1) || (outfile.indexOf("features.html") != -1)) { ClearPage.write(hdf, "sdkpage.cs", outfile); } else { ClearPage.write(hdf, "docpage.cs", outfile); } } else if (outfile.indexOf("guide/") != -1) { hdf.setValue("guide", "true"); ClearPage.write(hdf, "docpage.cs", outfile); } else if (outfile.indexOf("resources/") != -1) { hdf.setValue("resources", "true"); ClearPage.write(hdf, "docpage.cs", outfile); } else { ClearPage.write(hdf, "nosidenavpage.cs", outfile); } } } // writePage