From 490fe312f25c7643c1221de5274e5cbcbeb4683c Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Fri, 10 Nov 2017 17:59:04 +0100 Subject: [PATCH] [doc] Move the additional rulesets to the bottom --- .../pmd/docs/RuleDocGenerator.java | 40 ++++++++----------- pmd-doc/src/test/resources/expected/java.md | 14 +++---- 2 files changed, 24 insertions(+), 30 deletions(-) diff --git a/pmd-doc/src/main/java/net/sourceforge/pmd/docs/RuleDocGenerator.java b/pmd-doc/src/main/java/net/sourceforge/pmd/docs/RuleDocGenerator.java index 75f91b873a..754db91a16 100644 --- a/pmd-doc/src/main/java/net/sourceforge/pmd/docs/RuleDocGenerator.java +++ b/pmd-doc/src/main/java/net/sourceforge/pmd/docs/RuleDocGenerator.java @@ -184,31 +184,11 @@ public class RuleDocGenerator { lines.add("folder: pmd/rules"); lines.add("---"); - lines.add("List of rulesets and rules contained in each ruleset."); - lines.add(""); - - for (RuleSet ruleset : entry.getValue()) { - String link = RULESET_INDEX_PERMALINK_PATTERN - .replace("${language.tersename}", languageTersename) - .replace("${ruleset.name}", RuleSetUtils.getRuleSetFilename(ruleset)); - lines.add("* [" + ruleset.getName() + "](" + link + "): " + getRuleSetDescriptionSingleLine(ruleset)); - } - lines.add(""); - - List additionalRulesetsForLanguage = sortedAdditionalRulesets.get(entry.getKey()); - if (additionalRulesetsForLanguage != null) { - lines.add("List of additional rulesets"); - for (RuleSet ruleset : additionalRulesetsForLanguage) { - String deprecation = isRuleSetDeprecated(ruleset) ? DEPRECATION_LABEL_SMALL : ""; - lines.add("* " + ruleset.getName() + ": " - + deprecation - + getRuleSetDescriptionSingleLine(ruleset)); - } - lines.add(""); - } - for (RuleSet ruleset : entry.getValue()) { lines.add("## " + ruleset.getName()); + lines.add(""); + lines.add("{% include callout.html content=\"" + getRuleSetDescriptionSingleLine(ruleset).replaceAll("\"", "'") + "\" %}"); + lines.add(""); for (Rule rule : getSortedRules(ruleset)) { String link = RULESET_INDEX_PERMALINK_PATTERN @@ -242,6 +222,20 @@ public class RuleDocGenerator { lines.add(""); } + List additionalRulesetsForLanguage = sortedAdditionalRulesets.get(entry.getKey()); + if (additionalRulesetsForLanguage != null) { + lines.add("## Additional rulesets"); + lines.add(""); + + for (RuleSet ruleset : additionalRulesetsForLanguage) { + String deprecation = isRuleSetDeprecated(ruleset) ? DEPRECATION_LABEL_SMALL : ""; + lines.add("* " + ruleset.getName() + ": " + + deprecation + + getRuleSetDescriptionSingleLine(ruleset)); + } + lines.add(""); + } + System.out.println("Generated " + path); writer.write(path, lines); } diff --git a/pmd-doc/src/test/resources/expected/java.md b/pmd-doc/src/test/resources/expected/java.md index 195feeb09a..4fbdbc838d 100644 --- a/pmd-doc/src/test/resources/expected/java.md +++ b/pmd-doc/src/test/resources/expected/java.md @@ -3,16 +3,16 @@ title: Java Rules permalink: pmd_rules_java.html folder: pmd/rules --- -List of rulesets and rules contained in each ruleset. - -* [Sample](pmd_rules_java_sample.html): Sample ruleset to test rule doc generation. - -List of additional rulesets -* Sample Deprecated: Deprecated Sample ruleset which only contains deprecated rule references. - ## Sample + +{% include callout.html content="Sample ruleset to test rule doc generation." %} + * [DeprecatedSample](pmd_rules_java_sample.html#deprecatedsample): Deprecated Just some description of a deprecated rule. * [JumbledIncrementer](pmd_rules_java_sample.html#jumbledincrementer): Avoid jumbled loop incrementers - its usually a mistake, and is confusing even if intentional. * [MovedRule](pmd_rules_java_sample.html#movedrule): Deprecated The rule has been moved to another ruleset. Use instead [JumbledIncrementer](pmd_rules_java_sample2.html#jumbledincrementer). * [OverrideBothEqualsAndHashcode](pmd_rules_java_sample.html#overridebothequalsandhashcode): Override both 'public boolean Object.equals(Object other)', and 'public int Object.hashCode()', o... * [RenamedRule](pmd_rules_java_sample.html#renamedrule): Deprecated The rule has been renamed. Use instead [JumbledIncrementer](pmd_rules_java_sample.html#jumbledincrementer). + +## Additional rulesets + +* Sample Deprecated: Deprecated Sample ruleset which only contains deprecated rule references.