Merge pull request #50171 from akhilgkrishnan/add-link-to-api-documentation

Add link to API documentation for ActionView helper method [skip ci]
This commit is contained in:
Rafael Mendonça França 2024-01-03 13:41:49 -05:00 committed by GitHub
commit dc581c0cc7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -43,6 +43,8 @@ audio_tag("sound")
# => <audio src="/audios/sound"></audio> # => <audio src="/audios/sound"></audio>
``` ```
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/AssetTagHelper.html#method-i-audio_tag) for more information.
#### auto_discovery_link_tag #### auto_discovery_link_tag
Returns a link tag that browsers and feed readers can use to auto-detect an RSS, Atom, or JSON feed. Returns a link tag that browsers and feed readers can use to auto-detect an RSS, Atom, or JSON feed.
@ -52,6 +54,8 @@ auto_discovery_link_tag(:rss, "http://www.example.com/feed.rss", { title: "RSS F
# => <link rel="alternate" type="application/rss+xml" title="RSS Feed" href="http://www.example.com/feed.rss" /> # => <link rel="alternate" type="application/rss+xml" title="RSS Feed" href="http://www.example.com/feed.rss" />
``` ```
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/AssetTagHelper.html#method-i-auto_discovery_link_tag) for more information.
#### favicon_link_tag #### favicon_link_tag
Returns a link tag for a favicon managed by the asset pipeline. The `source` can be a full path or a file that exists in your assets directory. Returns a link tag for a favicon managed by the asset pipeline. The `source` can be a full path or a file that exists in your assets directory.
@ -61,6 +65,8 @@ favicon_link_tag
# => <link href="/assets/favicon.ico" rel="icon" type="image/x-icon" /> # => <link href="/assets/favicon.ico" rel="icon" type="image/x-icon" />
``` ```
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/AssetTagHelper.html#method-i-favicon_link_tag) for more information.
#### image_path #### image_path
Computes the path to an image asset in the `app/assets/images` directory. Full paths from the document root will be passed through. Used internally by `image_tag` to build the image path. Computes the path to an image asset in the `app/assets/images` directory. Full paths from the document root will be passed through. Used internally by `image_tag` to build the image path.
@ -76,6 +82,8 @@ image_path("edit.png")
# => /assets/edit-2d1a2db63fc738690021fedb5a65b68e.png # => /assets/edit-2d1a2db63fc738690021fedb5a65b68e.png
``` ```
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/AssetUrlHelper.html#method-i-image_path) for more information.
#### image_url #### image_url
Computes the URL to an image asset in the `app/assets/images` directory. This will call `image_path` internally and merge with your current host or your asset host. Computes the URL to an image asset in the `app/assets/images` directory. This will call `image_path` internally and merge with your current host or your asset host.
@ -84,6 +92,8 @@ Computes the URL to an image asset in the `app/assets/images` directory. This wi
image_url("edit.png") # => http://www.example.com/assets/edit.png image_url("edit.png") # => http://www.example.com/assets/edit.png
``` ```
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/AssetUrlHelper.html#method-i-image_url) for more information.
#### image_tag #### image_tag
Returns an HTML image tag for the source. The source can be a full path or a file that exists in your `app/assets/images` directory. Returns an HTML image tag for the source. The source can be a full path or a file that exists in your `app/assets/images` directory.
@ -92,6 +102,8 @@ Returns an HTML image tag for the source. The source can be a full path or a fil
image_tag("icon.png") # => <img src="/assets/icon.png" /> image_tag("icon.png") # => <img src="/assets/icon.png" />
``` ```
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/AssetTagHelper.html#method-i-image_tag) for more information.
#### javascript_include_tag #### javascript_include_tag
Returns an HTML script tag for each of the sources provided. You can pass in the filename (`.js` extension is optional) of JavaScript files that exist in your `app/assets/javascripts` directory for inclusion into the current page or you can pass the full path relative to your document root. Returns an HTML script tag for each of the sources provided. You can pass in the filename (`.js` extension is optional) of JavaScript files that exist in your `app/assets/javascripts` directory for inclusion into the current page or you can pass the full path relative to your document root.
@ -101,6 +113,8 @@ javascript_include_tag "common"
# => <script src="/assets/common.js"></script> # => <script src="/assets/common.js"></script>
``` ```
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/AssetTagHelper.html#method-i-javascript_include_tag) for more information.
#### javascript_path #### javascript_path
Computes the path to a JavaScript asset in the `app/assets/javascripts` directory. If the source filename has no extension, `.js` will be appended. Full paths from the document root will be passed through. Used internally by `javascript_include_tag` to build the script path. Computes the path to a JavaScript asset in the `app/assets/javascripts` directory. If the source filename has no extension, `.js` will be appended. Full paths from the document root will be passed through. Used internally by `javascript_include_tag` to build the script path.
@ -109,6 +123,8 @@ Computes the path to a JavaScript asset in the `app/assets/javascripts` director
javascript_path "common" # => /assets/common.js javascript_path "common" # => /assets/common.js
``` ```
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/AssetUrlHelper.html#method-i-javascript_path) for more information.
#### javascript_url #### javascript_url
Computes the URL to a JavaScript asset in the `app/assets/javascripts` directory. This will call `javascript_path` internally and merge with your current host or your asset host. Computes the URL to a JavaScript asset in the `app/assets/javascripts` directory. This will call `javascript_path` internally and merge with your current host or your asset host.
@ -118,6 +134,8 @@ javascript_url "common"
# => http://www.example.com/assets/common.js # => http://www.example.com/assets/common.js
``` ```
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/AssetUrlHelper.html#method-i-javascript_url) for more information.
#### picture_tag #### picture_tag
Returns an HTML picture tag for the source. It supports passing a String, an Array or a Block. Returns an HTML picture tag for the source. It supports passing a String, an Array or a Block.
@ -136,6 +154,8 @@ This generates the following HTML:
</picture> </picture>
``` ```
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/AssetTagHelper.html#method-i-picture_tag) for more information.
#### preload_link_tag #### preload_link_tag
Returns a link tag that browsers can use to preload the source. The source can be the path of a resource managed by asset pipeline, a full path, or an URI. Returns a link tag that browsers can use to preload the source. The source can be the path of a resource managed by asset pipeline, a full path, or an URI.
@ -145,6 +165,8 @@ preload_link_tag "application.css"
# => <link rel="preload" href="/assets/application.css" as="style" type="text/css" /> # => <link rel="preload" href="/assets/application.css" as="style" type="text/css" />
``` ```
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/AssetTagHelper.html#method-i-preload_link_tag) for more information.
#### stylesheet_link_tag #### stylesheet_link_tag
Returns a stylesheet link tag for the sources specified as arguments. If you don't specify an extension, `.css` will be appended automatically. Returns a stylesheet link tag for the sources specified as arguments. If you don't specify an extension, `.css` will be appended automatically.
@ -154,6 +176,8 @@ stylesheet_link_tag "application"
# => <link href="/assets/application.css" rel="stylesheet" /> # => <link href="/assets/application.css" rel="stylesheet" />
``` ```
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/AssetTagHelper.html#method-i-stylesheet_link_tag) for more information.
#### stylesheet_path #### stylesheet_path
Computes the path to a stylesheet asset in the `app/assets/stylesheets` directory. If the source filename has no extension, `.css` will be appended. Full paths from the document root will be passed through. Used internally by `stylesheet_link_tag` to build the stylesheet path. Computes the path to a stylesheet asset in the `app/assets/stylesheets` directory. If the source filename has no extension, `.css` will be appended. Full paths from the document root will be passed through. Used internally by `stylesheet_link_tag` to build the stylesheet path.
@ -162,6 +186,8 @@ Computes the path to a stylesheet asset in the `app/assets/stylesheets` director
stylesheet_path "application" # => /assets/application.css stylesheet_path "application" # => /assets/application.css
``` ```
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/AssetUrlHelper.html#method-i-stylesheet_path) for more information.
#### stylesheet_url #### stylesheet_url
Computes the URL to a stylesheet asset in the `app/assets/stylesheets` directory. This will call `stylesheet_path` internally and merge with your current host or your asset host. Computes the URL to a stylesheet asset in the `app/assets/stylesheets` directory. This will call `stylesheet_path` internally and merge with your current host or your asset host.
@ -171,6 +197,8 @@ stylesheet_url "application"
# => http://www.example.com/assets/application.css # => http://www.example.com/assets/application.css
``` ```
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/AssetUrlHelper.html#method-i-stylesheet_path) for more information.
#### video_tag #### video_tag
Generate an HTML video tag with source(s), either as a single tag for a string source or nested source tags within an array for multiple sources. The `sources` can be full paths, files in your public videos directory, or Active Storage attachments. Generate an HTML video tag with source(s), either as a single tag for a string source or nested source tags within an array for multiple sources. The `sources` can be full paths, files in your public videos directory, or Active Storage attachments.
@ -180,6 +208,8 @@ video_tag("trailer")
# => <video src="/videos/trailer"></video> # => <video src="/videos/trailer"></video>
``` ```
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/AssetTagHelper.html#method-i-video_tag) for more information.
### AtomFeedHelper ### AtomFeedHelper
#### atom_feed #### atom_feed
@ -225,6 +255,8 @@ atom_feed do |feed|
end end
``` ```
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/AtomFeedHelper.html#method-i-atom_feed) for more information.
### BenchmarkHelper ### BenchmarkHelper
#### benchmark #### benchmark
@ -239,6 +271,8 @@ Allows you to measure the execution time of a block in a template and records th
This would add something like "Process data files (0.34523)" to the log, which you can then use to compare timings when optimizing your code. This would add something like "Process data files (0.34523)" to the log, which you can then use to compare timings when optimizing your code.
See the [API Documentation](https://api.rubyonrails.org/classes/ActiveSupport/Benchmarkable.html#method-i-benchmark) for more information.
### CacheHelper ### CacheHelper
#### cache #### cache
@ -253,6 +287,8 @@ A method for caching fragments of a view rather than an entire action or page. T
[`AbstractController::Caching::Fragments`]: https://api.rubyonrails.org/classes/AbstractController/Caching/Fragments.html [`AbstractController::Caching::Fragments`]: https://api.rubyonrails.org/classes/AbstractController/Caching/Fragments.html
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/CacheHelper.html#method-i-cache) for more information.
### CaptureHelper ### CaptureHelper
#### capture #### capture
@ -278,6 +314,8 @@ The captured variable can then be used anywhere else.
</html> </html>
``` ```
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/CaptureHelper.html#method-i-capture) for more information.
#### content_for #### content_for
Calling `content_for` stores a block of markup in an identifier for later use. You can make subsequent calls to the stored content in other templates or the layout by passing the identifier as an argument to `yield`. Calling `content_for` stores a block of markup in an identifier for later use. You can make subsequent calls to the stored content in other templates or the layout by passing the identifier as an argument to `yield`.
@ -308,6 +346,8 @@ For example, let's say we have a standard application layout, but also a special
<% end %> <% end %>
``` ```
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/CaptureHelper.html#method-i-content_for) for more information.
### DateHelper ### DateHelper
#### distance_of_time_in_words #### distance_of_time_in_words
@ -321,6 +361,8 @@ distance_of_time_in_words(Time.now, Time.now + 15.seconds, include_seconds: true
# => less than 20 seconds # => less than 20 seconds
``` ```
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/DateHelper.html#method-i-distance_of_time_in_words) for more information.
#### time_ago_in_words #### time_ago_in_words
Like `distance_of_time_in_words`, but where `to_time` is fixed to `Time.now`. Like `distance_of_time_in_words`, but where `to_time` is fixed to `Time.now`.
@ -329,8 +371,12 @@ Like `distance_of_time_in_words`, but where `to_time` is fixed to `Time.now`.
time_ago_in_words(3.minutes.from_now) # => 3 minutes time_ago_in_words(3.minutes.from_now) # => 3 minutes
``` ```
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/DateHelper.html#method-i-time_ago_in_words) for more information.
### DebugHelper ### DebugHelper
#### debug
Returns a `pre` tag that has object dumped by YAML. This creates a very readable way to inspect an object. Returns a `pre` tag that has object dumped by YAML. This creates a very readable way to inspect an object.
```ruby ```ruby
@ -349,6 +395,8 @@ third:
</pre> </pre>
``` ```
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/DebugHelper.html#method-i-debug) for more information.
### FormHelper ### FormHelper
Form helpers are designed to make working with models much easier compared to using just standard HTML elements by providing a set of methods for creating forms based on your models. This helper generates the HTML for forms, providing a method for each sort of input (e.g., text, password, select, and so on). When the form is submitted (i.e., when the user hits the submit button or form.submit is called via JavaScript), the form inputs will be bundled into the params object and passed back to the controller. Form helpers are designed to make working with models much easier compared to using just standard HTML elements by providing a set of methods for creating forms based on your models. This helper generates the HTML for forms, providing a method for each sort of input (e.g., text, password, select, and so on). When the form is submitted (i.e., when the user hits the submit button or form.submit is called via JavaScript), the form inputs will be bundled into the params object and passed back to the controller.
@ -380,6 +428,8 @@ alert('All is good')
</script> </script>
``` ```
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/JavaScriptHelper.html#method-i-javascript_tag) for more information.
### NumberHelper ### NumberHelper
Provides methods for converting numbers into formatted strings. Methods are provided for phone numbers, currency, percentage, precision, positional notation, and file size. Provides methods for converting numbers into formatted strings. Methods are provided for phone numbers, currency, percentage, precision, positional notation, and file size.
@ -392,6 +442,8 @@ Formats a number into a currency string (e.g., $13.65).
number_to_currency(1234567890.50) # => $1,234,567,890.50 number_to_currency(1234567890.50) # => $1,234,567,890.50
``` ```
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/NumberHelper.html#method-i-number_to_currency) for more information.
#### number_to_human #### number_to_human
Pretty prints (formats and approximates) a number so it is more readable by users; useful for numbers that can get very large. Pretty prints (formats and approximates) a number so it is more readable by users; useful for numbers that can get very large.
@ -401,6 +453,8 @@ number_to_human(1234) # => 1.23 Thousand
number_to_human(1234567) # => 1.23 Million number_to_human(1234567) # => 1.23 Million
``` ```
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/NumberHelper.html#method-i-number_to_human) for more information.
#### number_to_human_size #### number_to_human_size
Formats the bytes in size into a more understandable representation; useful for reporting file sizes to users. Formats the bytes in size into a more understandable representation; useful for reporting file sizes to users.
@ -410,6 +464,8 @@ number_to_human_size(1234) # => 1.21 KB
number_to_human_size(1234567) # => 1.18 MB number_to_human_size(1234567) # => 1.18 MB
``` ```
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/NumberHelper.html#method-i-number_to_human_size) for more information.
#### number_to_percentage #### number_to_percentage
Formats a number as a percentage string. Formats a number as a percentage string.
@ -418,6 +474,8 @@ Formats a number as a percentage string.
number_to_percentage(100, precision: 0) # => 100% number_to_percentage(100, precision: 0) # => 100%
``` ```
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/NumberHelper.html#method-i-number_to_percentage) for more information.
#### number_to_phone #### number_to_phone
Formats a number into a phone number (US by default). Formats a number into a phone number (US by default).
@ -426,6 +484,8 @@ Formats a number into a phone number (US by default).
number_to_phone(1235551234) # => 123-555-1234 number_to_phone(1235551234) # => 123-555-1234
``` ```
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/NumberHelper.html#method-i-number_to_phone) for more information.
#### number_with_delimiter #### number_with_delimiter
Formats a number with grouped thousands using a delimiter. Formats a number with grouped thousands using a delimiter.
@ -434,6 +494,8 @@ Formats a number with grouped thousands using a delimiter.
number_with_delimiter(12345678) # => 12,345,678 number_with_delimiter(12345678) # => 12,345,678
``` ```
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/NumberHelper.html#method-i-number_with_delimiter) for more information.
#### number_with_precision #### number_with_precision
Formats a number with the specified level of `precision`, which defaults to 3. Formats a number with the specified level of `precision`, which defaults to 3.
@ -443,6 +505,8 @@ number_with_precision(111.2345) # => 111.235
number_with_precision(111.2345, precision: 2) # => 111.23 number_with_precision(111.2345, precision: 2) # => 111.23
``` ```
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/NumberHelper.html#method-i-number_with_precision) for more information.
### SanitizeHelper ### SanitizeHelper
The SanitizeHelper module provides a set of methods for scrubbing text of undesired HTML elements. The SanitizeHelper module provides a set of methods for scrubbing text of undesired HTML elements.
@ -469,10 +533,14 @@ class Application < Rails::Application
end end
``` ```
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/SanitizeHelper.html#method-i-sanitize) for more information.
#### sanitize_css(style) #### sanitize_css(style)
Sanitizes a block of CSS code. Sanitizes a block of CSS code.
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/SanitizeHelper.html#method-i-sanitize_css) for more information.
#### strip_links(html) #### strip_links(html)
Strips all link tags from text leaving just the link text. Strips all link tags from text leaving just the link text.
@ -492,6 +560,8 @@ strip_links('Blog: <a href="http://myblog.com/">Visit</a>.')
# => Blog: Visit. # => Blog: Visit.
``` ```
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/SanitizeHelper.html#method-i-strip_links) for more information.
#### strip_tags(html) #### strip_tags(html)
Strips all HTML tags from the html, including comments. Strips all HTML tags from the html, including comments.
@ -509,6 +579,8 @@ strip_tags("<b>Bold</b> no more! <a href='more.html'>See more</a>")
NB: The output may still contain unescaped '<', '>', '&' characters and confuse browsers. NB: The output may still contain unescaped '<', '>', '&' characters and confuse browsers.
See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/SanitizeHelper.html#method-i-strip_tags) for more information.
### UrlHelper ### UrlHelper
Provides methods to make links and get URLs that depend on the routing subsystem. Provides methods to make links and get URLs that depend on the routing subsystem.
@ -562,7 +634,7 @@ would output:
</a> </a>
``` ```
See [the API Documentation for more information](https://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-link_to) See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-link_to) for more information.
#### button_to #### button_to
@ -583,7 +655,7 @@ would roughly output something like:
</form> </form>
``` ```
See [the API Documentation for more information](https://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-button_to) See the [API Documentation](https://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-button_to) for more information.
### CsrfHelper ### CsrfHelper