yard-cucumber2 2.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +6 -0
- data/.rspec +3 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +37 -0
- data/History.txt +274 -0
- data/LICENSE.txt +22 -0
- data/README.md +188 -0
- data/Rakefile +25 -0
- data/example/README.md +8 -0
- data/example/child_feature/README.md +21 -0
- data/example/child_feature/child.feature +11 -0
- data/example/child_feature/grandchild_feature/grandchild.feature +12 -0
- data/example/empty.feature +2 -0
- data/example/french.feature +18 -0
- data/example/scenario.feature +63 -0
- data/example/scenario_outline.feature +94 -0
- data/example/scenario_outline_multi.feature +15 -0
- data/example/step_definitions/example.step.rb +109 -0
- data/example/step_definitions/first.step.rb +21 -0
- data/example/step_definitions/french_steps.rb +32 -0
- data/example/step_definitions/struct.rb +11 -0
- data/example/step_definitions/support/env.rb +7 -0
- data/example/step_definitions/support/env_support.rb +12 -0
- data/example/step_definitions/support/support.rb +6 -0
- data/example/tags.feature +18 -0
- data/example/transform.feature +13 -0
- data/lib/cucumber/city_builder.rb +331 -0
- data/lib/docserver/default/fulldoc/html/js/cucumber.js +85 -0
- data/lib/docserver/default/layout/html/headers.erb +14 -0
- data/lib/docserver/doc_server/full_list/html/full_list.erb +39 -0
- data/lib/docserver/doc_server/full_list/html/setup.rb +18 -0
- data/lib/templates/default/feature/html/feature.erb +39 -0
- data/lib/templates/default/feature/html/no_steps_defined.erb +1 -0
- data/lib/templates/default/feature/html/outline.erb +56 -0
- data/lib/templates/default/feature/html/pystring.erb +3 -0
- data/lib/templates/default/feature/html/scenario.erb +55 -0
- data/lib/templates/default/feature/html/setup.rb +55 -0
- data/lib/templates/default/feature/html/steps.erb +39 -0
- data/lib/templates/default/feature/html/table.erb +20 -0
- data/lib/templates/default/featuredirectory/html/alpha_table.erb +30 -0
- data/lib/templates/default/featuredirectory/html/directory.erb +32 -0
- data/lib/templates/default/featuredirectory/html/setup.rb +41 -0
- data/lib/templates/default/featuretags/html/namespace.erb +131 -0
- data/lib/templates/default/featuretags/html/setup.rb +34 -0
- data/lib/templates/default/fulldoc/html/css/cucumber.css +227 -0
- data/lib/templates/default/fulldoc/html/directories.erb +53 -0
- data/lib/templates/default/fulldoc/html/full_list_featuredirectories.erb +11 -0
- data/lib/templates/default/fulldoc/html/full_list_features.erb +29 -0
- data/lib/templates/default/fulldoc/html/full_list_stepdefinitions.erb +16 -0
- data/lib/templates/default/fulldoc/html/full_list_steps.erb +17 -0
- data/lib/templates/default/fulldoc/html/full_list_tags.erb +12 -0
- data/lib/templates/default/fulldoc/html/js/cucumber.js +305 -0
- data/lib/templates/default/fulldoc/html/setup.rb +175 -0
- data/lib/templates/default/layout/html/setup.rb +56 -0
- data/lib/templates/default/requirements/html/alpha_table.erb +26 -0
- data/lib/templates/default/requirements/html/requirements.erb +50 -0
- data/lib/templates/default/requirements/html/setup.rb +51 -0
- data/lib/templates/default/steptransformers/html/header.erb +12 -0
- data/lib/templates/default/steptransformers/html/index.erb +10 -0
- data/lib/templates/default/steptransformers/html/setup.rb +94 -0
- data/lib/templates/default/steptransformers/html/transformers.erb +79 -0
- data/lib/templates/default/steptransformers/html/undefinedsteps.erb +26 -0
- data/lib/templates/default/tag/html/alpha_table.erb +32 -0
- data/lib/templates/default/tag/html/setup.rb +27 -0
- data/lib/templates/default/tag/html/tag.erb +35 -0
- data/lib/yard-cucumber.rb +47 -0
- data/lib/yard-cucumber/version.rb +3 -0
- data/lib/yard/code_objects/cucumber/base.rb +32 -0
- data/lib/yard/code_objects/cucumber/feature.rb +18 -0
- data/lib/yard/code_objects/cucumber/namespace_object.rb +49 -0
- data/lib/yard/code_objects/cucumber/scenario.rb +26 -0
- data/lib/yard/code_objects/cucumber/scenario_outline.rb +75 -0
- data/lib/yard/code_objects/cucumber/step.rb +38 -0
- data/lib/yard/code_objects/cucumber/tag.rb +27 -0
- data/lib/yard/code_objects/step_definition.rb +7 -0
- data/lib/yard/code_objects/step_transform.rb +7 -0
- data/lib/yard/code_objects/step_transformer.rb +97 -0
- data/lib/yard/handlers/cucumber/base.rb +21 -0
- data/lib/yard/handlers/cucumber/feature_handler.rb +131 -0
- data/lib/yard/handlers/legacy/step_definition_handler.rb +45 -0
- data/lib/yard/handlers/legacy/step_transform_handler.rb +24 -0
- data/lib/yard/handlers/step_definition_handler.rb +86 -0
- data/lib/yard/handlers/step_transform_handler.rb +31 -0
- data/lib/yard/parser/cucumber/feature.rb +73 -0
- data/lib/yard/server/adapter.rb +43 -0
- data/lib/yard/server/commands/list_command.rb +31 -0
- data/lib/yard/server/router.rb +32 -0
- data/lib/yard/templates/helpers/base_helper.rb +26 -0
- data/yard-cucumber.gemspec +65 -0
- metadata +199 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<% n = 1 %>
|
|
2
|
+
<li class="r<%= n %>">
|
|
3
|
+
<%= all_features_link %>
|
|
4
|
+
</li>
|
|
5
|
+
<% n = n == 2 ? 1 : 2 %>
|
|
6
|
+
<% @items.each do |feature| %>
|
|
7
|
+
<li class="r<%= n %>">
|
|
8
|
+
<%= "<a class='toggle'></a>" unless feature.scenarios.empty? %>
|
|
9
|
+
<%= linkify feature, feature.value %>
|
|
10
|
+
<small><%= feature.location %></small>
|
|
11
|
+
</li>
|
|
12
|
+
<% n = n == 2 ? 1 : 2 %>
|
|
13
|
+
<% if feature.scenarios %>
|
|
14
|
+
<ul>
|
|
15
|
+
<% feature.scenarios.each_with_index do |scenario,index| %>
|
|
16
|
+
<li class="r<%= n %>">
|
|
17
|
+
<span class='object_link'>
|
|
18
|
+
<a href="<%= url_for(scenario.feature,"scenario_#{index}") %>"
|
|
19
|
+
title="<%= h scenario.value %>">
|
|
20
|
+
<%= h scenario.value %>
|
|
21
|
+
</a>
|
|
22
|
+
</span>
|
|
23
|
+
<small><%= scenario.location %></small>
|
|
24
|
+
</li>
|
|
25
|
+
<% n = n == 2 ? 1 : 2 %>
|
|
26
|
+
<% end %>
|
|
27
|
+
</ul>
|
|
28
|
+
<% end %>
|
|
29
|
+
<% end %>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<li>
|
|
2
|
+
<%= linkify YARD::CodeObjects::Cucumber::CUCUMBER_STEPTRANSFORM_NAMESPACE, "All Step Definitions" %>
|
|
3
|
+
</li>
|
|
4
|
+
<% n = 1 %>
|
|
5
|
+
<% @items.each do |stepdef| %>
|
|
6
|
+
<li class="r<%= n %>">
|
|
7
|
+
<span class='object_link'>
|
|
8
|
+
<span class="pre"><%= stepdef.keyword %></span>
|
|
9
|
+
<a href="<%= url_for stepdef %>" title="<%= h stepdef.value %>">
|
|
10
|
+
<span class="name"><%= h stepdef.literal_value %></span>
|
|
11
|
+
</a>
|
|
12
|
+
</span>
|
|
13
|
+
<small><%= h(stepdef.location) %></small>
|
|
14
|
+
</li>
|
|
15
|
+
<% n = n == 2 ? 1 : 2 %>
|
|
16
|
+
<% end %>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<li>
|
|
2
|
+
<%= linkify YARD::CodeObjects::Cucumber::CUCUMBER_STEPTRANSFORM_NAMESPACE, "All Defined Steps" %>
|
|
3
|
+
</li>
|
|
4
|
+
<% n = 1 %>
|
|
5
|
+
|
|
6
|
+
<% @items.each do |step| %>
|
|
7
|
+
<li class="r<%= n %>">
|
|
8
|
+
<span class='object_link'>
|
|
9
|
+
<a href="<%= url_for step.scenario.feature %>" title="<%= h step.value %>">
|
|
10
|
+
<span class="pre"><%= step.keyword %></span>
|
|
11
|
+
<span class="name"><%= h(step.value) %></span>
|
|
12
|
+
</a>
|
|
13
|
+
</span>
|
|
14
|
+
<span class="">(<%= h(step.file) %>)<span>
|
|
15
|
+
</li>
|
|
16
|
+
<% n = n == 2 ? 1 : 2 %>
|
|
17
|
+
<% end %>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<li>
|
|
2
|
+
<%= linkify YARD::CodeObjects::Cucumber::CUCUMBER_TAG_NAMESPACE, "All Tags" %>
|
|
3
|
+
</li>
|
|
4
|
+
<% n = 1 %>
|
|
5
|
+
|
|
6
|
+
<% @items.each do |tag| %>
|
|
7
|
+
<li class="r<%= n %>">
|
|
8
|
+
<%= linkify tag, tag.value %>
|
|
9
|
+
<small><%= tag.all_scenarios.size %></small>
|
|
10
|
+
</li>
|
|
11
|
+
<% n = n == 2 ? 1 : 2 %>
|
|
12
|
+
<% end %>
|
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
function cucumberKeyboardShortcuts() {
|
|
2
|
+
if (window.top.frames.main) return;
|
|
3
|
+
$(document).keypress(function(evt) {
|
|
4
|
+
if (evt.altKey || evt.ctrlKey || evt.metaKey || evt.shiftKey) return;
|
|
5
|
+
if (typeof evt.target !== "undefined" &&
|
|
6
|
+
(evt.target.nodeName == "INPUT" ||
|
|
7
|
+
evt.target.nodeName == "TEXTAREA")) return;
|
|
8
|
+
switch (evt.charCode) {
|
|
9
|
+
case 68: case 100: $('#stepdefinition_list_link').click(); break; // 'd'
|
|
10
|
+
case 82: case 114: $('#feature_list_link').click(); break; // 'r'
|
|
11
|
+
case 83: case 115: $('#step_list_link').click(); break; // 's'
|
|
12
|
+
case 84: case 116: $('#tag_list_link').click(); break; // 't'
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
$(cucumberKeyboardShortcuts);
|
|
18
|
+
|
|
19
|
+
$(function() {
|
|
20
|
+
|
|
21
|
+
//
|
|
22
|
+
// Feature Page - Scenarios
|
|
23
|
+
//
|
|
24
|
+
$('.scenario div.title').click(function(eventObject) {
|
|
25
|
+
if (typeof eventObject.currentTarget !== "undefined") {
|
|
26
|
+
toggleScenario( $($(eventObject.currentTarget).parent()) );
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
//
|
|
31
|
+
// Developer View
|
|
32
|
+
// Click + Developer View = toggle the expansion of all tags, location, and comments
|
|
33
|
+
//
|
|
34
|
+
$('#view').click(function(eventObject) {
|
|
35
|
+
|
|
36
|
+
if (typeof eventObject.currentTarget !== "undefined") {
|
|
37
|
+
var view = eventObject.currentTarget;
|
|
38
|
+
|
|
39
|
+
if (view.innerHTML === '[More Detail]') {
|
|
40
|
+
$('.developer').show(500);
|
|
41
|
+
view.innerHTML = '[Less Detail]';
|
|
42
|
+
} else {
|
|
43
|
+
$('.developer').hide(500);
|
|
44
|
+
// Already hidden elements with .developer sub-elements were not getting message
|
|
45
|
+
$('.developer').each(function() {
|
|
46
|
+
$(this).css('display','none');
|
|
47
|
+
});
|
|
48
|
+
view.innerHTML = '[More Detail]';
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
//
|
|
54
|
+
// Expand/Collapse All
|
|
55
|
+
//
|
|
56
|
+
$('#expand').click(function(eventObject) {
|
|
57
|
+
|
|
58
|
+
if (typeof eventObject.currentTarget !== "undefined") {
|
|
59
|
+
if (eventObject.currentTarget.innerHTML === '[Expand All]') {
|
|
60
|
+
eventObject.currentTarget.innerHTML = '[Collapse All]';
|
|
61
|
+
$('div.scenario > div.details:hidden').each(function() {
|
|
62
|
+
toggleScenario( $($(this).parent()) );
|
|
63
|
+
});
|
|
64
|
+
} else {
|
|
65
|
+
eventObject.currentTarget.innerHTML = '[Expand All]';
|
|
66
|
+
$('div.scenario > div.details:visible').each(function() {
|
|
67
|
+
toggleScenario( $($(this).parent()) );
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
//
|
|
74
|
+
// Expand/Collapse All
|
|
75
|
+
//
|
|
76
|
+
$('#stepdefinition,#steptransform').click(function(eventObject) {
|
|
77
|
+
|
|
78
|
+
if (typeof eventObject.currentTarget !== "undefined") {
|
|
79
|
+
if (eventObject.currentTarget.innerHTML === '[Expand All]') {
|
|
80
|
+
eventObject.currentTarget.innerHTML = '[Collapse All]';
|
|
81
|
+
$('div.' + eventObject.currentTarget.id + ' > div.details:hidden').each(function() {
|
|
82
|
+
$(this).show(200);
|
|
83
|
+
});
|
|
84
|
+
} else {
|
|
85
|
+
eventObject.currentTarget.innerHTML = '[Expand All]';
|
|
86
|
+
$('div.' + eventObject.currentTarget.id + ' > div.details:visible').each(function() {
|
|
87
|
+
$(this).hide(200);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
//
|
|
95
|
+
// Scenario Outlines - Toggle Examples
|
|
96
|
+
//
|
|
97
|
+
$('.outline table tr').click(function(eventObject) {
|
|
98
|
+
|
|
99
|
+
if (typeof eventObject.currentTarget !== "undefined") {
|
|
100
|
+
var exampleRow = $(eventObject.currentTarget);
|
|
101
|
+
|
|
102
|
+
if (eventObject.currentTarget.className.match(/example\d+-\d+/) == null) {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
var exampleClass = eventObject.currentTarget.className.match(/example\d+-\d+/)[0];
|
|
107
|
+
var example = exampleRow.closest('div.details').find('.' + exampleClass);
|
|
108
|
+
|
|
109
|
+
var currentExample = null;
|
|
110
|
+
|
|
111
|
+
$('.outline table tr').each(function() {
|
|
112
|
+
$(this).removeClass('selected');
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
if ( example[0].style.display == 'none' ) {
|
|
116
|
+
currentExample = example[0];
|
|
117
|
+
exampleRow.addClass('selected');
|
|
118
|
+
} else {
|
|
119
|
+
currentExample = exampleRow.closest('div.details').find('.steps')[0];
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// hide everything
|
|
123
|
+
exampleRow.closest('div.details').find('.steps').each(function() {
|
|
124
|
+
$(this).hide();
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
// show the selected
|
|
128
|
+
$(currentExample).show();
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
function toggleScenario(scenario) {
|
|
137
|
+
|
|
138
|
+
var state = scenario.find(".attributes input[name='collapsed']")[0];
|
|
139
|
+
|
|
140
|
+
if (state.value === 'true') {
|
|
141
|
+
scenario.find("div.details").each(function() {
|
|
142
|
+
$(this).show(500);
|
|
143
|
+
});
|
|
144
|
+
state.value = "false";
|
|
145
|
+
scenario.find('a.toggle').each(function() {
|
|
146
|
+
this.innerHTML = ' - ';
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
} else {
|
|
150
|
+
scenario.find("div.details").each(function() {
|
|
151
|
+
$(this).hide(500);
|
|
152
|
+
});
|
|
153
|
+
state.value = "true";
|
|
154
|
+
scenario.find('a.toggle').each(function() {
|
|
155
|
+
this.innerHTML = ' + ';
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
function updateTagFiltering(tagString) {
|
|
162
|
+
var formulaTags = determineTagsUsedInFormula(tagString);
|
|
163
|
+
displayExampleCommandLine(formulaTags);
|
|
164
|
+
displayQualifyingFeaturesAndScenarios(formulaTags);
|
|
165
|
+
fixSectionRowAlternations();
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function clearTagFiltering() {
|
|
169
|
+
updateTagFiltering("");
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function determineTagsUsedInFormula(tagString) {
|
|
173
|
+
|
|
174
|
+
tagString = tagString.replace(/^(\s+)|(\s+)$/,'').replace(/\s{2,}/,' ');
|
|
175
|
+
|
|
176
|
+
var tagGroup = tagString.match(/(?:~)?@\w+(,(?:~)?@\w+)*/g);
|
|
177
|
+
|
|
178
|
+
var returnTags = [];
|
|
179
|
+
|
|
180
|
+
if (tagGroup) {
|
|
181
|
+
tagGroup.forEach(function(tag, index, array) {
|
|
182
|
+
console.log("Tag Group: " + tag);
|
|
183
|
+
var validTags = removeInvalidTags(tag)
|
|
184
|
+
if (validTags != "") {
|
|
185
|
+
returnTags.push(validTags);
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
return returnTags;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function removeInvalidTags(tagGroup) {
|
|
194
|
+
tagGroup.split(",").forEach(function(tag, index, array) {
|
|
195
|
+
|
|
196
|
+
baseTag = tag.match(/^~(.+)/) ? tag.match(/^~(.+)/)[1] : tag;
|
|
197
|
+
|
|
198
|
+
//console.log("Validating Tag: " + tag)
|
|
199
|
+
if (tag_list.indexOf(baseTag) === -1) {
|
|
200
|
+
//console.log("Removing Tag: " + tag);
|
|
201
|
+
tagGroup = tagGroup.replace(new RegExp(',?' + tag + ',?'),"")
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
return tagGroup;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
function displayExampleCommandLine(tags) {
|
|
210
|
+
$("#command_example")[0].innerHTML = "cucumber ";
|
|
211
|
+
|
|
212
|
+
if (tags.length > 0) {
|
|
213
|
+
$("#command_example")[0].innerHTML += "--tags " + tags.join(" --tags ");
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function fixSectionRowAlternations() {
|
|
218
|
+
$(".feature:visible,.scenario:visible").each(function(index){
|
|
219
|
+
$(this).removeClass("odd even").addClass( ((index + 1) % 2 == 0 ? "even" : "odd") );
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
function displayQualifyingFeaturesAndScenarios(tags) {
|
|
224
|
+
|
|
225
|
+
if (tags.length > 0) {
|
|
226
|
+
|
|
227
|
+
$(".feature,.scenario").each(function(feature){
|
|
228
|
+
$(this).hide();
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
var tagSelectors = generateCssSelectorFromTags(tags);
|
|
232
|
+
|
|
233
|
+
tagSelectors.forEach(function(selector,selectorIndex,selectorArray) {
|
|
234
|
+
var tags = selector;
|
|
235
|
+
|
|
236
|
+
$(".feature." + tags).each(function(index) {
|
|
237
|
+
$(this).show();
|
|
238
|
+
});
|
|
239
|
+
$(".scenario." + tags).each(function(index) {
|
|
240
|
+
$(this).show();
|
|
241
|
+
$(this).parent().prev().show();
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
if ( $(".feature:visible,.scenario:visible").length == 0 ) {
|
|
247
|
+
$("#features div.undefined").show();
|
|
248
|
+
} else {
|
|
249
|
+
$("#features div.undefined").hide();
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
} else {
|
|
254
|
+
$(".feature:hidden,.scenario:hidden").each(function(feature){
|
|
255
|
+
$(this).show();
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
function generateCssSelectorFromTags(tagGroups) {
|
|
262
|
+
|
|
263
|
+
var tagSelectors = [ "" ];
|
|
264
|
+
|
|
265
|
+
tagGroups.forEach(function(tagGroup,index,array) {
|
|
266
|
+
var newTagSelectors = [];
|
|
267
|
+
|
|
268
|
+
tagSelectors.forEach(function(selector,selectorIndex,selectorArray) {
|
|
269
|
+
tagGroup.split(",").forEach(function(tag,tagIndex,tagArray) {
|
|
270
|
+
|
|
271
|
+
if ( tag.match(/^~@.+$/) ) {
|
|
272
|
+
tag = tag.match(/^~(@.+)$/)[1]
|
|
273
|
+
//console.log("selector: " + (selector + " :not(" + tag + ")").trim());
|
|
274
|
+
newTagSelectors.push((selector + ":not(." + tag.replace(/@/g,"\\@") +")").trim());
|
|
275
|
+
} else {
|
|
276
|
+
//console.log("selector: " + (selector + " " + tag).trim());
|
|
277
|
+
newTagSelectors.push((selector + "." + tag.replace(/@/g,"\\@")).trim());
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
tagSelectors = newTagSelectors;
|
|
284
|
+
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
return tagSelectors;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
function createStepDefinitionLinks() {
|
|
293
|
+
// $('.step_instances_list').
|
|
294
|
+
// before("<span class='showSteps'>[<a href='#' class='toggleSteps'>View steps</a>]</span>");
|
|
295
|
+
$('.toggleSteps').toggle(function() {
|
|
296
|
+
$(this).parent().next().slideUp(100);
|
|
297
|
+
$(this).text("View " + $(this).attr('alt'));
|
|
298
|
+
},
|
|
299
|
+
function() {
|
|
300
|
+
$(this).parent().next().slideDown(100);
|
|
301
|
+
$(this).text("Hide " + $(this).attr('alt'));
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
$(createStepDefinitionLinks);
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
include YARD::Templates::Helpers::HtmlHelper
|
|
2
|
+
|
|
3
|
+
def init
|
|
4
|
+
super
|
|
5
|
+
|
|
6
|
+
# Additional javascript that power the additional menus, collapsing, etc.
|
|
7
|
+
asset "js/cucumber.js", file("js/cucumber.js",true)
|
|
8
|
+
|
|
9
|
+
serialize_object_type :feature
|
|
10
|
+
|
|
11
|
+
serialize_object_type :tag
|
|
12
|
+
|
|
13
|
+
# Generates the requirements splash page with the 'requirements' template
|
|
14
|
+
serialize(YARD::CodeObjects::Cucumber::CUCUMBER_NAMESPACE)
|
|
15
|
+
|
|
16
|
+
# Generates a page for step definitions and step transforms with the 'steptransformers' template
|
|
17
|
+
serialize(YARD::CodeObjects::Cucumber::CUCUMBER_STEPTRANSFORM_NAMESPACE)
|
|
18
|
+
|
|
19
|
+
# Generates the tags page with the 'featuretags' template
|
|
20
|
+
serialize(YARD::CodeObjects::Cucumber::CUCUMBER_TAG_NAMESPACE)
|
|
21
|
+
|
|
22
|
+
serialize_feature_directories
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
#
|
|
26
|
+
# The top-level feature directories. This is affected by the directories that YARD is told to parse.
|
|
27
|
+
# All other features in sub-directories are contained under each of these top-level directories.
|
|
28
|
+
#
|
|
29
|
+
# @example Generating one feature directory
|
|
30
|
+
#
|
|
31
|
+
# `yardoc 'example/**/*'`
|
|
32
|
+
#
|
|
33
|
+
# @example Generating two feature directories
|
|
34
|
+
#
|
|
35
|
+
# `yardoc 'example/**/*' 'example2/**/*'`
|
|
36
|
+
#
|
|
37
|
+
# @return the feature directories at the root of the Cucumber Namespace.
|
|
38
|
+
#
|
|
39
|
+
def root_feature_directories
|
|
40
|
+
@root_feature_directories ||= YARD::CodeObjects::Cucumber::CUCUMBER_NAMESPACE.children.find_all {|child| child.is_a?(YARD::CodeObjects::Cucumber::FeatureDirectory)}
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
#
|
|
44
|
+
# Generate pages for the objects if there are objects of this type contained
|
|
45
|
+
# within the Registry.
|
|
46
|
+
#
|
|
47
|
+
def serialize_object_type(type)
|
|
48
|
+
objects = Registry.all(type.to_sym)
|
|
49
|
+
Array(objects).each {|object| serialize(object) }
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
#
|
|
53
|
+
# Generates pages for the feature directories found. Starting with all root-level feature
|
|
54
|
+
# directories and then recursively finding all child feature directories.
|
|
55
|
+
#
|
|
56
|
+
def serialize_feature_directories
|
|
57
|
+
serialize_feature_directories_recursively(root_feature_directories)
|
|
58
|
+
root_feature_directories.each {|directory| serialize(directory) }
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
#
|
|
62
|
+
# Generate a page for each Feature Directory. This is called recursively to
|
|
63
|
+
# ensure that all feature directories contained as children are rendered to
|
|
64
|
+
# pages.
|
|
65
|
+
#
|
|
66
|
+
def serialize_feature_directories_recursively(namespaces)
|
|
67
|
+
namespaces.each do |namespace|
|
|
68
|
+
Templates::Engine.with_serializer(namespace, options[:serializer]) do
|
|
69
|
+
options[:object] = namespace
|
|
70
|
+
T('layout').run(options)
|
|
71
|
+
end
|
|
72
|
+
serialize_feature_directories_recursively(namespace.children.find_all {|child| child.is_a?(YARD::CodeObjects::Cucumber::FeatureDirectory)})
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
# Generate feature list
|
|
78
|
+
# @note this method is called automatically by YARD based on the menus defined in the layout
|
|
79
|
+
def generate_feature_list
|
|
80
|
+
features = Registry.all(:feature)
|
|
81
|
+
features_ordered_by_name = features.sort {|x,y| x.value.to_s <=> y.value.to_s }
|
|
82
|
+
generate_full_list features_ordered_by_name, :features
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
# Generate tag list
|
|
86
|
+
# @note this method is called automatically by YARD based on the menus defined in the layout
|
|
87
|
+
def generate_tag_list
|
|
88
|
+
tags = Registry.all(:tag)
|
|
89
|
+
tags_ordered_by_use = Array(tags).sort {|x,y| y.all_scenarios.size <=> x.all_scenarios.size }
|
|
90
|
+
|
|
91
|
+
generate_full_list tags_ordered_by_use, :tags
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# Generate a step definition list
|
|
95
|
+
# @note this menu is not automatically added until yard configuration has this menu added
|
|
96
|
+
# See the layout template method that loads the menus
|
|
97
|
+
def generate_stepdefinition_list
|
|
98
|
+
generate_full_list YARD::Registry.all(:stepdefinition), :stepdefinitions,
|
|
99
|
+
:list_title => "Step Definitions List"
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
# Generate a step list
|
|
103
|
+
# @note this menu is not automatically added until yard configuration has this menu added
|
|
104
|
+
# See the layout template method that loads the menus
|
|
105
|
+
def generate_step_list
|
|
106
|
+
generate_full_list YARD::Registry.all(:step), :steps
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
# Generate feature list
|
|
110
|
+
# @note this menu is not automatically added until yard configuration has this menu added
|
|
111
|
+
# See the layout template method that loads the menus
|
|
112
|
+
def generate_featuredirectories_list
|
|
113
|
+
directories_ordered_by_name = root_feature_directories.sort {|x,y| x.value.to_s <=> y.value.to_s }
|
|
114
|
+
generate_full_list directories_ordered_by_name, :featuredirectories,
|
|
115
|
+
:list_title => "Features by Directory",
|
|
116
|
+
:list_filename => "featuredirectories_list.html"
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
# Helpler method to generate a full_list page of the specified objects with the
|
|
121
|
+
# specified type.
|
|
122
|
+
def generate_full_list(objects,type,options = {})
|
|
123
|
+
defaults = { :list_title => "#{type.to_s.capitalize} List",
|
|
124
|
+
:css_class => "class",
|
|
125
|
+
:list_filename => "#{type.to_s.gsub(/s$/,'')}_list.html" }
|
|
126
|
+
|
|
127
|
+
options = defaults.merge(options)
|
|
128
|
+
|
|
129
|
+
@items = objects
|
|
130
|
+
@list_type = type
|
|
131
|
+
@list_title = options[:list_title]
|
|
132
|
+
@list_class = options[:css_class]
|
|
133
|
+
asset options[:list_filename], erb(:full_list)
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
#
|
|
137
|
+
# @note This method overrides YARD's default template class_list method.
|
|
138
|
+
#
|
|
139
|
+
# The existing YARD 'Class List' search field contains all the YARD namespace objects.
|
|
140
|
+
# We, however, do not want the Cucumber Namespace YARD Object (which holds the features,
|
|
141
|
+
# tags, etc.) as it is a meta-object.
|
|
142
|
+
#
|
|
143
|
+
# This method removes the namespace from the root node, generates the class list,
|
|
144
|
+
# and then adds it back into the root node.
|
|
145
|
+
#
|
|
146
|
+
def class_list(root = Registry.root)
|
|
147
|
+
return super unless root == Registry.root
|
|
148
|
+
|
|
149
|
+
cucumber_namespace = YARD::CodeObjects::Cucumber::CUCUMBER_NAMESPACE
|
|
150
|
+
root.instance_eval { children.delete cucumber_namespace }
|
|
151
|
+
out = super(root)
|
|
152
|
+
root.instance_eval { children.push cucumber_namespace }
|
|
153
|
+
out
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
#
|
|
157
|
+
# Generate a link to the 'All Features' in the features_list.html
|
|
158
|
+
#
|
|
159
|
+
# When there are no feature directories or multiple top-level feature directories
|
|
160
|
+
# then we want to link to the 'Requirements' page
|
|
161
|
+
#
|
|
162
|
+
# When there are is just one feature directory then we want to link to that directory
|
|
163
|
+
#
|
|
164
|
+
def all_features_link
|
|
165
|
+
if root_feature_directories.length == 0 || root_feature_directories.length > 1
|
|
166
|
+
linkify YARD::CodeObjects::Cucumber::CUCUMBER_NAMESPACE, "All Features"
|
|
167
|
+
else
|
|
168
|
+
linkify root_feature_directories.first, "All Features"
|
|
169
|
+
end
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
def directory_node(directory)
|
|
173
|
+
@directory = directory
|
|
174
|
+
erb(:directories)
|
|
175
|
+
end
|