From 5a4f28664237fd5d53273c791f5f2decbf27d45b Mon Sep 17 00:00:00 2001 From: Laszlo Csomor Date: Thu, 26 Feb 2015 12:47:14 +0000 Subject: Annotate the public/confidential/shared parts of the BE template. Rewrite some examples that used internal labels to be safe for external version. Also remove some obsolete parts such as no-longer existent Make variables. -- MOS_MIGRATED_REVID=87241538 --- .../build/docgen/BuildEncyclopediaProcessor.java | 13 +++++-------- .../google/devtools/build/docgen/DocgenConsts.java | 19 ++++++++++++------- 2 files changed, 17 insertions(+), 15 deletions(-) (limited to 'src/main') diff --git a/src/main/java/com/google/devtools/build/docgen/BuildEncyclopediaProcessor.java b/src/main/java/com/google/devtools/build/docgen/BuildEncyclopediaProcessor.java index fb52a4ca05..e80b2c5371 100644 --- a/src/main/java/com/google/devtools/build/docgen/BuildEncyclopediaProcessor.java +++ b/src/main/java/com/google/devtools/build/docgen/BuildEncyclopediaProcessor.java @@ -59,21 +59,16 @@ public class BuildEncyclopediaProcessor { */ public void generateDocumentation(String[] inputDirs, String outputRootDir) throws BuildEncyclopediaDocException, IOException { - BufferedWriter bw = null; File buildEncyclopediaPath = setupDirectories(outputRootDir); - try { - bw = new BufferedWriter(new FileWriter(buildEncyclopediaPath)); + try (BufferedWriter bw = new BufferedWriter(new FileWriter(buildEncyclopediaPath))) { bw.write(DocgenConsts.HEADER_COMMENT); + bw.write("\n"); // for the benefit of the block-beginning comment at the top of the template Set ruleDocEntries = collectAndProcessRuleDocs(inputDirs, false); writeRuleClassDocs(ruleDocEntries, bw); + bw.write("\n"); // for the benefit of the block-beginning comment at the top of the template bw.write(SourceFileReader.readTemplateContents(DocgenConsts.FOOTER_TEMPLATE)); - - } finally { - if (bw != null) { - bw.close(); - } } } @@ -196,6 +191,7 @@ public class BuildEncyclopediaProcessor { } } + bw.write("\n"); // for the benefit of the block-beginning comment at the top of the template bw.write(SourceFileReader.readTemplateContents(DocgenConsts.HEADER_TEMPLATE, generateBEHeaderMapping(docEntries))); @@ -205,6 +201,7 @@ public class BuildEncyclopediaProcessor { DocgenConsts.VAR_SECTION_TEST, getRuleDocs(testDocs), DocgenConsts.VAR_SECTION_GENERATE, getRuleDocs(generateDocs), DocgenConsts.VAR_SECTION_OTHER, getRuleDocs(otherDocs)); + bw.write("\n"); // for the benefit of the block-beginning comment at the top of the template bw.write(SourceFileReader.readTemplateContents(DocgenConsts.BODY_TEMPLATE, sectionMapping)); } diff --git a/src/main/java/com/google/devtools/build/docgen/DocgenConsts.java b/src/main/java/com/google/devtools/build/docgen/DocgenConsts.java index a2e75832ff..161d7b6aec 100644 --- a/src/main/java/com/google/devtools/build/docgen/DocgenConsts.java +++ b/src/main/java/com/google/devtools/build/docgen/DocgenConsts.java @@ -13,6 +13,8 @@ // limitations under the License. package com.google.devtools.build.docgen; +import com.google.common.base.Joiner; +import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.devtools.build.lib.util.FileType; import com.google.devtools.build.lib.util.FileTypeSet; @@ -62,13 +64,16 @@ public class DocgenConsts { public static final String FLAG_DEPRECATED = "DEPRECATED"; public static final String FLAG_GENERIC_RULE = "GENERIC_RULE"; - public static final String HEADER_COMMENT = - "\n" - + "\n"; + public static final String HEADER_COMMENT = Joiner.on("\n").join(ImmutableList.of( + "", + "", + "", + "", + "", + "")); public static final String BUILD_ENCYCLOPEDIA_NAME = "build-encyclopedia.html"; -- cgit v1.2.3