Skip to content

Commit

Permalink
Add exclude_tags to yard config
Browse files Browse the repository at this point in the history
  • Loading branch information
norekinc committed Jun 9, 2016
1 parent 23f5220 commit 8d84b03
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,16 @@ English step definitions. Even without specifying this feature files in other
languages are found, this provides the ability for the step definitions to match
correctly to step definitions.

* Exclude features or scenarios from yardoc

You can exclude any feature or scenario from the yardoc by adding a predefined tags to them.
To define tags that will be excluded, again in yard configuration file:

```yaml
:"yard-cucumber":
exclude_tags: [ 'exclude-yardoc', 'also-exclude-yardoc' ]
```

## Details

There are two things that I enjoy: a test framework written in my own Domain
Expand Down Expand Up @@ -185,4 +195,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12 changes: 12 additions & 0 deletions lib/cucumber/city_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ def find_or_create_tag(tag_name,parent)
def feature(feature)
#log.debug "FEATURE"

return if has_exclude_tags?(feature[:tags].map { |t| t[:name].gsub(/^@/, '') })

@feature = YARD::CodeObjects::Cucumber::Feature.new(@namespace,File.basename(@file.gsub('.feature','').gsub('.','_'))) do |f|
f.comments = feature[:comments] ? feature[:comments].map{|comment| comment[:text]}.join("\n") : ''
f.description = feature[:description] || ''
Expand Down Expand Up @@ -150,6 +152,8 @@ def background(background)
def scenario(statement)
#log.debug "SCENARIO"

return if has_exclude_tags?(statement[:tags].map { |t| t[:name].gsub(/^@/, '') })

scenario = YARD::CodeObjects::Cucumber::Scenario.new(@feature,"scenario_#{@feature.scenarios.length + 1}") do |s|
s.comments = statement[:comments] ? statement[:comments].map{|comment| comment.value}.join("\n") : ''
s.description = statement[:description] || ''
Expand Down Expand Up @@ -178,6 +182,8 @@ def scenario(statement)
def scenario_outline(statement)
#log.debug "SCENARIO OUTLINE"

return if has_exclude_tags?(statement[:tags].map { |t| t[:name].gsub(/^@/, '') })

outline = YARD::CodeObjects::Cucumber::ScenarioOutline.new(@feature,"scenario_#{@feature.scenarios.length + 1}") do |s|
s.comments = statement[:comments] ? statement[:comments].map{|comment| comment.value}.join("\n") : ''
s.description = statement[:description] || ''
Expand Down Expand Up @@ -344,6 +350,12 @@ def clone_table(base)
base.map {|row| row.map {|cell| cell.dup }}
end

def has_exclude_tags?(tags)
if YARD::Config.options["yard-cucumber"] and YARD::Config.options["yard-cucumber"]["exclude_tags"]
return true unless (YARD::Config.options["yard-cucumber"]["exclude_tags"] & tags).empty?
end
end

end
end
end

0 comments on commit 8d84b03

Please sign in to comment.