@Test public void shouldRenderIndexAfterBibliography() { DocumentSection root = new DocumentSection(); root.addFeature(FeatureBuilder.instance().id("My Bibliography").name("My Bibliography").tag("@bibliography").description("This is my bibliography.").scenario(ScenarioBuilder.instance().name("Root").build()).build()); root.addFeature(FeatureBuilder.instance().id("My Index").name("My Index").tag("@index").scenario(ScenarioBuilder.instance().name("Root").build()).build()); String expectedDocument = "[bibliography]" + newLine() + "[[My-Bibliography, My Bibliography]]" + newLine() + "= *My Bibliography*" + newLine() + newLine() + newLine() + "This is my bibliography." + newLine() + newLine() + "[index]" + newLine() + "[[My-Index, My Index]]" + newLine() + "= *My Index*" + newLine() + 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();  }