Skip to content
This repository
Browse code

[padrino-core] Continue conversion from rdoc to yard.

  • Loading branch information...
commit e218f09a089efa9119efbd01aed8693d8244f135 1 parent 0e5a97d
Davide D'Agostino authored September 07, 2011
6  .yardopts
... ...
@@ -0,0 +1,6 @@
  1
+--exclude /support_lite|padrino-tasks|padrino-core\/cli/
  2
+--output-dir doc/
  3
+--readme README.rdoc
  4
+--no-private
  5
+--title Padrino Framework
  6
+padrino-*/lib/**/*.rb
12  Rakefile
@@ -99,17 +99,7 @@ task :default => :test
99 99
 
100 100
 desc "Generate documentation for the Padrino framework"
101 101
 task :doc do
102  
-  yard = YARD::CLI::Yardoc.new
103  
-  yard.parse_arguments *%w[
104  
-    --exclude /support_lite|padrino-tasks|padrino-core\/cli/
105  
-    --hide-void-return
106  
-    --output-dir doc/
107  
-    --readme README.rdoc
108  
-    --no-private
109  
-    --title Padrino Framework
110  
-    padrino-*/lib/**/*.rb
111  
-  ]
112  
-  yard.run
  102
+  YARD::CLI::Yardoc.new.run
113 103
 end
114 104
 
115 105
 desc "Publish doc on padrinorb.com/api"
33  padrino-core/lib/padrino-core.rb
@@ -13,7 +13,7 @@ class ApplicationLoadError < RuntimeError # @private
13 13
   end
14 14
 
15 15
   class << self
16  
-    #
  16
+    ##
17 17
     # Helper method for file references.
18 18
     #
19 19
     # @param [Array<String>] args
@@ -31,7 +31,7 @@ def root(*args)
31 31
       File.expand_path(File.join(PADRINO_ROOT, *args))
32 32
     end
33 33
 
34  
-    #
  34
+    ##
35 35
     # Helper method that return {PADRINO_ENV}.
36 36
     #
37 37
     # @return [Symbol]
@@ -41,7 +41,7 @@ def env
41 41
       @_env ||= PADRINO_ENV.to_s.downcase.to_sym
42 42
     end
43 43
 
44  
-    #
  44
+    ##
45 45
     # The resulting rack builder mapping each 'mounted' application.
46 46
     #
47 47
     # @return [Padrino::Router]
@@ -65,7 +65,7 @@ def application
65 65
       end
66 66
     end
67 67
 
68  
-    #
  68
+    ##
69 69
     # Configure Global Project Settings for mounted apps. These can be overloaded
70 70
     # in each individual app's own personal configuration. This can be used like:
71 71
     #
@@ -82,7 +82,7 @@ def configure_apps(&block)
82 82
       @_global_configuration = block if block_given?
83 83
     end
84 84
 
85  
-    #
  85
+    ##
86 86
     # Returns project-wide configuration settings defined in
87 87
     # {configure_apps} block.
88 88
     #
@@ -90,8 +90,16 @@ def apps_configuration
90 90
       @_global_configuration
91 91
     end
92 92
 
  93
+    ##
  94
+    # Set +Encoding.default_internal+ and +Encoding.default_external+
  95
+    # to +Encoding::UFT_8+.
  96
+    #
  97
+    # Please note that in +1.9.2+ with some template engines like +haml+
  98
+    # you should turn off Encoding.default_internal to prevent problems.
  99
+    #
  100
+    # @see https://github.com/rtomayko/tilt/issues/75
93 101
     #
94  
-    # Default encoding to UTF8.
  102
+    # @return [NilClass]
95 103
     #
96 104
     def set_encoding
97 105
       if RUBY_VERSION < '1.9'
@@ -103,7 +111,7 @@ def set_encoding
103 111
       nil
104 112
     end
105 113
 
106  
-    #
  114
+    ##
107 115
     # Determines whether the dependencies are locked by Bundler.
108 116
     # otherwise return nil
109 117
     #
@@ -111,12 +119,14 @@ def set_encoding
111 119
     #   Returns +:locked+ if the +Gemfile.lock+ file exists, or +:unlocked+
112 120
     #   if only the +Gemfile+ exists.
113 121
     #
  122
+    # @deprecated Will be removed in 1.0.0
  123
+    #
114 124
     def bundle
115 125
       return :locked   if File.exist?(root('Gemfile.lock'))
116 126
       return :unlocked if File.exist?(root("Gemfile"))
117 127
     end
118 128
 
119  
-    #
  129
+    ##
120 130
     # A Rack::Builder object that allows to add middlewares in front of all
121 131
     # Padrino applications.
122 132
     #
@@ -127,14 +137,17 @@ def middleware
127 137
       @middleware ||= []
128 138
     end
129 139
 
130  
-    #
  140
+    ##
131 141
     # Clears all previously configured middlewares.
132 142
     #
  143
+    # @return [Array]
  144
+    #   An empty array
  145
+    #
133 146
     def clear_middleware!
134 147
       @middleware = []
135 148
     end
136 149
 
137  
-    #
  150
+    ##
138 151
     # Convenience method for adding a Middleware to the whole padrino app.
139 152
     #
140 153
     # @param [Class] m
34  padrino-core/lib/padrino-core/application.rb
@@ -31,6 +31,13 @@ def inherited(base) # @private
31 31
       # take into account overwritten app settings inside subclassed definitions
32 32
       # Only performs the setup first time application is initialized.
33 33
       #
  34
+      # @param [Array] args
  35
+      #
  36
+      # @yield [Sinatra]
  37
+      #   a Sinatra application
  38
+      #
  39
+      # @return [Sinatra]
  40
+      #
34 41
       def new(*args, &bk)
35 42
         setup_application!
36 43
         logging, logging_was = false, logging
@@ -46,8 +53,9 @@ def new(*args, &bk)
46 53
       # This method is used from our Padrino Reloader during development mode
47 54
       # in order to reload the source files.
48 55
       #
49  
-      # ==== Examples
  56
+      # @return [TrueClass]
50 57
       #
  58
+      # @example
51 59
       #   MyApp.reload!
52 60
       #
53 61
       def reload!
@@ -62,25 +70,27 @@ def reload!
62 70
         default_routes!  # Reload default routes
63 71
         default_errors!  # Reload our errors
64 72
         I18n.reload! if defined?(I18n) # Reload also our translations
  73
+        true
65 74
       end
66 75
 
67 76
       ##
68 77
       # Resets application routes to only routes not defined by the user
69 78
       #
70  
-      # ==== Examples
  79
+      # @return [TrueClass]
71 80
       #
  81
+      # @example
72 82
       #   MyApp.reset_routes!
73 83
       #
74 84
       def reset_routes!
75 85
         reset_router!
76 86
         default_routes!
  87
+        true
77 88
       end
78 89
 
79 90
       ##
80 91
       # Returns the routes of our app.
81 92
       #
82  
-      # ==== Examples
83  
-      #
  93
+      # @example
84 94
       #   MyApp.routes
85 95
       #
86 96
       def routes
@@ -91,6 +101,8 @@ def routes
91 101
       # Setup the application by registering initializers, load paths and logger
92 102
       # Invoked automatically when an application is first instantiated
93 103
       #
  104
+      # @return [TrueClass]
  105
+      #
94 106
       def setup_application!
95 107
         return if @_configured
96 108
         self.register_initializers
@@ -104,12 +116,15 @@ def setup_application!
104 116
           I18n.reload!
105 117
         end
106 118
         @_configured = true
  119
+        @_configured
107 120
       end
108 121
 
109 122
       ##
110 123
       # Run the Padrino app as a self-hosted server using
111 124
       # Thin, Mongrel or WEBrick (in that order)
112 125
       #
  126
+      # @see Padrino::Server#start
  127
+      #
113 128
       def run!(options={})
114 129
         return unless Padrino.load!
115 130
         Padrino.mount(self.to_s).to("/")
@@ -117,7 +132,8 @@ def run!(options={})
117 132
       end
118 133
 
119 134
       ##
120  
-      # Returns the used $LOAD_PATHS from this application
  135
+      # @return [Array]
  136
+      #   directory that need to be added to +$LOAD_PATHS+ from this application
121 137
       #
122 138
       def load_paths
123 139
         @_load_paths ||= %w(models lib mailers controllers helpers).map { |path| File.join(self.root, path) }
@@ -127,7 +143,10 @@ def load_paths
127 143
       # Returns default list of path globs to load as dependencies
128 144
       # Appends custom dependency patterns to the be loaded for your Application
129 145
       #
130  
-      # ==== Examples
  146
+      # @return [Array]
  147
+      #   list of path globs to load as dependencies
  148
+      #
  149
+      # @example
131 150
       #   MyApp.dependencies << "#{Padrino.root}/uploaders/**/*.rb"
132 151
       #   MyApp.dependencies << Padrino.root('other_app', 'controllers.rb')
133 152
       #
@@ -143,12 +162,13 @@ def dependencies
143 162
       #
144 163
       # By default we look for files:
145 164
       #
  165
+      #   # List of default files that we are looking for:
146 166
       #   yourapp/models.rb
147 167
       #   yourapp/models/**/*.rb
148 168
       #   yourapp/lib.rb
149 169
       #   yourapp/lib/**/*.rb
150 170
       #
151  
-      # ==== Examples
  171
+      # @example Adding a custom perequisite
152 172
       #   MyApp.prerequisites << Padrino.root('my_app', 'custom_model.rb')
153 173
       #
154 174
       def prerequisites
43  padrino-core/lib/padrino-core/application/rendering.rb
... ...
@@ -1,7 +1,7 @@
1 1
 require 'padrino-core/support_lite' unless defined?(SupportLite)
2 2
 
3 3
 module Padrino
4  
-  #
  4
+  ##
5 5
   # Padrino enhances the Sinatra ‘render’ method to have support for
6 6
   # automatic template engine detection, enhanced layout functionality,
7 7
   # locale enabled rendering, among other features.
@@ -10,7 +10,7 @@ module Rendering
10 10
     class TemplateNotFound < RuntimeError
11 11
     end
12 12
 
13  
-    #
  13
+    ##
14 14
     # This is an array of file patterns to ignore. If your editor add a
15 15
     # suffix during editing to your files please add it like:
16 16
     #
@@ -21,12 +21,12 @@ class TemplateNotFound < RuntimeError
21 21
       /~$/ # This is for Gedit
22 22
     ] unless defined?(IGNORE_FILE_PATTERN)
23 23
 
24  
-    #
  24
+    ##
25 25
     # Default rendering options used in the #render-method.
26 26
     #
27 27
     DEFAULT_RENDERING_OPTIONS = { :strict_format => false, :raise_exceptions => true } unless defined?(DEFAULT_RENDERING_OPTIONS)
28 28
 
29  
-    #
  29
+    ##
30 30
     # Main class that register this extension.
31 31
     #
32 32
     class << self
@@ -38,7 +38,7 @@ def registered(app)
38 38
     end
39 39
 
40 40
     module ClassMethods
41  
-      #
  41
+      ##
42 42
       # Use layout like rails does or if a block given then like sinatra.
43 43
       # If used without a block, sets the current layout for the route.
44 44
       #
@@ -61,7 +61,7 @@ def layout(name=:layout, &block)
61 61
         @layout = name
62 62
       end
63 63
 
64  
-      #
  64
+      ##
65 65
       # Returns the cached template file to render for a given url, content_type and locale.
66 66
       #
67 67
       # @param [Array<template_path, content_type, locale>] render_options
@@ -70,7 +70,7 @@ def fetch_template_file(render_options)
70 70
         (@_cached_templates ||= {})[render_options]
71 71
       end
72 72
 
73  
-      #
  73
+      ##
74 74
       # Caches the template file for the given rendering options
75 75
       #
76 76
       # @param [String] template_file
@@ -82,10 +82,10 @@ def cache_template_file!(template_file, render_options)
82 82
         (@_cached_templates ||= {})[render_options] = template_file || []
83 83
       end
84 84
 
85  
-      #
  85
+      ##
86 86
       # Returns the cached layout path.
87 87
       #
88  
-      # @param [Symbol] given_layout
  88
+      # @param [Symbol, nil] given_layout
89 89
       #   The requested layout.
90 90
       #
91 91
       def fetch_layout_path(given_layout=nil)
@@ -103,13 +103,30 @@ def fetch_layout_path(given_layout=nil)
103 103
     module InstanceMethods
104 104
       attr_reader :current_engine
105 105
 
  106
+      ##
  107
+      # Get/Set the content_type
106 108
       #
107 109
       # @param [String, nil] type
108 110
       #   The Content-Type to use.
109 111
       #
  112
+      # @param [Symbol, nil] type.
  113
+      #   Look and parse the given symbol to the matched Content-Type.
  114
+      #
110 115
       # @param [Hash] params
111 116
       #   Additional params to append to the Content-Type.
112 117
       #
  118
+      # @example
  119
+      #   case content_type
  120
+      #     when :js then do_some
  121
+      #     when :css then do_another
  122
+      #   end
  123
+      #
  124
+      #   content_type :js
  125
+      #   # => set the response with 'application/javascript' Content-Type
  126
+      #   content_type 'text/html'
  127
+      #
  128
+      #   # => set directly the Content-Type to 'text/html'
  129
+      #
113 130
       def content_type(type=nil, params={})
114 131
         unless type.nil?
115 132
           super(type, params)
@@ -119,7 +136,7 @@ def content_type(type=nil, params={})
119 136
       end
120 137
 
121 138
       private
122  
-        #
  139
+        ##
123 140
         # Enhancing Sinatra render functionality for:
124 141
         #
125 142
         # * Using layout similar to rails
@@ -176,7 +193,7 @@ def render(engine, data=nil, options={}, locals={}, &block)
176 193
           @_out_buf = _buf_was
177 194
         end
178 195
 
179  
-        #
  196
+        ##
180 197
         # Returns the located layout tuple to be used for the rendered template
181 198
         # (if available).
182 199
         #
@@ -190,7 +207,7 @@ def resolved_layout
190 207
           located_layout ? located_layout : [nil, nil]
191 208
         end
192 209
 
193  
-        #
  210
+        ##
194 211
         # Returns the template path and engine that match content_type (if present),
195 212
         # I18n.locale.
196 213
         #
@@ -254,7 +271,7 @@ def resolve_template(template_path, options={})
254 271
           located_template
255 272
         end
256 273
 
257  
-        #
  274
+        ##
258 275
         # Return the I18n.locale if I18n is defined.
259 276
         #
260 277
         def locale
141  padrino-core/lib/padrino-core/application/routing.rb
... ...
@@ -1,6 +1,10 @@
1 1
 require 'http_router' unless defined?(HttpRouter)
2 2
 require 'padrino-core/support_lite' unless defined?(SupportLite)
3 3
 
  4
+##
  5
+# Adds to Sinatra +controller+ informations
  6
+#
  7
+# @private
4 8
 class Sinatra::Request
5 9
   attr_accessor :route_obj
6 10
 
@@ -9,6 +13,10 @@ def controller
9 13
   end
10 14
 end
11 15
 
  16
+##
  17
+# HttpRouter adapter
  18
+#
  19
+# @private
12 20
 class HttpRouter
13 21
   def rewrite_partial_path_info(env, request); end
14 22
   def rewrite_path_info(env, request); end
@@ -53,7 +61,7 @@ def process_destination_path(path, env)
53 61
     end
54 62
   end
55 63
 
56  
-  class Route # @private
  64
+  class Route
57 65
     attr_reader :before_filters, :after_filters
58 66
     attr_accessor :custom_conditions, :use_layout, :controller, :cache
59 67
 
@@ -82,7 +90,7 @@ def custom_conditions=(custom_conditions)
82 90
 end
83 91
 
84 92
 module Padrino
85  
-  class Filter
  93
+  class Filter # @private
86 94
     attr_reader :block
87 95
 
88 96
     def initialize(mode, scoped_controller, options, args, &block)
@@ -114,7 +122,7 @@ def to_proc
114 122
     end
115 123
   end
116 124
 
117  
-  #
  125
+  ##
118 126
   # Padrino provides advanced routing definition support to make routes and
119 127
   # url generation much easier. This routing system supports named route
120 128
   # aliases and easy access to url paths. The benefits of this is that instead
@@ -126,13 +134,9 @@ module Routing
126 134
     CONTENT_TYPE_ALIASES = { :htm => :html } unless defined?(CONTENT_TYPE_ALIASES)
127 135
     ROUTE_PRIORITY = {:high => 0, :normal => 1, :low => 2} unless defined?(ROUTE_PRIORITY)
128 136
 
129  
-    class UnrecognizedException < RuntimeError
130  
-    end
  137
+    class UnrecognizedException < RuntimeError; end
131 138
 
132  
-    #
133  
-    # Keeps information about parent scope.
134  
-    #
135  
-    class Parent < String
  139
+    class Parent < String # @private
136 140
       attr_reader :map
137 141
       attr_reader :optional
138 142
       attr_reader :options
@@ -147,10 +151,10 @@ def initialize(value, options={})
147 151
       end
148 152
     end
149 153
 
150  
-    #
151  
-    # Main class that register this extension.
152  
-    #
153 154
     class << self
  155
+      ##
  156
+      # Main class that register this extension.
  157
+      #
154 158
       def registered(app)
155 159
         app.send(:include, InstanceMethods)
156 160
         app.extend(ClassMethods)
@@ -159,7 +163,7 @@ def registered(app)
159 163
     end
160 164
 
161 165
     module ClassMethods
162  
-      #
  166
+      ##
163 167
       # Method for organize in a better way our routes.
164 168
       #
165 169
       # @param [Array] args
@@ -191,8 +195,7 @@ module ClassMethods
191 195
       #     get :foo do; "respond to html, xml and json"; end
192 196
       #   end
193 197
       #
194  
-      # @example Specify parent resources in padrino with the +:parent+
195  
-      # option on the controller:
  198
+      # @example Specify parent resources in padrino with the +:parent+ option on the controller:
196 199
       #   controllers :product, :parent => :user do
197 200
       #     get :index do
198 201
       #       # url is generated as "/user/#{params[:user_id]}/product"
@@ -235,6 +238,7 @@ module ClassMethods
235 238
       # In a controller before and after filters are scoped and didn't affect other controllers or main app.
236 239
       # In a controller layout are scoped and didn't affect others controllers and main app.
237 240
       #
  241
+      # @example
238 242
       #   controller :posts do
239 243
       #     layout :post
240 244
       #     before { foo }
@@ -275,20 +279,65 @@ def controller(*args, &block)
275 279
       end
276 280
       alias :controllers :controller
277 281
 
  282
+      ##
  283
+      # Add a before filter hook
278 284
       #
279  
-      # @see add_filter
  285
+      # @see #construct_filter
280 286
       #
281 287
       def before(*args, &block)
282 288
         add_filter :before, &(args.empty? ? block : construct_filter(*args, &block))
283 289
       end
284 290
 
  291
+      ##
  292
+      # Add an after filter hook
285 293
       #
286  
-      # @see add_filter
  294
+      # @see #construct_filter
287 295
       #
288 296
       def after(*args, &block)
289 297
         add_filter :after, &(args.empty? ? block : construct_filter(*args, &block))
290 298
       end
291 299
 
  300
+      ##
  301
+      # Creates a filter to process before/after the matching route.
  302
+      #
  303
+      # @param [Array] args
  304
+      #
  305
+      # @example We are be able to filter with String path
  306
+      #   before('/') { 'only to :index' }
  307
+      #   get(:index} { 'foo' } # => filter match only before this.
  308
+      #   get(:main) { 'bar' }
  309
+      #
  310
+      # @example is the same of
  311
+      #   before(:index) { 'only to :index' }
  312
+      #   get(:index} { 'foo' } # => filter match only before this.
  313
+      #   get(:main) { 'bar' }
  314
+      #
  315
+      # @example it works only for the given controller
  316
+      #   controller :foo do
  317
+      #     before(:index) { 'only to for :foo_index' }
  318
+      #     get(:index} { 'foo' } # => filter match only before this.
  319
+      #     get(:main) { 'bar' }
  320
+      #   end
  321
+      #
  322
+      #   controller :bar do
  323
+      #     before(:index) { 'only to for :bar_index' }
  324
+      #     get(:index} { 'foo' } # => filter match only before this.
  325
+      #     get(:main) { 'bar' }
  326
+      #   end
  327
+      #
  328
+      # @example if filters based on a symbol or regexp
  329
+      #   before :index, /main/ do; ... end
  330
+      #   # => match oly path that are  +/+ or contains +main+
  331
+      #
  332
+      # @example filtering everything except an occurency
  333
+      #   before :except => :index do; ...; end
  334
+      #
  335
+      # @example you can also filter using a request param
  336
+      #   before :agent => /IE/ do; ...; end
  337
+      #   # => match +HTTP_USER_AGENT+ containing +IE+
  338
+      #
  339
+      # @see http://www.padrinorb.com/guides/controllers#route-filters
  340
+      #
292 341
       def construct_filter(*args, &block)
293 342
         options = args.last.is_a?(Hash) ? args.pop : {}
294 343
         except = options.key?(:except) && Array(options.delete(:except))
@@ -297,7 +346,7 @@ def construct_filter(*args, &block)
297 346
         Filter.new(!except, @_controller, options, Array(except || args), &block)
298 347
       end
299 348
 
300  
-      #
  349
+      ##
301 350
       # Provides many parents with shallowing.
302 351
       #
303 352
       # @param [Symbol] name
@@ -306,7 +355,7 @@ def construct_filter(*args, &block)
306 355
       # @param [Hash] options
307 356
       #   Additional options.
308 357
       #
309  
-      # @example examples
  358
+      # @example
310 359
       #   controllers :product do
311 360
       #     parent :shop, :optional => true, :map => "/my/stand"
312 361
       #     parent :category, :optional => true
@@ -328,7 +377,7 @@ def parent(name, options={})
328 377
         @_parents << Parent.new(name, options)
329 378
       end
330 379
 
331  
-      #
  380
+      ##
332 381
       # Using {HttpRouter}, for features and configurations.
333 382
       #
334 383
       # @example
@@ -362,18 +411,42 @@ def reset_router!
362 411
         router.reset!
363 412
       end
364 413
 
  414
+      ##
  415
+      # Recognize a given path
  416
+      #
  417
+      # @param [String] path
  418
+      #   Path+Query to parse
  419
+      #
  420
+      # @return [Symbol, Hash]
  421
+      #   Returns controller and query params.
  422
+      #
  423
+      # @example Giving a controller like:
  424
+      #   controller :foo do
  425
+      #     get :bar, :map => 'foo-bar-:id'; ...; end
  426
+      #   end
  427
+      #
  428
+      # @example You should be able to reverse:
  429
+      #   MyApp.url(:foo_bar, :id => :mine)
  430
+      #   # => /foo-bar-mine
  431
+      #
  432
+      # @example Into this:
  433
+      #   MyApp.recognize_path('foo-bar-mine')
  434
+      #   # => [:foo_bar, :id => :mine]
  435
+      #
365 436
       def recognize_path(path)
366 437
         responses = @router.recognize(Rack::MockRequest.env_for(path))
367 438
         [responses[0].path.route.named, responses[0].params]
368 439
       end
369 440
 
370  
-      #
  441
+      ##
371 442
       # Instance method for url generation.
372 443
       #
373 444
       # @example
374 445
       #   url(:show, :id => 1)
375 446
       #   url(:show, :name => 'test', :id => 24)
376 447
       #   url(:show, 1)
  448
+      #   url(:controller_name, :show, :id => 21)
  449
+      #   url(:controller_show, :id => 29)
377 450
       #
378 451
       def url(*args)
379 452
         params = args.extract_options!  # parameters is hash at end
@@ -398,7 +471,7 @@ def url(*args)
398 471
       end
399 472
       alias :url_for :url
400 473
 
401  
-      def get(path, *args, &block)
  474
+      def get(path, *args, &block) # @private
402 475
         conditions = @conditions.dup
403 476
         route('GET', path, *args, &block)
404 477
 
@@ -406,6 +479,9 @@ def get(path, *args, &block)
406 479
         route('HEAD', path, *args, &block)
407 480
       end
408 481
 
  482
+      ##
  483
+      # Returns the lat controller, useful inside a layout/view.
  484
+      #
409 485
       def current_controller
410 486
         @_controller && @_controller.last
411 487
       end
@@ -432,7 +508,7 @@ def conform_uri(uri_string)
432 508
           uri_string.gsub(/^(?!\/)(.*)/, '/\1').gsub(/[\/]+$/, '')
433 509
         end
434 510
 
435  
-        #
  511
+        ##
436 512
         # Rewrite default routes.
437 513
         #
438 514
         # @example
@@ -530,7 +606,7 @@ def route(verb, path, *args, &block)
530 606
           route
531 607
         end
532 608
 
533  
-        #
  609
+        ##
534 610
         # Returns the final parsed route details (modified to reflect all
535 611
         # Padrino options) given the raw route. Raw route passed in could be
536 612
         # a named alias or a string and is parsed to reflect provides formats,
@@ -606,7 +682,7 @@ def parse_route(path, options, verb)
606 682
           [path, name, options]
607 683
         end
608 684
 
609  
-        #
  685
+        ##
610 686
         # Processes the existing path and appends the 'with' parameters onto the route
611 687
         # Used for calculating path in route method.
612 688
         #
@@ -614,7 +690,7 @@ def process_path_for_with_params(path, with_params)
614 690
           File.join(path, Array(with_params).map(&:inspect).join("/"))
615 691
         end
616 692
 
617  
-        #
  693
+        ##
618 694
         # Processes the existing path and prepends the 'parent' parameters onto the route
619 695
         # Used for calculating path in route method.
620 696
         #
@@ -628,7 +704,7 @@ def process_path_for_parent_params(path, parent_params)
628 704
           [parent_prefix, path].flatten.join("")
629 705
         end
630 706
 
631  
-        #
  707
+        ##
632 708
         # Processes the existing path and appends the 'format' suffix onto the route
633 709
         # Used for calculating path in route method.
634 710
         #
@@ -636,7 +712,7 @@ def process_path_for_provides(path, format_params)
636 712
           path << "(.:format)" unless path[-10, 10] == '(.:format)'
637 713
         end
638 714
 
639  
-        #
  715
+        ##
640 716
         # Allows routing by MIME-types specified in the URL or ACCEPT header.
641 717
         #
642 718
         # By default, if a non-provided mime-type is specified in a URL, the
@@ -706,7 +782,7 @@ def provides(*types)
706 782
     end
707 783
 
708 784
     module InstanceMethods
709  
-      #
  785
+      ##
710 786
       # Instance method for url generation.
711 787
       #
712 788
       # @example
@@ -715,6 +791,8 @@ module InstanceMethods
715 791
       #   url(:show, 1)
716 792
       #   url("/foo")
717 793
       #
  794
+      # @see Padrino::Routing::ClassMethods#url
  795
+      #
718 796
       def url(*args)
719 797
         # Delegate to Sinatra 1.2 for simple url("/foo")
720 798
         # http://www.sinatrarb.com/intro#Generating%20URLs
@@ -737,7 +815,7 @@ def current_path(*path_params)
737 815
         @route.url(*path_params)
738 816
       end
739 817
 
740  
-      #
  818
+      ##
741 819
       # This is mostly just a helper so request.path_info isn't changed when
742 820
       # serving files from the public directory.
743 821
       #
@@ -761,7 +839,7 @@ def static!
761 839
         end
762 840
       end
763 841
 
764  
-      #
  842
+      ##
765 843
       # Return the request format, this is useful when we need to respond to
766 844
       # a given Content-Type.
767 845
       #
@@ -823,7 +901,6 @@ def route!(base=self.class, pass_block=nil)
823 901
           route_eval(&pass_block) if pass_block
824 902
 
825 903
           route_missing
826  
-        ensure
827 904
         end
828 905
     end # InstanceMethods
829 906
   end # Routing
3  padrino-core/lib/padrino-core/application/showexceptions.rb
... ...
@@ -1,7 +1,8 @@
1 1
 module Padrino
2  
-  #
  2
+  ##
3 3
   # This module extend Sinatra::ShowExceptions adding Padrino as "Framework".
4 4
   #
  5
+  # @private
5 6
   class ShowExceptions < Sinatra::ShowExceptions
6 7
     private
7 8
       def frame_class(frame)
51  padrino-core/lib/padrino-core/caller.rb
@@ -19,38 +19,33 @@ module Padrino
19 19
     %r{/thor}                                        # thor require hacks
20 20
   ] unless defined?(PADRINO_IGNORE_CALLERS)
21 21
 
22  
-  #
  22
+  ##
23 23
   # Add rubinius (and hopefully other VM implementations) ignore patterns ...
24 24
   #
25 25
   PADRINO_IGNORE_CALLERS.concat(RUBY_IGNORE_CALLERS) if defined?(RUBY_IGNORE_CALLERS)
26 26
 
27 27
   private
  28
+    ##
  29
+    # The filename for the file that is the direct caller (first caller).
  30
+    #
  31
+    # @return [String]
  32
+    #   The file the caller method exists in.
  33
+    #
  34
+    def self.first_caller
  35
+      caller_files.first
  36
+    end
28 37
 
29  
-  #
30  
-  # The filename for the file that is the direct caller (first caller).
31  
-  #
32  
-  # @return [String]
33  
-  #   The file the caller method exists in.
34  
-  #
35  
-  # @api private
36  
-  #
37  
-  def self.first_caller
38  
-    caller_files.first
39  
-  end
40  
-
41  
-  #
42  
-  # Like +Kernel#caller+ but excluding certain magic entries and without
43  
-  # line / method information; the resulting array contains filenames only.
44  
-  #
45  
-  # @return [Array<String>]
46  
-  #   The files of the calling methods.
47  
-  #
48  
-  # @api private
49  
-  #
50  
-  def self.caller_files
51  
-    caller(1).
52  
-      map    { |line| line.split(/:(?=\d|in )/)[0,2] }.
53  
-      reject { |file,line| PADRINO_IGNORE_CALLERS.any? { |pattern| file =~ pattern } }.
54  
-      map    { |file,line| file }
55  
-  end
  38
+    #
  39
+    # Like +Kernel#caller+ but excluding certain magic entries and without
  40
+    # line / method information; the resulting array contains filenames only.
  41
+    #
  42
+    # @return [Array<String>]
  43
+    #   The files of the calling methods.
  44
+    #
  45
+    def self.caller_files
  46
+      caller(1).
  47
+        map    { |line| line.split(/:(?=\d|in )/)[0,2] }.
  48
+        reject { |file,line| PADRINO_IGNORE_CALLERS.any? { |pattern| file =~ pattern } }.
  49
+        map    { |file,line| file }
  50
+    end
56 51
 end # Padrino

0 notes on commit e218f09

Please sign in to comment.
Something went wrong with that request. Please try again.