X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.scl.compiler%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Fmarkdown%2Fhtml%2FGenerateAllHtmlDocumentation.java;fp=bundles%2Forg.simantics.scl.compiler%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Fmarkdown%2Fhtml%2FGenerateAllHtmlDocumentation.java;h=fe038b1e34312500dc43f4077cf45c5aa1fa97cb;hp=350c655edbbaca85de3687c54070a92594615ad7;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hpb=24e2b34260f219f0d1644ca7a138894980e25b14 diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/markdown/html/GenerateAllHtmlDocumentation.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/markdown/html/GenerateAllHtmlDocumentation.java index 350c655ed..fe038b1e3 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/markdown/html/GenerateAllHtmlDocumentation.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/markdown/html/GenerateAllHtmlDocumentation.java @@ -1,87 +1,87 @@ -package org.simantics.scl.compiler.markdown.html; - -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.List; - -import org.simantics.scl.compiler.module.repository.ModuleRepository; - -public class GenerateAllHtmlDocumentation { - public static void generate(ModuleRepository moduleRepository, Path directory) throws IOException { - HierarchicalDocumentationRef root = HierarchicalDocumentationRef.generateTree(moduleRepository.getSourceRepository()); - generate(moduleRepository, directory, root.getChildren(), 0, root); - generateIndex(directory, 0, "StandardLibrary/Prelude.html"); - } - - private static void generateIndex(Path directory, int level, String url) throws IOException { - Path documentationFile = directory.resolve("index.html"); - for(int i=0;i" + - "" + - "If you are not redirected automatically, follow the link."; - Files.write(documentationFile, content.getBytes()); - } - - private static void generate(ModuleRepository moduleRepository, Path directory, List refs, int level, HierarchicalDocumentationRef root) throws IOException { - String navigation = generateNavigation(level, root); - for(HierarchicalDocumentationRef ref : refs) { - String name = ref.getName(); - - // Documentation for this ref - String documentationName = ref.getDocumentationName(); - if(documentationName != null) { - String documentation = HtmlDocumentationGeneration.generate(moduleRepository, documentationName, navigation); - Path documentationFile = directory.resolve(name + ".html"); - Files.write(documentationFile, documentation.getBytes()); - } - - // Children of the ref - List children = ref.getChildren(); - if(!children.isEmpty()) { - Path childDirectory = directory.resolve(name); - if(!Files.exists(childDirectory)) - Files.createDirectory(childDirectory); - generate(moduleRepository, childDirectory, children, level+1, root); - if(documentationName != null) - generateIndex(childDirectory, 1, ref.getName() + ".html"); - else - generateIndex(childDirectory, level+1, "StandardLibrary/Prelude.html"); - } - } - } - - private static String generateNavigation(int level, - HierarchicalDocumentationRef root) { - StringBuilder b = new StringBuilder(); - generateNavigation(b, level, root.getChildren()); - return b.toString(); - } - - private static void generateNavigation(StringBuilder b, int level, - List refs) { - b.append("
    "); - for(HierarchicalDocumentationRef ref : refs) { - b.append("
  • "); - String documentationName = ref.getDocumentationName(); - if(documentationName != null) { - if(!documentationName.contains("/")) - documentationName = "StandardLibrary/" + documentationName; - b.append(""); - } - b.append(ref.getName()); - if(documentationName != null) - b.append(""); - List children = ref.getChildren(); - if(children != null) - generateNavigation(b, level, children); - b.append("
  • "); - } - b.append("
"); - } -} +package org.simantics.scl.compiler.markdown.html; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.List; + +import org.simantics.scl.compiler.module.repository.ModuleRepository; + +public class GenerateAllHtmlDocumentation { + public static void generate(ModuleRepository moduleRepository, Path directory) throws IOException { + HierarchicalDocumentationRef root = HierarchicalDocumentationRef.generateTree(moduleRepository.getSourceRepository()); + generate(moduleRepository, directory, root.getChildren(), 0, root); + generateIndex(directory, 0, "StandardLibrary/Prelude.html"); + } + + private static void generateIndex(Path directory, int level, String url) throws IOException { + Path documentationFile = directory.resolve("index.html"); + for(int i=0;i" + + "" + + "If you are not redirected automatically, follow the link."; + Files.write(documentationFile, content.getBytes()); + } + + private static void generate(ModuleRepository moduleRepository, Path directory, List refs, int level, HierarchicalDocumentationRef root) throws IOException { + String navigation = generateNavigation(level, root); + for(HierarchicalDocumentationRef ref : refs) { + String name = ref.getName(); + + // Documentation for this ref + String documentationName = ref.getDocumentationName(); + if(documentationName != null) { + String documentation = HtmlDocumentationGeneration.generate(moduleRepository, documentationName, navigation); + Path documentationFile = directory.resolve(name + ".html"); + Files.write(documentationFile, documentation.getBytes()); + } + + // Children of the ref + List children = ref.getChildren(); + if(!children.isEmpty()) { + Path childDirectory = directory.resolve(name); + if(!Files.exists(childDirectory)) + Files.createDirectory(childDirectory); + generate(moduleRepository, childDirectory, children, level+1, root); + if(documentationName != null) + generateIndex(childDirectory, 1, ref.getName() + ".html"); + else + generateIndex(childDirectory, level+1, "StandardLibrary/Prelude.html"); + } + } + } + + private static String generateNavigation(int level, + HierarchicalDocumentationRef root) { + StringBuilder b = new StringBuilder(); + generateNavigation(b, level, root.getChildren()); + return b.toString(); + } + + private static void generateNavigation(StringBuilder b, int level, + List refs) { + b.append("
    "); + for(HierarchicalDocumentationRef ref : refs) { + b.append("
  • "); + String documentationName = ref.getDocumentationName(); + if(documentationName != null) { + if(!documentationName.contains("/")) + documentationName = "StandardLibrary/" + documentationName; + b.append(""); + } + b.append(ref.getName()); + if(documentationName != null) + b.append(""); + List children = ref.getChildren(); + if(children != null) + generateNavigation(b, level, children); + b.append("
  • "); + } + b.append("
"); + } +}