RuleDocGenerator { public void generate(Iterator<RuleSet> registeredRulesets, List<String> additionalRulesets) { Map<Language, List<RuleSet>> sortedRulesets; Map<Language, List<RuleSet>> sortedAdditionalRulesets; try { sortedRulesets = sortRulesets(registeredRulesets); sortedAdditionalRulesets = sortRulesets(resolveAdditionalRulesets(additionalRulesets)); determineRuleClassSourceFiles(sortedRulesets); generateLanguageIndex(sortedRulesets, sortedAdditionalRulesets); generateRuleSetIndex(sortedRulesets); generateSidebar(sortedRulesets); } catch (RuleSetNotFoundException | IOException e) { throw new RuntimeException(e); } } RuleDocGenerator(FileWriter writer, Path root); void generate(Iterator<RuleSet> registeredRulesets, List<String> additionalRulesets);  }
@Test public void testSingleRuleset() throws RuleSetNotFoundException, IOException { RuleDocGenerator generator = new RuleDocGenerator(writer, root); RuleSetFactory rsf = RulesetsFactoryUtils.defaultFactory(); RuleSet ruleset = rsf.createRuleSet("rulesets/ruledoctest/sample.xml"); generator.generate(Arrays.asList(ruleset).iterator(), Arrays.asList( "rulesets/ruledoctest/sample-deprecated.xml", "rulesets/ruledoctest/other-ruleset.xml")); assertEquals(3, writer.getData().size()); FileEntry languageIndex = writer.getData().get(0); assertTrue(FilenameUtils.normalize(languageIndex.getFilename(), true).endsWith("docs/pages/pmd/rules/java.md")); assertEquals(loadResource("/expected/java.md"), languageIndex.getContent()); FileEntry ruleSetIndex = writer.getData().get(1); assertTrue(FilenameUtils.normalize(ruleSetIndex.getFilename(), true).endsWith("docs/pages/pmd/rules/java/sample.md")); assertEquals(loadResource("/expected/sample.md"), ruleSetIndex.getContent()); FileEntry sidebar = writer.getData().get(2); assertTrue(FilenameUtils.normalize(sidebar.getFilename(), true).endsWith("docs/_data/sidebars/pmd_sidebar.yml")); assertEquals(loadResource("/expected/pmd_sidebar.yml"), sidebar.getContent()); }