package com.github.cukedoctor.example.spi;

import static com.github.cukedoctor.util.Assert.hasText;
import static com.github.cukedoctor.util.Constants.Markup.bold;
import static com.github.cukedoctor.util.Constants.newLine;

import com.github.cukedoctor.api.model.Feature;
import com.github.cukedoctor.api.model.Scenario;
import com.github.cukedoctor.renderer.CukedoctorFeatureRenderer;
import com.github.cukedoctor.spi.ScenarioRenderer;

/**
 * Created by pestano on 29/02/16.
 *
 * renders features as labeled list: http://asciidoctor.org/docs/user-manual/#labeled-list
 *
 * Template
 *
 * Feature1::
 * +
 * ****
 * feature description
 * ****
 *   Scenario1:::
 *     +
 *     ****
 *      * Step1
 *      * Step2
 *      * StepN
 *     ****
 *   Scenario2:::
 *     +
 *     ****
 *      * Step1
 *      * Step2
 *     ****
 *
 *  Feature2:::
 *    //same as above
 *
 */
public class CustomFeatureRenderer extends CukedoctorFeatureRenderer {


    @Override
    public String renderFeature(Feature feature) {
        docBuilder.textLine((bold(feature.getName()))+"::").newLine();
        if (hasText(feature.getDescription())) {
            docBuilder.append("+").sideBarBlock(feature.getDescription().trim().replaceAll("\\n", " +" + newLine()));
        }

        if(feature.hasScenarios()){

            ScenarioRenderer scenarioRenderer = new CustomScenarioRenderer();
            for (Scenario scenario : feature.getScenarios()) {
                docBuilder.append(scenarioRenderer.renderScenario(scenario,feature));
            }
        }

        return docBuilder.toString();
    }
}

@@ -36,39 +36,32 @@
 le.spi;%0A%0Aimport 
-static 
 com.github.cuked
@@ -70,153 +70,38 @@
 tor.
-util.Assert.hasText;%0Aimport static com.github.cukedoctor.util.Constants.Markup.bold;%0Aimport static com.github.cukedoctor.util.Constants.newLine;%0A
+api.CukedoctorDocumentBuilder;
 %0Aimp
@@ -311,16 +311,198 @@
 derer;%0A%0A
+import static com.github.cukedoctor.util.Assert.hasText;%0Aimport static com.github.cukedoctor.util.Constants.Markup.bold;%0Aimport static com.github.cukedoctor.util.Constants.newLine;%0A%0A
 /**%0A * C
@@ -1074,28 +1074,103 @@
 ) %7B%0A        
-docB
+CukedoctorDocumentBuilder builder = docBuilder.createNestedBuilder();%0A        b
 uilder.textL
@@ -1269,36 +1269,33 @@
 ) %7B%0A            
-docB
+b
 uilder.append(%22+
@@ -1585,20 +1585,17 @@
         
-docB
+b
 uilder.a
@@ -1692,20 +1692,17 @@
  return 
-docB
+b
 uilder.t

Update CustomFeatureRenderer example to use nested doc builder