Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix API docs #447

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 17 additions & 16 deletions lib/hanami/action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ def self.gem_loader
# config.format :json
# end
#
# @return [Config]
# @return [Config]
#
# @api public
# @since 2.0.0
# @since 2.0.0
# @api public

# @!scope instance

Expand Down Expand Up @@ -138,7 +138,7 @@ def self.params(_klass = nil)
"To use `params`, please add 'hanami/validations' gem to your Gemfile"
end

# @overload self.append_before(*callbacks, &block)
# @overload append_before(*callbacks, &block)
# Define a callback for an Action.
# The callback will be executed **before** the action is called, in the
# order they are added.
Expand All @@ -153,7 +153,7 @@ def self.params(_klass = nil)
#
# @since 0.3.2
#
# @see Hanami::Action::Callbacks::ClassMethods#append_after
# @see Action#append_after
#
# @example Method names (symbols)
# require "hanami/controller"
Expand Down Expand Up @@ -206,7 +206,7 @@ class << self
alias_method :before, :append_before
end

# @overload self.append_after(*callbacks, &block)
# @overload append_after(*callbacks, &block)
# Define a callback for an Action.
# The callback will be executed **after** the action is called, in the
# order they are added.
Expand All @@ -221,7 +221,7 @@ class << self
#
# @since 0.3.2
#
# @see Hanami::Action::Callbacks::ClassMethods#append_before
# @see Action#append_before
def self.append_after(...)
config.after_callbacks.append(...)
end
Expand All @@ -231,7 +231,7 @@ class << self
alias_method :after, :append_after
end

# @overload self.prepend_before(*callbacks, &block)
# @overload prepend_before(*callbacks, &block)
# Define a callback for an Action.
# The callback will be executed **before** the action is called.
# It will add the callback at the beginning of the callbacks' chain.
Expand All @@ -246,12 +246,12 @@ class << self
#
# @since 0.3.2
#
# @see Hanami::Action::Callbacks::ClassMethods#prepend_after
# @see Action#prepend_after
def self.prepend_before(...)
config.before_callbacks.prepend(...)
end

# @overload self.prepend_after(*callbacks, &block)
# @overload prepend_after(*callbacks, &block)
# Define a callback for an Action.
# The callback will be executed **after** the action is called.
# It will add the callback at the beginning of the callbacks' chain.
Expand All @@ -266,7 +266,7 @@ def self.prepend_before(...)
#
# @since 0.3.2
#
# @see Hanami::Action::Callbacks::ClassMethods#prepend_before
# @see Action#prepend_before
def self.prepend_after(...)
config.after_callbacks.prepend(...)
end
Expand Down Expand Up @@ -334,11 +334,14 @@ def call(env)

protected

# Hook for subclasses to apply behavior as part of action invocation
# Hook for subclasses to apply behavior as part of action invocation.
#
# This is the method you'll implement in your actions.
#
# @param request [Hanami::Action::Request]
# @param response [Hanami::Action::Response]
#
# @abstract
# @since 2.0.0
# @api public
def handle(request, response)
Expand All @@ -361,8 +364,8 @@ def handle(request, response)
#
# @since 0.2.0
#
# @see Hanami::Action::Throwable#handle_exception
# @see Hanami::Http::Status:ALL
# @see Hanami::Action.handle_exception
# @see https://rubydoc.info/github/rack/rack/Rack/Utils
#
# @example Basic usage
# require "hanami/controller"
Expand Down Expand Up @@ -525,8 +528,6 @@ def _run_after_callbacks(*args)
#
# @since 0.5.0
#
# @see Hanami::Action#_requires_no_body?
#
# @example
# require "hanami/controller"
#
Expand Down
7 changes: 4 additions & 3 deletions lib/hanami/action/cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ class Action
# Cache type API
#
# @since 0.3.0
# @api private
#
# @see Hanami::Action::Cache::ClassMethods#cache_control
# @see Hanami::Action::Cache::ClassMethods#expires
# @see Hanami::Action::Cache::ClassMethods#fresh
# @see Hanami::Action::Response#cache_control
# @see Hanami::Action::Response#expires
# @see Hanami::Action::Response#fresh
module Cache
# Override Ruby's hook for modules.
# It includes exposures logic
Expand Down
4 changes: 1 addition & 3 deletions lib/hanami/action/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,13 @@ def format(*formats)

# @!attribute [rw] root_directory
#
# Sets the the for the public directory, which is used for file downloads.
# Sets the the root directory for the public directory, which is used for file downloads.
# This must be an existent directory.
#
# Defaults to the current working directory.
#
# @return [String] the directory path
#
# @api private
#
# @since 1.0.0

# @!attribute [rw] public_directory
Expand Down
2 changes: 1 addition & 1 deletion lib/hanami/action/cookie_jar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Action
#
# @since 0.1.0
#
# @see Hanami::Action::Cookies#cookies
# @see Hanami::Action::Response#cookies
class CookieJar
# @since 0.4.5
# @api private
Expand Down
5 changes: 3 additions & 2 deletions lib/hanami/action/cookies.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ module Hanami
class Action
# Cookies API
#
# This module isn't included by default.
# If you want cookies in your actions then include this module.
# It's not included by default.
#
# @since 0.1.0
#
# @see Hanami::Action::Cookies#cookies
# @see Hanami::Action::Response#cookies
module Cookies
private

Expand Down
5 changes: 2 additions & 3 deletions lib/hanami/action/csrf_protection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
require_relative "errors"

module Hanami
# @api private
class Action
# CSRF Protection
#
Expand All @@ -30,8 +29,8 @@ class Action
#
# @since 0.4.0
#
# @see https://www.owasp.org/index.php/Cross-Site_Request_Forgery_%28CSRF%29
# @see https://www.owasp.org/index.php/Cross-Site_Request_Forgery_(CSRF)_Prevention_Cheat_Sheet
# @see https://owasp.org/www-community/attacks/csrf
# @see https://cheatsheetseries.owasp.org/cheatsheets/Cross-Site_Request_Forgery_Prevention_Cheat_Sheet.html
#
# @example Custom Handling
# module Web::Controllers::Books
Expand Down
2 changes: 1 addition & 1 deletion lib/hanami/action/response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Action
# @see http://www.rubydoc.info/gems/rack/Rack/Response
#
# @since 2.0.0
# @api private
# @api public
class Response < ::Rack::Response
# @since 2.0.0
# @api private
Expand Down