Skip to content

Commit d1411b2

Browse files
Split up code blocks for multi-file examples [ci-skip]
RDoc treats consecutive indented lines as a single code block. For code examples that span multiple files / languages, this confuses the syntax highlighter and makes the examples harder to read. Unfortunately, RDoc doesn't provide syntax to prevent this, and it ignores multiple consecutive blank lines. However, by inserting an empty tag such as `<code></code>`, we can force RDoc to recognize separate code blocks.
1 parent c0b5052 commit d1411b2

File tree

5 files changed

+35
-4
lines changed

5 files changed

+35
-4
lines changed

actionview/lib/action_view/helpers/form_helper.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,6 +1121,8 @@ def fields(scope = nil, model: nil, **options, &block)
11211121
# post:
11221122
# cost: "Total cost"
11231123
#
1124+
# <code></code>
1125+
#
11241126
# label(:post, :cost)
11251127
# # => <label for="post_cost">Total cost</label>
11261128
#
@@ -2365,6 +2367,8 @@ def fields(scope = nil, model: nil, **options, &block)
23652367
# post:
23662368
# cost: "Total cost"
23672369
#
2370+
# <code></code>
2371+
#
23682372
# label(:cost)
23692373
# # => <label for="post_cost">Total cost</label>
23702374
#

actionview/lib/action_view/helpers/sanitize_helper.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ module SanitizeHelper
6060
# end
6161
# end
6262
#
63+
# <code></code>
64+
#
6365
# <%= sanitize @comment.body, scrubber: CommentScrubber.new %>
6466
#
6567
# See {Rails HTML Sanitizer}[https://github.com/rails/rails-html-sanitizer] for
@@ -71,6 +73,8 @@ module SanitizeHelper
7173
# node.remove if node.name == 'script'
7274
# end
7375
#
76+
# <code></code>
77+
#
7478
# <%= sanitize @comment.body, scrubber: scrubber %>
7579
#
7680
# See {Loofah's documentation}[https://github.com/flavorjones/loofah] for more

activerecord/lib/active_record/fixtures.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,8 @@ class FixtureClassNotFound < ActiveRecord::ActiveRecordError # :nodoc:
268268
# name: Reginald the Pirate
269269
# monkey_id: 1
270270
#
271+
# <code></code>
272+
#
271273
# ### in monkeys.yml
272274
#
273275
# george:
@@ -285,6 +287,8 @@ class FixtureClassNotFound < ActiveRecord::ActiveRecordError # :nodoc:
285287
# name: Reginald the Pirate
286288
# monkey: george
287289
#
290+
# <code></code>
291+
#
288292
# ### in monkeys.yml
289293
#
290294
# george:
@@ -306,6 +310,8 @@ class FixtureClassNotFound < ActiveRecord::ActiveRecordError # :nodoc:
306310
#
307311
# belongs_to :eater, polymorphic: true
308312
#
313+
# <code></code>
314+
#
309315
# ### in fruits.yml
310316
#
311317
# apple:
@@ -331,6 +337,8 @@ class FixtureClassNotFound < ActiveRecord::ActiveRecordError # :nodoc:
331337
# id: 1
332338
# name: George the Monkey
333339
#
340+
# <code></code>
341+
#
334342
# ### in fruits.yml
335343
#
336344
# apple:
@@ -345,6 +353,8 @@ class FixtureClassNotFound < ActiveRecord::ActiveRecordError # :nodoc:
345353
# id: 3
346354
# name: grape
347355
#
356+
# <code></code>
357+
#
348358
# ### in fruits_monkeys.yml
349359
#
350360
# apple_george:
@@ -368,6 +378,8 @@ class FixtureClassNotFound < ActiveRecord::ActiveRecordError # :nodoc:
368378
# name: George the Monkey
369379
# fruits: apple, orange, grape
370380
#
381+
# <code></code>
382+
#
371383
# ### in fruits.yml
372384
#
373385
# apple:
@@ -467,6 +479,8 @@ class FixtureClassNotFound < ActiveRecord::ActiveRecordError # :nodoc:
467479
# belongs_to :author
468480
# end
469481
#
482+
# <code></code>
483+
#
470484
# # books.yml
471485
# alices_adventure_in_wonderland:
472486
# author_id: <%= ActiveRecord::FixtureSet.identify(:lewis_carroll) %>
@@ -482,6 +496,8 @@ class FixtureClassNotFound < ActiveRecord::ActiveRecordError # :nodoc:
482496
# belongs_to :book, query_constraints: [:author_id, :book_id]
483497
# end
484498
#
499+
# <code></code>
500+
#
485501
# # book_orders.yml
486502
# alices_adventure_in_wonderland_in_books:
487503
# author: lewis_carroll

activestorage/lib/active_storage/fixture_set.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,13 @@ module ActiveStorage
2626
# has_one_attached :thumbnail
2727
# end
2828
#
29+
# <code></code>
30+
#
2931
# # fixtures/active_storage/blobs.yml
3032
# first_thumbnail_blob: <%= ActiveStorage::FixtureSet.blob filename: "first.png" %>
3133
#
34+
# <code></code>
35+
#
3236
# # fixtures/active_storage/attachments.yml
3337
# first_thumbnail_attachment:
3438
# name: thumbnail

railties/lib/rails/application.rb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,7 @@ def deprecators
234234
end
235235

236236
# Convenience for loading config/foo.yml for the current \Rails env.
237-
#
238-
# Examples:
237+
# Example:
239238
#
240239
# # config/exception_notification.yml:
241240
# production:
@@ -246,13 +245,15 @@ def deprecators
246245
# url: http://localhost:3001
247246
# namespace: my_app_development
248247
#
248+
# <code></code>
249+
#
249250
# # config/environments/production.rb
250251
# Rails.application.configure do
251252
# config.middleware.use ExceptionNotifier, config_for(:exception_notification)
252253
# end
253254
#
254-
# # You can also store configurations in a shared section which will be
255-
# # merged with the environment configuration
255+
# You can also store configurations in a shared section which will be merged
256+
# with the environment configuration
256257
#
257258
# # config/example.yml
258259
# shared:
@@ -265,6 +266,8 @@ def deprecators
265266
# bar:
266267
# qux: 2
267268
#
269+
# <code></code>
270+
#
268271
# # development environment
269272
# Rails.application.config_for(:example)[:foo][:bar]
270273
# # => { baz: 1, qux: 2 }

0 commit comments

Comments
 (0)