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.
This commit is contained in:
Jonathan Hefner 2024-01-07 16:15:44 -06:00
parent c0b5052d92
commit d1411b2018
5 changed files with 35 additions and 4 deletions

@ -1121,6 +1121,8 @@ def fields(scope = nil, model: nil, **options, &block)
# post:
# cost: "Total cost"
#
# <code></code>
#
# label(:post, :cost)
# # => <label for="post_cost">Total cost</label>
#
@ -2365,6 +2367,8 @@ def fields(scope = nil, model: nil, **options, &block)
# post:
# cost: "Total cost"
#
# <code></code>
#
# label(:cost)
# # => <label for="post_cost">Total cost</label>
#

@ -60,6 +60,8 @@ module SanitizeHelper
# end
# end
#
# <code></code>
#
# <%= sanitize @comment.body, scrubber: CommentScrubber.new %>
#
# See {Rails HTML Sanitizer}[https://github.com/rails/rails-html-sanitizer] for
@ -71,6 +73,8 @@ module SanitizeHelper
# node.remove if node.name == 'script'
# end
#
# <code></code>
#
# <%= sanitize @comment.body, scrubber: scrubber %>
#
# See {Loofah's documentation}[https://github.com/flavorjones/loofah] for more

@ -268,6 +268,8 @@ class FixtureClassNotFound < ActiveRecord::ActiveRecordError # :nodoc:
# name: Reginald the Pirate
# monkey_id: 1
#
# <code></code>
#
# ### in monkeys.yml
#
# george:
@ -285,6 +287,8 @@ class FixtureClassNotFound < ActiveRecord::ActiveRecordError # :nodoc:
# name: Reginald the Pirate
# monkey: george
#
# <code></code>
#
# ### in monkeys.yml
#
# george:
@ -306,6 +310,8 @@ class FixtureClassNotFound < ActiveRecord::ActiveRecordError # :nodoc:
#
# belongs_to :eater, polymorphic: true
#
# <code></code>
#
# ### in fruits.yml
#
# apple:
@ -331,6 +337,8 @@ class FixtureClassNotFound < ActiveRecord::ActiveRecordError # :nodoc:
# id: 1
# name: George the Monkey
#
# <code></code>
#
# ### in fruits.yml
#
# apple:
@ -345,6 +353,8 @@ class FixtureClassNotFound < ActiveRecord::ActiveRecordError # :nodoc:
# id: 3
# name: grape
#
# <code></code>
#
# ### in fruits_monkeys.yml
#
# apple_george:
@ -368,6 +378,8 @@ class FixtureClassNotFound < ActiveRecord::ActiveRecordError # :nodoc:
# name: George the Monkey
# fruits: apple, orange, grape
#
# <code></code>
#
# ### in fruits.yml
#
# apple:
@ -467,6 +479,8 @@ class FixtureClassNotFound < ActiveRecord::ActiveRecordError # :nodoc:
# belongs_to :author
# end
#
# <code></code>
#
# # books.yml
# alices_adventure_in_wonderland:
# author_id: <%= ActiveRecord::FixtureSet.identify(:lewis_carroll) %>
@ -482,6 +496,8 @@ class FixtureClassNotFound < ActiveRecord::ActiveRecordError # :nodoc:
# belongs_to :book, query_constraints: [:author_id, :book_id]
# end
#
# <code></code>
#
# # book_orders.yml
# alices_adventure_in_wonderland_in_books:
# author: lewis_carroll

@ -26,9 +26,13 @@ module ActiveStorage
# has_one_attached :thumbnail
# end
#
# <code></code>
#
# # fixtures/active_storage/blobs.yml
# first_thumbnail_blob: <%= ActiveStorage::FixtureSet.blob filename: "first.png" %>
#
# <code></code>
#
# # fixtures/active_storage/attachments.yml
# first_thumbnail_attachment:
# name: thumbnail

@ -234,8 +234,7 @@ def deprecators
end
# Convenience for loading config/foo.yml for the current \Rails env.
#
# Examples:
# Example:
#
# # config/exception_notification.yml:
# production:
@ -246,13 +245,15 @@ def deprecators
# url: http://localhost:3001
# namespace: my_app_development
#
# <code></code>
#
# # config/environments/production.rb
# Rails.application.configure do
# config.middleware.use ExceptionNotifier, config_for(:exception_notification)
# end
#
# # You can also store configurations in a shared section which will be
# # merged with the environment configuration
# You can also store configurations in a shared section which will be merged
# with the environment configuration
#
# # config/example.yml
# shared:
@ -265,6 +266,8 @@ def deprecators
# bar:
# qux: 2
#
# <code></code>
#
# # development environment
# Rails.application.config_for(:example)[:foo][:bar]
# # => { baz: 1, qux: 2 }