CukedoctorFeatureRenderer extends AbstractBaseRenderer implements FeatureRenderer { @Override public String renderFeature(Feature feature) { CukedoctorDocumentBuilder builder = docBuilder.createPeerBuilder(); if (feature.hasIgnoreDocsTag()) { return ""; } builder.textLine(renderFeatureSectionId(feature)); builder.title(bold(feature.getName())).newLine(); if (notNull(documentAttributes) && hasText(documentAttributes.getBackend())) { String backend = documentAttributes.getBackend(); if((backend.toLowerCase().contains("html") || backend.toLowerCase().contains("all")) && !cukedoctorConfig.isDisableMinMaxExtension()) { builder.append("ifndef::backend-pdf[]").append(newLine()); builder.append("minmax::", feature.getName().replaceAll(",", "").replaceAll(" ", "-")).append("[]").newLine(); builder.append("endif::[]").append(newLine()); } } if (hasText(feature.getDescription())) { final String description = trimAllLines(feature.getDescription()).replaceAll("\\\\", ""); renderDescription(builder, description); } if(feature.hasScenarios()){ builder.append(renderFeatureScenarios(feature, builder)); } return builder.toString(); } CukedoctorFeatureRenderer();  CukedoctorFeatureRenderer(DocumentAttributes documentAttributes);  CukedoctorFeatureRenderer(CukedoctorConfig cukedoctorConfig); @Override String renderFeature(Feature feature); @Override String renderFeatures(List<Feature> features);  }
@Test public void shouldRenderSourceDocStringInStep() { List<Feature> features = FeatureParser.parse(featureWithSourceDocStringInStep); final Feature feature = features.get(0); CukedoctorFeatureRenderer featureRenderer = new CukedoctorFeatureRenderer(new DocumentAttributes()); String resultDoc = featureRenderer.renderFeature(feature, new CukedoctorDocumentBuilderImpl().createNestedBuilder().createNestedBuilder()); assertThat(resultDoc).isEqualTo(Expectations.FEATURE_WITH_SOURCE_DOC_STRING); }
@Test public void shouldNotTrimFeatureWithCodeListingInDescription() { final String descriptionWithListing = "[source, xml]"+newLine() + "----" + newLine() + "<plugin>" + newLine() + " <groupId>com.github.cukedoctor</groupId>" + newLine() + " <artifactId>cukedoctor-maven-plugin</artifactId>" + newLine() + " <version>2.0</version>" + newLine() + " <executions>" + newLine() + " <execution>" + newLine() + " <goals>" + newLine() + " <goal>execute</goal>" + newLine() + " </goals>" + newLine() + " <phase>install</phase>" + newLine() + " </execution>" + newLine() + " </executions>" + newLine() + " <dependencies>" + newLine() + " <dependency>" + newLine() + " <groupId>com.github.cukedoctor</groupId>" + newLine() + " <artifactId>cukedoctor-section-layout</artifactId>" + newLine() + " <version>2.0</version>" + newLine() + " </dependency>" + newLine() + " </dependencies>" + newLine() + "</plugin>" + newLine() + "----"; final Feature featureWithCodeInDescription = FeatureBuilder.instance().description(descriptionWithListing) .name("A feature with listing") .build(); final String resultDoc = new CukedoctorFeatureRenderer(new DocumentAttributes()) .renderFeature(featureWithCodeInDescription, CukedoctorDocumentBuilder.Factory.newInstance().createNestedBuilder()); assertThat(resultDoc).contains(descriptionWithListing); }
@Test public void shouldNotTrimScenarioWithCodeListingInDescription() { final String descriptionWithListing = "[source, xml]"+newLine() + "----" + newLine() + "<plugin>" + newLine() + " <groupId>com.github.cukedoctor</groupId>" + newLine() + " <artifactId>cukedoctor-maven-plugin</artifactId>" + newLine() + " <version>2.0</version>" + newLine() + " <executions>" + newLine() + " <execution>" + newLine() + " <goals>" + newLine() + " <goal>execute</goal>" + newLine() + " </goals>" + newLine() + " <phase>install</phase>" + newLine() + " </execution>" + newLine() + " </executions>" + newLine() + " <dependencies>" + newLine() + " <dependency>" + newLine() + " <groupId>com.github.cukedoctor</groupId>" + newLine() + " <artifactId>cukedoctor-section-layout</artifactId>" + newLine() + " <version>2.0</version>" + newLine() + " </dependency>" + newLine() + " </dependencies>" + newLine() + "</plugin>" + newLine() + "----"; final Feature feature = FeatureBuilder.instance().description("Feature description") .name("A feature") .scenario(ScenarioBuilder.instance().name("Scenario with listing in description") .description(descriptionWithListing).build()) .build(); final String resultDoc = new CukedoctorFeatureRenderer(new DocumentAttributes()) .renderFeature(feature, CukedoctorDocumentBuilder.Factory.newInstance().createNestedBuilder()); assertThat(resultDoc).contains(descriptionWithListing); }