|
37 | 37 | import java.util.Set; |
38 | 38 | import java.util.UUID; |
39 | 39 | import java.util.stream.Collectors; |
| 40 | +import java.util.stream.Stream; |
40 | 41 |
|
41 | 42 | public class DocGenerator { |
42 | 43 | public static void main(String[] args) throws Exception { |
@@ -69,11 +70,13 @@ public static void generate(Path basedir, boolean publish, boolean v1) throws Ex |
69 | 70 |
|
70 | 71 | asciidoctor.convertFile(asciidoc.resolve("index.adoc").toFile(), |
71 | 72 | createOptions(asciidoc, outdir, version, null)); |
72 | | - Path modules = outdir.resolve("modules"); |
73 | | - Files.createDirectories(modules); |
74 | | - Files.walk(asciidoc.resolve("modules")).filter(Files::isRegularFile).forEach(module -> { |
75 | | - processModule(asciidoctor, asciidoc, module, outdir, version); |
76 | | - }); |
| 73 | + Stream.of("usage", "modules").forEach(SneakyThrows.throwingConsumer(name -> { |
| 74 | + Path modules = outdir.resolve(name); |
| 75 | + Files.createDirectories(modules); |
| 76 | + Files.walk(asciidoc.resolve(name)).filter(Files::isRegularFile).forEach(module -> { |
| 77 | + processModule(asciidoctor, asciidoc, module, outdir, name, version); |
| 78 | + }); |
| 79 | + })); |
77 | 80 |
|
78 | 81 | // post process |
79 | 82 | Files.walk(outdir).filter(it -> it.getFileName().toString().endsWith("index.html")) |
@@ -142,18 +145,24 @@ private static void v1doc(Path basedir, Path output) throws Exception { |
142 | 145 | } |
143 | 146 |
|
144 | 147 | private static void processModule(Asciidoctor asciidoctor, Path basedir, Path module, Path outdir, |
145 | | - String version) { |
| 148 | + String name, String version) { |
146 | 149 | try { |
147 | 150 | String moduleName = module.getFileName().toString().replace(".adoc", ""); |
148 | 151 |
|
149 | | - Options options = createOptions(basedir, outdir, version, |
150 | | - moduleName.replace("-", " ") + " module"); |
| 152 | + String title = moduleName.replace("-", " "); |
| 153 | + if (name.equals("modules")) { |
| 154 | + title += " module"; |
| 155 | + } |
| 156 | + Options options = createOptions(basedir, outdir, version, title); |
151 | 157 |
|
152 | 158 | asciidoctor.convertFile(module.toFile(), options); |
153 | 159 |
|
154 | 160 | Path output = outdir.resolve(moduleName + ".html").toAbsolutePath(); |
155 | | - Path indexlike = output.getParent().resolve("modules").resolve(moduleName) |
156 | | - .resolve("index.html"); |
| 161 | + Path indexlike = output.getParent().resolve(name); |
| 162 | + if (name.equals("modules")) { |
| 163 | + indexlike = indexlike.resolve(moduleName); |
| 164 | + } |
| 165 | + indexlike = indexlike.resolve("index.html"); |
157 | 166 | Files.createDirectories(indexlike.getParent()); |
158 | 167 | Files.move(output, indexlike); |
159 | 168 | String content = new String(Files.readAllBytes(indexlike), StandardCharsets.UTF_8) |
|
0 commit comments