Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Render "*.feature"-files #1807

Closed
ghost opened this issue Feb 17, 2016 · 3 comments
Closed

Render "*.feature"-files #1807

ghost opened this issue Feb 17, 2016 · 3 comments

Comments

@ghost
Copy link

ghost commented Feb 17, 2016

Hi @tdreyno,

I would like to build an extension to render "gherkin"-files my-feature.feature into HTML. The idea behind this is the use some of the feature-files as documentation. First and foremost I would like to use the extension to generate the documentation for aruba and some internal gems I use at work.

features
  |
  +- doc
  |   |
  |   - my-feature.feature
  |
  +- tests
      |
      - my-feature.feature

The result should be something similar to http://www.relishapp.com/cucumber/aruba/v/0-11-0 but more integrated into the project's website.

The extension should have some configuration options settable via config.rb.

activate :middleman_gherkin do |e|
  e.path     = File.expand_path('../features/doc', __FILE__)       # default
  e.template = File.expand_path('../source/feature.erb', __FILE__) # default
end

Since v4.x you cannot render files into HTML which does not contain .html.format in their file names. I don't want to force users to write my-feature.html.feature files, but would like to use .feature instead. In some other issue the problem with the "missing" .html-extension was already discussed. You mentioned something about hardcoding values.

Would be possible for an extension, to tell the renderer that the result is always HTML even if the .html-part is missing.

This question is more about your experience in writing middleman-extensions: How would you implement the parser/HTML-generator. I have not decided yet how to do this. One idea is to implement it as tilt-gem, but since it requires another renderer, e.g. ERB, I'm not sure if this is the best way to go. At best I would like to leave the choice to the user which template language to use for converting feature files. This should be possible, but is there a middleman helper I can use in the extension?

Thanks a lot.

Cheers
Dennis

@tdreyno
Copy link
Member

tdreyno commented Feb 17, 2016

I would create a custom Resource type and have the extension replace any resource that is a .gerkin with a GerkinResource. That class would then have it's own render method to do whatever it wants and can set the destination_path to include .html

@ghost
Copy link
Author

ghost commented Feb 19, 2016

Thanks.

@sandstrom
Copy link
Contributor

I'm doing some issue-gardening 🌿🌷🌾 and came across this issue.

Sorry that this has lingered for quite a while! I'd suggest either closing this (it can be solved using the method described by tdreyno).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants