Skip to content

Commit 4da49fa

Browse files
authored
Merge pull request rails#46513 from p8/actionview/fix-code-example-indentation
Use 2 spaces for identation in ActionView code examples [ci-skip]
2 parents 98bbfc0 + 482d94c commit 4da49fa

File tree

4 files changed

+67
-55
lines changed

4 files changed

+67
-55
lines changed

actionview/lib/action_view/helpers/capture_helper.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def capture(*args)
127127
# <li><%= link_to 'Home', action: 'index' %></li>
128128
# <% end %>
129129
#
130-
# And in another place:
130+
# And in another place:
131131
#
132132
# <% content_for :navigation do %>
133133
# <li><%= link_to 'Login', action: 'login' %></li>
@@ -143,7 +143,7 @@ def capture(*args)
143143
# <li><%= link_to 'Home', action: 'index' %></li>
144144
# <% end %>
145145
#
146-
# <%# Add some other content, or use a different template: %>
146+
# <%# Add some other content, or use a different template: %>
147147
#
148148
# <% content_for :navigation, flush: true do %>
149149
# <li><%= link_to 'Login', action: 'login' %></li>

actionview/lib/action_view/helpers/date_helper.rb

Lines changed: 52 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,22 +1001,25 @@ def build_options_and_select(type, selected, options = {})
10011001
end
10021002

10031003
# Build select option HTML from date value and options.
1004-
# build_options(15, start: 1, end: 31)
1005-
# => "<option value="1">1</option>
1006-
# <option value="2">2</option>
1007-
# <option value="3">3</option>..."
10081004
#
1009-
# If <tt>use_two_digit_numbers: true</tt> option is passed
1010-
# build_options(15, start: 1, end: 31, use_two_digit_numbers: true)
1011-
# => "<option value="1">01</option>
1012-
# <option value="2">02</option>
1013-
# <option value="3">03</option>..."
1005+
# build_options(15, start: 1, end: 31)
1006+
# => "<option value="1">1</option>
1007+
# <option value="2">2</option>
1008+
# <option value="3">3</option>..."
10141009
#
1015-
# If <tt>:step</tt> options is passed
1016-
# build_options(15, start: 1, end: 31, step: 2)
1017-
# => "<option value="1">1</option>
1018-
# <option value="3">3</option>
1019-
# <option value="5">5</option>..."
1010+
# If <tt>use_two_digit_numbers: true</tt> option is passed:
1011+
#
1012+
# build_options(15, start: 1, end: 31, use_two_digit_numbers: true)
1013+
# => "<option value="1">01</option>
1014+
# <option value="2">02</option>
1015+
# <option value="3">03</option>..."
1016+
#
1017+
# If <tt>:step</tt> options is passed:
1018+
#
1019+
# build_options(15, start: 1, end: 31, step: 2)
1020+
# => "<option value="1">1</option>
1021+
# <option value="3">3</option>
1022+
# <option value="5">5</option>..."
10201023
def build_options(selected, options = {})
10211024
options = {
10221025
leading_zeros: true, ampm: false, use_two_digit_numbers: false
@@ -1041,22 +1044,25 @@ def build_options(selected, options = {})
10411044
end
10421045

10431046
# Build select option HTML for day.
1044-
# build_day_options(2)
1045-
# => "<option value="1">1</option>
1046-
# <option value="2" selected="selected">2</option>
1047-
# <option value="3">3</option>..."
1047+
#
1048+
# build_day_options(2)
1049+
# => "<option value="1">1</option>
1050+
# <option value="2" selected="selected">2</option>
1051+
# <option value="3">3</option>..."
10481052
#
10491053
# If <tt>day_format: ->(day) { day.ordinalize }</tt> option is passed to DateTimeSelector
1050-
# build_day_options(2)
1051-
# => "<option value="1">1st</option>
1052-
# <option value="2" selected="selected">2nd</option>
1053-
# <option value="3">3rd</option>..."
1054+
#
1055+
# build_day_options(2)
1056+
# => "<option value="1">1st</option>
1057+
# <option value="2" selected="selected">2nd</option>
1058+
# <option value="3">3rd</option>..."
10541059
#
10551060
# If <tt>use_two_digit_numbers: true</tt> option is passed to DateTimeSelector
1056-
# build_day_options(2)
1057-
# => "<option value="1">01</option>
1058-
# <option value="2" selected="selected">02</option>
1059-
# <option value="3">03</option>..."
1061+
#
1062+
# build_day_options(2)
1063+
# => "<option value="1">01</option>
1064+
# <option value="2" selected="selected">02</option>
1065+
# <option value="3">03</option>..."
10601066
def build_day_options(selected)
10611067
select_options = []
10621068
(1..31).each do |value|
@@ -1070,10 +1076,11 @@ def build_day_options(selected)
10701076
end
10711077

10721078
# Build select option HTML for year.
1073-
# build_year_options(1998, start: 1998, end: 2000)
1074-
# => "<option value="1998" selected="selected">1998</option>
1075-
# <option value="1999">1999</option>
1076-
# <option value="2000">2000</option>"
1079+
#
1080+
# build_year_options(1998, start: 1998, end: 2000)
1081+
# => "<option value="1998" selected="selected">1998</option>
1082+
# <option value="1999">1999</option>
1083+
# <option value="2000">2000</option>"
10771084
def build_year_options(selected, options = {})
10781085
start = options.delete(:start)
10791086
stop = options.delete(:end)
@@ -1091,10 +1098,11 @@ def build_year_options(selected, options = {})
10911098
end
10921099

10931100
# Builds select tag from date type and HTML select options.
1094-
# build_select(:month, "<option value="1">January</option>...")
1095-
# => "<select id="post_written_on_2i" name="post[written_on(2i)]">
1096-
# <option value="1">January</option>...
1097-
# </select>"
1101+
#
1102+
# build_select(:month, "<option value="1">January</option>...")
1103+
# => "<select id="post_written_on_2i" name="post[written_on(2i)]">
1104+
# <option value="1">January</option>...
1105+
# </select>"
10981106
def build_select(type, select_options_as_html)
10991107
select_options = {
11001108
id: input_id_from_type(type),
@@ -1111,9 +1119,10 @@ def build_select(type, select_options_as_html)
11111119
(content_tag("select", select_html.html_safe, select_options) + "\n").html_safe
11121120
end
11131121

1114-
# Builds the CSS class value for the select element
1115-
# css_class_attribute(:year, 'date optional', { year: 'my-year' })
1116-
# => "date optional my-year"
1122+
# Builds the CSS class value for the select element.
1123+
#
1124+
# css_class_attribute(:year, 'date optional', { year: 'my-year' })
1125+
# => "date optional my-year"
11171126
def css_class_attribute(type, html_options_class, options) # :nodoc:
11181127
css_class = \
11191128
case options
@@ -1127,8 +1136,9 @@ def css_class_attribute(type, html_options_class, options) # :nodoc:
11271136
end
11281137

11291138
# Builds a prompt option tag with supplied options or from default options.
1130-
# prompt_option_tag(:month, prompt: 'Select month')
1131-
# => "<option value="">Select month</option>"
1139+
#
1140+
# prompt_option_tag(:month, prompt: 'Select month')
1141+
# => "<option value="">Select month</option>"
11321142
def prompt_option_tag(type, options)
11331143
prompt = \
11341144
case options
@@ -1145,8 +1155,9 @@ def prompt_option_tag(type, options)
11451155
end
11461156

11471157
# Builds hidden input tag for date part and value.
1148-
# build_hidden(:year, 2008)
1149-
# => "<input type="hidden" id="date_year" name="date[year]" value="2008" autocomplete="off" />"
1158+
#
1159+
# build_hidden(:year, 2008)
1160+
# => "<input type="hidden" id="date_year" name="date[year]" value="2008" autocomplete="off" />"
11501161
def build_hidden(type, value)
11511162
select_options = {
11521163
type: "hidden",

actionview/lib/action_view/helpers/number_helper.rb

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ def number_to_percentage(number, options = {})
202202
# number_with_delimiter("123456.78",
203203
# delimiter_pattern: /(\d+?)(?=(\d\d)+(\d)(?!\d))/) # => "1,23,456.78"
204204
#
205-
# number_with_delimiter("112a", raise: true) # => raise InvalidNumberError
205+
# number_with_delimiter("112a", raise: true) # => raise InvalidNumberError
206206
def number_with_delimiter(number, options = {})
207207
delegate_number_helper_method(:number_to_delimited, number, options)
208208
end
@@ -370,13 +370,14 @@ def number_to_human_size(number, options = {})
370370
# out by default (set <tt>:strip_insignificant_zeros</tt> to
371371
# +false+ to change that):
372372
#
373-
# number_to_human(12.00001) # => "12"
374-
# number_to_human(12.00001, strip_insignificant_zeros: false) # => "12.0"
373+
# number_to_human(12.00001) # => "12"
374+
# number_to_human(12.00001, strip_insignificant_zeros: false) # => "12.0"
375375
#
376376
# ==== Custom Unit Quantifiers
377377
#
378378
# You can also use your own custom unit quantifiers:
379-
# number_to_human(500000, units: {unit: "ml", thousand: "lt"}) # => "500 lt"
379+
#
380+
# number_to_human(500000, units: {unit: "ml", thousand: "lt"}) # => "500 lt"
380381
#
381382
# If in your I18n locale you have:
382383
# distance:
@@ -393,12 +394,12 @@ def number_to_human_size(number, options = {})
393394
#
394395
# Then you could do:
395396
#
396-
# number_to_human(543934, units: :distance) # => "544 kilometers"
397-
# number_to_human(54393498, units: :distance) # => "54400 kilometers"
398-
# number_to_human(54393498000, units: :distance) # => "54.4 gazillion-distance"
399-
# number_to_human(343, units: :distance, precision: 1) # => "300 meters"
400-
# number_to_human(1, units: :distance) # => "1 meter"
401-
# number_to_human(0.34, units: :distance) # => "34 centimeters"
397+
# number_to_human(543934, units: :distance) # => "544 kilometers"
398+
# number_to_human(54393498, units: :distance) # => "54400 kilometers"
399+
# number_to_human(54393498000, units: :distance) # => "54.4 gazillion-distance"
400+
# number_to_human(343, units: :distance, precision: 1) # => "300 meters"
401+
# number_to_human(1, units: :distance) # => "1 meter"
402+
# number_to_human(0.34, units: :distance) # => "34 centimeters"
402403
#
403404
def number_to_human(number, options = {})
404405
delegate_number_helper_method(:number_to_human, number, options)

actionview/lib/action_view/helpers/output_safety_helper.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ module OutputSafetyHelper
1313
#
1414
# For example:
1515
#
16-
# raw @user.name
17-
# # => 'Jimmy <alert>Tables</alert>'
16+
# raw @user.name
17+
# # => 'Jimmy <alert>Tables</alert>'
1818
def raw(stringish)
1919
stringish.to_s.html_safe
2020
end

0 commit comments

Comments
 (0)