Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 66 lines (46 sloc) 1.659 kb
8aa6098 @rkh added readme
authored
1 YARD::Sinatra
2 =============
3
4 This plugin adds [Sinatra](http://sinatrarb.com) routes to [YARD](http://yardoc.org/) output.
5
6 Usage
7 -----
8
06a4177 @rkh no more bigband
authored
9 Install via rubygems:
8aa6098 @rkh added readme
authored
10
11 gem install yard-sinatra
12
13 Add comments to your routes (well, that's optional):
14
15 require "sinatra/base"
16 require "user"
17
18 class ExampleApp < Sinatra::Base
19
20 # Settings for a given user
21 #
22 # @param [User] some user
23 # @return [Hash] settings for that user
24 def settings(some_user)
25 raise NotImplementedMethod
26 end
27
28 # Displays a settings page for the current user
29 #
30 # @see ExampleApp#settings
31 get "/settings" do
32 haml :settings, {}, :settings => settings(current_user)
33 end
cfeb8dc Updated example in the README to show NOT_FOUND support
Ryan Sobol authored
34
35 # Error 404 Page Not Found
36 not_found do
37 haml :'404'
38 end
8aa6098 @rkh added readme
authored
39
40 end
41
42 The you're ready to go:
43
44 yardoc example_app.rb
45
89b359d @emidander Updated information on yard plugin handling to match updated YARD beh…
emidander authored
46 Old versions of YARD (before 0.6.2) will automatically detect the yard-sinatra plugin and load it. In newer versions you must use the `--plugin yard-sinatra` parameter, or add it to a .yardopts file.
8aa6098 @rkh added readme
authored
47
48 Other use cases
49 ---------------
50
51 As with yard, this can be used for other means besides documentation.
52 For instance, you might want a list of all routes defined in a given list of files without executing those files:
53
54 require "yard/sinatra"
55 YARD::Registry.load Dir.glob("lib/**/*.rb")
56 YARD::Sinatra.routes.each do |route|
57 puts route.http_verb, route.http_path, route.file, route.docstring
58 end
6aefb2b @rkh addded thanks
authored
59
60 Thanks
61 ------
62
a395446 @rkh fixing markup
authored
63 * Ryan Sobol for implementing `not_found` documentation.
6aefb2b @rkh addded thanks
authored
64 * Loren Segal for making it seamlessly work as YARD plugin.
65 Well, and for YARD.
Something went wrong with that request. Please try again.