Skip to content

Asciidoctor extension to format gherkin feature files in asciidoc files.

License

Notifications You must be signed in to change notification settings

jboz/asciidoctor-gherkin-extension

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

asciidoctor-gherkin-extension

You can use this extension to include your gherkin feature files in asciidoc in the form of sections, paragraphs, lists and tables.

The conversion is based on a simple and customizable erb template.

This project is up to date with the last gherkin specification and use the last version of the https://github.com/cucumber/gherkin library. Take a look at https://cucumber.io/docs/gherkin/reference/ to see the full supported syntax.

Usage

The following feature

simple.feature
Feature: A simple feature
  This is the feature description.

  Background: Background
    Given a simple background step.

  Scenario: Scenario title
    Given a simple scenario step
    When I render the asciidoctor content to html
    Then my feature gets nicely formatted in html.

can be included via the gherkin block macro :

gherkin::./simple.feature[]

and gets rendered into a 3rd level section with subsections :

Corresponding intermediate asciidoc source
=== A simple feature

This is the feature description.

==== Background

* *Given* a simple background step.

==== Scenario title

* *Given* a simple scenario step
* *When* I render the asciidoctor content to html
* *Then* my feature gets nicely formatted in html.

If the 3rd level section doesn’t match the section level at the point where you want to include your feature file, you can adjust the section level via the :leveloffset: attribute.

:leveloffset: -1
gherkin::./simple.feature[]
:leveloffset: +1

Or just create your own template.

Custom templates

You can use the template attribute to specify a custom erb template. The attribute value is used as a relative file path, resolved using the docdir attribute as base directory. The template receives a hash called feature containing the feature elements (scenarios, steps, examples, docstrings etc.).

Here is an example of a custom template rendering a table with one row per scenario :

mytemplate.erb
:tip-caption: 💡
:tip-caption: :bulb:

[TIP]
====
Implemented feature: https://linkToMyFeature[<%= feature.getName() %>]
====

assuming you place this template in the same directory as your asciidoc file, the following asciidoc content

gherkin::./simple.feature[template=mytemplate.erb]

would render like

💡

Implemented feature: My feature title

Options

You can define attribut(s) in the asciddoc way :

gherkin::./simple.feature[attribut1=value1,attribut2=value2]

To see the list of available attributes and their default values open file src/main/java/ch/ifocusit/asciidoctor/gherkin/GherkinAsciidocBuilder.java

About

Asciidoctor extension to format gherkin feature files in asciidoc files.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages

  • HTML 36.9%
  • Java 34.9%
  • Gherkin 16.9%
  • Ruby 11.3%