in tutorials-convert/src/main/java/org/netbeans/tools/tutorials/HTMLConverter.java [222:298]
public static void main(String[] args) throws Exception {
if (args.length != 1) {
usage();
}
File cloneDirectory = new File(args[0]);
checkDirectoryExists("Incorrect clone directory ", cloneDirectory);
File srcContent = new File(new File(cloneDirectory, "src"), "content");
checkDirectoryExists("Incorrect clone/src/content directory ", srcContent);
File platform = new File(srcContent, "platform");
checkDirectoryExists("Incorrect clone/src/content/platform directory ", platform);
File platformTutorials = new File(platform, "tutorials");
checkDirectoryExists("Incorrect clone/src/content/platform/tutorials directory ", platformTutorials);
File platformImages = new File(platform, "images");
checkDirectoryExists("Incorrect clone/src/content/platform/images directory ", platformImages);
File platformGraph = new File(platform, "graph");
checkDirectoryExists("Incorrect clone/src/content/platform/graph directory ", platformGraph);
File currentDirectory = new File(System.getProperty("user.dir"));
File dest = new File(currentDirectory, "tutorials-asciidoc");
if (!dest.exists()) {
if (!dest.mkdirs()) {
throw new IllegalStateException("Cannot create directory " + dest.getAbsolutePath());
}
}
File destTutorials = new File(dest, "tutorials");
if (!destTutorials.exists()) {
if (!destTutorials.mkdirs()) {
throw new IllegalStateException("Cannot create directory " + destTutorials.getAbsolutePath());
}
}
File destGraph = new File(dest, "graph");
if (!destGraph.exists()) {
if (!destGraph.mkdirs()) {
throw new IllegalStateException("Cannot create directory " + destGraph.getAbsolutePath());
}
}
ExternalLinksMap externalLinks = new ExternalLinksMap();
convert(platformTutorials, platformImages, destTutorials, externalLinks);
convert(platformGraph, platformGraph, destGraph, externalLinks);
// convertTrails(cloneDirectory, docsTutorialsImagesDirectory, dest, externalLinks);
LOG.info("Generating 'external-links.txt' with list of external links...");
try ( PrintWriter ef = new PrintWriter(new FileWriter("external-links.yml"))) {
for (String domain : externalLinks.getDomains()) {
ef.format("- domain: \"%s\"%n", domain);
ef.format(" links:%n");
for (String href : externalLinks.getHrefs(domain)) {
ef.format(" link: \"%s\"%n", href);
ef.format(" used-at:%n");
for (String tutorial : externalLinks.getTutorials(href)) {
ef.format(" - \"%s\"%n", tutorial);
}
}
}
}
/* Remove a hand-made "content" section, that is not replaced by the asciidoc 'toc' stuff */
Map<File, String> titles = AsciidocPostProcessor.removeContentSetcion(dest);
/* Generate some "index.asciidoc" files with the list of tutorials on each directory. */
AsciidocPostProcessor.generateIndexes(dest, titles);
}