net.sourceforge.pmd.doc.internal.SidebarGenerator Maven / Gradle / Ivy
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.doc.internal;
import java.io.IOException;
import java.io.Reader;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import org.apache.commons.lang3.SystemUtils;
import org.yaml.snakeyaml.DumperOptions;
import org.yaml.snakeyaml.DumperOptions.FlowStyle;
import org.yaml.snakeyaml.DumperOptions.LineBreak;
import org.yaml.snakeyaml.LoaderOptions;
import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.constructor.SafeConstructor;
import org.yaml.snakeyaml.representer.Representer;
import net.sourceforge.pmd.lang.Language;
import net.sourceforge.pmd.lang.rule.RuleSet;
public class SidebarGenerator {
private static final String SIDEBAR_YML = "docs/_data/sidebars/pmd_sidebar.yml";
private final FileWriter writer;
private final Path sidebarPath;
public SidebarGenerator(FileWriter writer, Path basePath) {
this.writer = Objects.requireNonNull(writer, "A file writer must be provided");
this.sidebarPath = Objects.requireNonNull(basePath, "A base directory must be provided").resolve(SIDEBAR_YML);
}
@SuppressWarnings("unchecked")
private Map extractRuleReference(Map sidebar) {
List