diff --git a/.yardopts b/.yardopts index 8fbab40f..40867ad0 100644 --- a/.yardopts +++ b/.yardopts @@ -1,9 +1,10 @@ -middleman-*/lib/**/*.rb +middleman-*/lib/**/*.rb --exclude middleman-core/lib/vendored-middleman-deps/ --exclude middleman-core/lib/middleman-core/step_definitions --exclude middleman-core/lib/middleman-core/templates/default/ --exclude middleman-core/lib/middleman-core/templates/html5/ --exclude middleman-core/lib/middleman-core/templates/mobile/ --exclude middleman-core/lib/middleman-core/templates/shared/ +--exclude middleman-core/lib/middleman-core/templates/extension/ --no-private --hide-void-return \ No newline at end of file diff --git a/middleman-core/.yardopts b/middleman-core/.yardopts new file mode 100644 index 00000000..b6b437b9 --- /dev/null +++ b/middleman-core/.yardopts @@ -0,0 +1,10 @@ +lib/**/*.rb +--exclude lib/vendored-middleman-deps/ +--exclude lib/middleman-core/step_definitions +--exclude lib/middleman-core/templates/default/ +--exclude lib/middleman-core/templates/html5/ +--exclude lib/middleman-core/templates/mobile/ +--exclude lib/middleman-core/templates/shared/ +--exclude lib/middleman-core/templates/extension/ +--no-private +--hide-void-return \ No newline at end of file diff --git a/middleman-core/lib/middleman-core/core_extensions/request.rb b/middleman-core/lib/middleman-core/core_extensions/request.rb index 99ee3b33..9f916766 100644 --- a/middleman-core/lib/middleman-core/core_extensions/request.rb +++ b/middleman-core/lib/middleman-core/core_extensions/request.rb @@ -173,8 +173,8 @@ module Middleman }) end - delegate :use, :to => :"self.class" - delegate :map, :to => :"self.class" + delegate :use, :to => :"self.class" + delegate :map, :to => :"self.class" # Rack request # @return [Rack::Request] @@ -287,8 +287,6 @@ module Middleman end # Immediately send static file - # - # @param [String] path File to send def send_file(resource, env) file = ::Rack::File.new nil file.path = resource.source_file diff --git a/middleman-core/lib/middleman-core/extensions.rb b/middleman-core/lib/middleman-core/extensions.rb index c049f6f6..0c93c7b4 100644 --- a/middleman-core/lib/middleman-core/extensions.rb +++ b/middleman-core/lib/middleman-core/extensions.rb @@ -113,12 +113,20 @@ module Middleman config.define_setting(key, default, description) end - def helpers(&block) + # Add helpers to the global Middleman application. + # This accepts either a list of modules to add on behalf + # of this extension, or a block whose contents will all + # be used as helpers in a new module. + def helpers(*m, &block) self.defined_helpers ||= [] - m = Module.new - m.module_eval(&block) - self.defined_helpers << m + if block + m = Module.new + m.module_eval(&block) + mod = [m] + end + + self.defined_helpers += m end def extension_name @@ -172,7 +180,7 @@ module Middleman def app=(app) @app = app - + (self.class.defined_helpers || []).each do |m| app.class.send(:include, m) end diff --git a/middleman-core/lib/middleman-core/sitemap/extensions/redirects.rb b/middleman-core/lib/middleman-core/sitemap/extensions/redirects.rb index 63183b53..ead8fc70 100644 --- a/middleman-core/lib/middleman-core/sitemap/extensions/redirects.rb +++ b/middleman-core/lib/middleman-core/sitemap/extensions/redirects.rb @@ -38,8 +38,7 @@ module Middleman # Setup a redirect from a path to a target # @param [String] path - # @param [Hash] The :to value gives a target path - # @return [void] + # @param [Hash] opts The :to value gives a target path def create_redirect(path, opts={}, &block) if block_given? opts[:template] = block diff --git a/middleman-core/lib/middleman-core/sitemap/extensions/request_endpoints.rb b/middleman-core/lib/middleman-core/sitemap/extensions/request_endpoints.rb index 1227f60b..84eee061 100644 --- a/middleman-core/lib/middleman-core/sitemap/extensions/request_endpoints.rb +++ b/middleman-core/lib/middleman-core/sitemap/extensions/request_endpoints.rb @@ -38,9 +38,8 @@ module Middleman # Setup a proxy from a path to a target # @param [String] path - # @param [Hash] The :path value gives a request path if it + # @param [Hash] opts The :path value gives a request path if it # differs from the output path - # @return [void] def create_endpoint(path, opts={}, &block) endpoint = { :request_path => path @@ -84,7 +83,7 @@ module Middleman def template? true end - + def render(*args, &block) return self.output.call if self.output end