public static void writeAssets() { JarFile thisJar = JarUtils.jarForClass(Doclava.class, null); if (thisJar != null) { try { List<String> templateDirs = ClearPage.getBundledTemplateDirs(); for (String templateDir : templateDirs) { String assetsDir = ensureSlash(templateDir) + "assets"; JarUtils.copyResourcesToDirectory( thisJar, assetsDir, ensureSlash(ClearPage.outputDir) + assetsOutputDir); } // write mule-developer-core.css Data data = makeHDF(); ClearPage.write( data, "mule-developer-core.cs", assetsOutputDir + "/mule-developer-core.css"); } catch (IOException e) { System.err.println("Error copying assets directory."); e.printStackTrace(); return; } } List<String> templateDirs = ClearPage.getTemplateDirs(); for (String templateDir : templateDirs) { File assets = new File(ensureSlash(templateDir) + "assets"); if (assets.isDirectory()) { writeDirectory(null, assets, assetsOutputDir, null, ""); } } }
public static boolean start(RootDoc r) { String keepListFile = null; String proofreadFile = null; String todoFile = null; String stubsDir = null; // Create the dependency graph for the stubs directory String apiFile = null; HashSet<String> stubPackages = null; ArrayList<String> knownTagsFiles = new ArrayList<String>(); root = r; String[][] options = r.options(); for (String[] a : options) { if (a[0].equals("-d")) { ClearPage.outputDir = a[1]; } else if (a[0].equals("-templatedir")) { ClearPage.addTemplateDir(a[1]); } else if (a[0].equals("-hdf")) { mHDFData.add(new String[] {a[1], a[2]}); } else if (a[0].equals("-markdown")) { mMarkdown.add(new String[] {a[1], a[2], a[3]}); } else if (a[0].equals("-knowntags")) { knownTagsFiles.add(a[1]); } else if (a[0].equals("-toroot")) { ClearPage.toroot = a[1]; } else if (a[0].equals("-title")) { Doclava.title = a[1]; } else if (a[0].equals("-werror")) { Errors.setWarningsAreErrors(true); } else if (a[0].equals("-error") || a[0].equals("-warning") || a[0].equals("-hide")) { try { int level = -1; if (a[0].equals("-error")) { level = Errors.ERROR; } else if (a[0].equals("-warning")) { level = Errors.WARNING; } else if (a[0].equals("-hide")) { level = Errors.HIDDEN; } Errors.setErrorLevel(Integer.parseInt(a[1]), level); } catch (NumberFormatException e) { // already printed below return false; } } else if (a[0].equals("-keeplist")) { keepListFile = a[1]; } else if (a[0].equals("-proofread")) { proofreadFile = a[1]; } else if (a[0].equals("-todo")) { todoFile = a[1]; } else if (a[0].equals("-public")) { showLevel = SHOW_PUBLIC; } else if (a[0].equals("-protected")) { showLevel = SHOW_PROTECTED; } else if (a[0].equals("-package")) { showLevel = SHOW_PACKAGE; } else if (a[0].equals("-private")) { showLevel = SHOW_PRIVATE; } else if (a[0].equals("-hidden")) { showLevel = SHOW_HIDDEN; } else if (a[0].equals("-stubs")) { stubsDir = a[1]; } else if (a[0].equals("-stubpackages")) { stubPackages = new HashSet<String>(); for (String pkg : a[1].split(":")) { stubPackages.add(pkg); } } else if (a[0].equals("-apixml")) { apiFile = a[1]; } else if (a[0].equals("-nodocs")) { generateDocs = false; } else if (a[0].equals("-parsecomments")) { parseComments = true; } else if (a[0].equals("-since")) { sinceTagger.addVersion(a[1], a[2]); } else if (a[0].equals("-federate")) { try { String name = a[1]; URL federationURL = new URL(a[2]); federationTagger.addSiteUrl(name, federationURL); } catch (MalformedURLException e) { System.err.println("Could not parse URL for federation: " + a[1]); return false; } } else if (a[0].equals("-federationxml")) { String name = a[1]; String file = a[2]; federationTagger.addSiteXml(name, file); } else if (a[0].equals("-apiversion")) { apiVersion = a[1]; } else if (a[0].equals("-assetsdir")) { assetsOutputDir = a[1]; } else if (a[0].equals("-generatesources")) { generateSources = true; } } if (!readKnownTagsFiles(knownTags, knownTagsFiles)) { return false; } // Set up the data structures Converter.makeInfo(r); // Stubs and xml final File currentApiFile; if (!generateDocs && apiFile != null) { currentApiFile = new File(apiFile); } else if (generateDocs) { currentApiFile = new File(ensureSlash(ClearPage.outputDir) + javadocDir + FederatedSite.XML_API_PATH); } else { currentApiFile = null; } Stubs.writeStubsAndXml(stubsDir, currentApiFile, stubPackages); if (generateDocs && apiFile != null) { ClearPage.copyFile(currentApiFile, new File(apiFile)); } // Reference documentation if (generateDocs) { ClearPage.addBundledTemplateDir("assets/customizations"); ClearPage.addBundledTemplateDir("assets/templates"); List<ResourceLoader> resourceLoaders = new ArrayList<ResourceLoader>(); List<String> templates = ClearPage.getTemplateDirs(); for (String tmpl : templates) { resourceLoaders.add(new FileSystemResourceLoader(tmpl)); } templates = ClearPage.getBundledTemplateDirs(); for (String tmpl : templates) { resourceLoaders.add(new ClassResourceLoader(Doclava.class, '/' + tmpl)); } ResourceLoader compositeResourceLoader = new CompositeResourceLoader(resourceLoaders); jSilver = new JSilver(compositeResourceLoader); if (!Doclava.readTemplateSettings()) { return false; } long startTime = System.nanoTime(); // Use current version information if (apiVersion != null && sinceTagger.hasVersions()) { sinceTagger.addVersion(currentApiFile.getAbsolutePath(), apiVersion); } // Apply @since tags from the XML file sinceTagger.tagAll(Converter.rootClasses()); // Apply details of federated documentation federationTagger.tagAll(Converter.rootClasses()); // Files for proofreading if (proofreadFile != null) { Proofread.initProofread(proofreadFile); } if (todoFile != null) { TodoFile.writeTodoFile(todoFile); } writeAssets(); // Navigation tree NavTree.writeNavTree(assetsOutputDir); // Write Markdown files writeMarkdowns(); // Mule writeModules(muleXmlDir + "modules" + htmlExtension); // Packages Pages writePackages(javadocDir + "packages" + htmlExtension); // Classes writeClassLists(); writeClasses(); writeHierarchy(); // writeKeywords(); // Lists for JavaScript writeLists(); if (keepListFile != null) { writeKeepList(keepListFile); } // Index page writeIndex(); // Installation page writeInstall(); Proofread.finishProofread(proofreadFile); long time = System.nanoTime() - startTime; System.out.println( "Mule DevKit took " + (time / 1000000000) + " sec. to write docs to " + ClearPage.outputDir); } Errors.printErrors(); return !Errors.hadError; }