@Test public void shouldRenderFeaturesNotTaggedWithASectionInTheFeaturesSection() { System.setProperty("HIDE_FEATURES_SECTION", "false"); DocumentSection root = new DocumentSection(); root.addFeature(FeatureBuilder.instance().id("My Feature").name("My Feature").build()); root.addFeature(FeatureBuilder.instance().id("My Other Feature").name("My Other Feature").build()); final String expectedDocument = "[[Features, Features]]" + newLine() + "= *Features*" + newLine() + newLine() + newLine() + "[[My-Feature, My Feature]]" + newLine() + "== *My Feature*" + newLine() + newLine() + "[[My-Other-Feature, My Other Feature]]" + newLine() + "== *My Other Feature*" + newLine() + newLine(); assertEquals(expectedDocument, renderDocument(root)); }
@Override public Section addFeature(Feature feature) { if (feature.hasIgnoreDocsTag()) return this; if (isGlossary(feature)) { glossary.addFeature(feature); return this; } if (isBibliography(feature)) { bibliography.addFeature(feature); return this; } if (isIndex(feature)) { index.addFeature(feature); return this; } Optional<String> sectionId = feature.extractTag(SectionTagPattern); if (!sectionId.isPresent()) { featuresSection.addFeature(feature); return this; } addFeatureForSection(feature, sectionId.get()); if (feature.hasTag(AppendixTagPattern)) { appendixIds.add(sectionId.get()); } return this; }
DocumentSection implements Section { @Override public Section addFeature(Feature feature) { if (feature.hasIgnoreDocsTag()) return this; if (isGlossary(feature)) { glossary.addFeature(feature); return this; } if (isBibliography(feature)) { bibliography.addFeature(feature); return this; } if (isIndex(feature)) { index.addFeature(feature); return this; } Optional<String> sectionId = feature.extractTag(SectionTagPattern); if (!sectionId.isPresent()) { featuresSection.addFeature(feature); return this; } addFeatureForSection(feature, sectionId.get()); if (feature.hasTag(AppendixTagPattern)) { appendixIds.add(sectionId.get()); } return this; } }
DocumentSection implements Section { @Override public Section addFeature(Feature feature) { if (feature.hasIgnoreDocsTag()) return this; if (isGlossary(feature)) { glossary.addFeature(feature); return this; } if (isBibliography(feature)) { bibliography.addFeature(feature); return this; } if (isIndex(feature)) { index.addFeature(feature); return this; } Optional<String> sectionId = feature.extractTag(SectionTagPattern); if (!sectionId.isPresent()) { featuresSection.addFeature(feature); return this; } addFeatureForSection(feature, sectionId.get()); if (feature.hasTag(AppendixTagPattern)) { appendixIds.add(sectionId.get()); } return this; } DocumentSection();  DocumentSection(Iterable<Feature> features); }
DocumentSection implements Section { @Override public Section addFeature(Feature feature) { if (feature.hasIgnoreDocsTag()) return this; if (isGlossary(feature)) { glossary.addFeature(feature); return this; } if (isBibliography(feature)) { bibliography.addFeature(feature); return this; } if (isIndex(feature)) { index.addFeature(feature); return this; } Optional<String> sectionId = feature.extractTag(SectionTagPattern); if (!sectionId.isPresent()) { featuresSection.addFeature(feature); return this; } addFeatureForSection(feature, sectionId.get()); if (feature.hasTag(AppendixTagPattern)) { appendixIds.add(sectionId.get()); } return this; } DocumentSection();  DocumentSection(Iterable<Feature> features); @Override Section addFeature(Feature feature); @Override String render(CukedoctorDocumentBuilder docBuilder, I18nLoader i18n, DocumentAttributes documentAttributes); @Override int getOrder(); @Override Stream<Feature> getFeatures(); }
DocumentSection implements Section { @Override public Section addFeature(Feature feature) { if (feature.hasIgnoreDocsTag()) return this; if (isGlossary(feature)) { glossary.addFeature(feature); return this; } if (isBibliography(feature)) { bibliography.addFeature(feature); return this; } if (isIndex(feature)) { index.addFeature(feature); return this; } Optional<String> sectionId = feature.extractTag(SectionTagPattern); if (!sectionId.isPresent()) { featuresSection.addFeature(feature); return this; } addFeatureForSection(feature, sectionId.get()); if (feature.hasTag(AppendixTagPattern)) { appendixIds.add(sectionId.get()); } return this; } DocumentSection();  DocumentSection(Iterable<Feature> features); @Override Section addFeature(Feature feature); @Override String render(CukedoctorDocumentBuilder docBuilder, I18nLoader i18n, DocumentAttributes documentAttributes); @Override int getOrder(); @Override Stream<Feature> getFeatures();  }