yard 0.6.8 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of yard might be problematic. Click here for more details.

Files changed (224) hide show
  1. data/.yardopts +1 -0
  2. data/ChangeLog +723 -0
  3. data/README.md +16 -6
  4. data/docs/CodeObjects.md +10 -16
  5. data/docs/GettingStarted.md +232 -32
  6. data/docs/Glossary.md +1 -2
  7. data/docs/Handlers.md +10 -16
  8. data/docs/Overview.md +14 -13
  9. data/docs/Parser.md +13 -22
  10. data/docs/Tags.md +209 -16
  11. data/docs/Templates.md +237 -26
  12. data/docs/WhatsNew.md +178 -2
  13. data/lib/yard.rb +13 -10
  14. data/lib/yard/autoload.rb +22 -18
  15. data/lib/yard/cli/command.rb +13 -12
  16. data/lib/yard/cli/command_parser.rb +20 -19
  17. data/lib/yard/cli/config.rb +19 -19
  18. data/lib/yard/cli/diff.rb +46 -21
  19. data/lib/yard/cli/gems.rb +11 -11
  20. data/lib/yard/cli/graph.rb +13 -13
  21. data/lib/yard/cli/help.rb +1 -1
  22. data/lib/yard/cli/list.rb +22 -0
  23. data/lib/yard/cli/server.rb +17 -17
  24. data/lib/yard/cli/stats.rb +32 -32
  25. data/lib/yard/cli/yardoc.rb +181 -135
  26. data/lib/yard/cli/yri.rb +29 -29
  27. data/lib/yard/code_objects/base.rb +101 -101
  28. data/lib/yard/code_objects/class_object.rb +20 -20
  29. data/lib/yard/code_objects/constant_object.rb +1 -1
  30. data/lib/yard/code_objects/extended_method_object.rb +5 -5
  31. data/lib/yard/code_objects/extra_file_object.rb +89 -0
  32. data/lib/yard/code_objects/macro_object.rb +215 -0
  33. data/lib/yard/code_objects/method_object.rb +30 -30
  34. data/lib/yard/code_objects/module_object.rb +1 -1
  35. data/lib/yard/code_objects/namespace_object.rb +39 -39
  36. data/lib/yard/code_objects/proxy.rb +38 -38
  37. data/lib/yard/code_objects/root_object.rb +1 -1
  38. data/lib/yard/config.rb +40 -40
  39. data/lib/yard/core_ext/array.rb +2 -2
  40. data/lib/yard/core_ext/file.rb +11 -11
  41. data/lib/yard/core_ext/insertion.rb +10 -10
  42. data/lib/yard/core_ext/module.rb +2 -2
  43. data/lib/yard/core_ext/string.rb +2 -2
  44. data/lib/yard/core_ext/symbol_hash.rb +14 -14
  45. data/lib/yard/docstring.rb +122 -54
  46. data/lib/yard/globals.rb +2 -2
  47. data/lib/yard/handlers/base.rb +216 -127
  48. data/lib/yard/handlers/processor.rb +65 -27
  49. data/lib/yard/handlers/ruby/alias_handler.rb +6 -3
  50. data/lib/yard/handlers/ruby/attribute_handler.rb +7 -6
  51. data/lib/yard/handlers/ruby/base.rb +50 -31
  52. data/lib/yard/handlers/ruby/class_condition_handler.rb +11 -11
  53. data/lib/yard/handlers/ruby/class_handler.rb +10 -10
  54. data/lib/yard/handlers/ruby/class_variable_handler.rb +3 -3
  55. data/lib/yard/handlers/ruby/constant_handler.rb +7 -7
  56. data/lib/yard/handlers/ruby/exception_handler.rb +2 -2
  57. data/lib/yard/handlers/ruby/extend_handler.rb +1 -1
  58. data/lib/yard/handlers/ruby/legacy/alias_handler.rb +8 -5
  59. data/lib/yard/handlers/ruby/legacy/attribute_handler.rb +6 -5
  60. data/lib/yard/handlers/ruby/legacy/base.rb +42 -27
  61. data/lib/yard/handlers/ruby/legacy/class_condition_handler.rb +9 -9
  62. data/lib/yard/handlers/ruby/legacy/class_handler.rb +13 -12
  63. data/lib/yard/handlers/ruby/legacy/class_variable_handler.rb +3 -6
  64. data/lib/yard/handlers/ruby/legacy/constant_handler.rb +5 -8
  65. data/lib/yard/handlers/ruby/legacy/exception_handler.rb +1 -1
  66. data/lib/yard/handlers/ruby/legacy/extend_handler.rb +1 -0
  67. data/lib/yard/handlers/ruby/legacy/macro_handler.rb +40 -0
  68. data/lib/yard/handlers/ruby/legacy/method_handler.rb +10 -10
  69. data/lib/yard/handlers/ruby/legacy/mixin_handler.rb +4 -3
  70. data/lib/yard/handlers/ruby/legacy/module_handler.rb +2 -1
  71. data/lib/yard/handlers/ruby/legacy/private_constant_handler.rb +4 -4
  72. data/lib/yard/handlers/ruby/legacy/visibility_handler.rb +2 -1
  73. data/lib/yard/handlers/ruby/legacy/yield_handler.rb +3 -3
  74. data/lib/yard/handlers/ruby/macro_handler.rb +41 -0
  75. data/lib/yard/handlers/ruby/macro_handler_methods.rb +130 -0
  76. data/lib/yard/handlers/ruby/method_condition_handler.rb +1 -1
  77. data/lib/yard/handlers/ruby/method_handler.rb +13 -13
  78. data/lib/yard/handlers/ruby/mixin_handler.rb +4 -4
  79. data/lib/yard/handlers/ruby/module_handler.rb +2 -1
  80. data/lib/yard/handlers/ruby/private_constant_handler.rb +4 -4
  81. data/lib/yard/handlers/ruby/struct_handler_methods.rb +11 -11
  82. data/lib/yard/handlers/ruby/visibility_handler.rb +1 -1
  83. data/lib/yard/handlers/ruby/yield_handler.rb +5 -5
  84. data/lib/yard/logging.rb +11 -11
  85. data/lib/yard/parser/base.rb +8 -8
  86. data/lib/yard/parser/c_parser.rb +42 -33
  87. data/lib/yard/parser/ruby/ast_node.rb +62 -61
  88. data/lib/yard/parser/ruby/legacy/ruby_lex.rb +66 -66
  89. data/lib/yard/parser/ruby/legacy/ruby_parser.rb +4 -4
  90. data/lib/yard/parser/ruby/legacy/statement.rb +11 -11
  91. data/lib/yard/parser/ruby/legacy/statement_list.rb +15 -15
  92. data/lib/yard/parser/ruby/legacy/token_list.rb +9 -9
  93. data/lib/yard/parser/ruby/ruby_parser.rb +51 -37
  94. data/lib/yard/parser/source_parser.rb +271 -46
  95. data/lib/yard/rake/yardoc_task.rb +18 -17
  96. data/lib/yard/registry.rb +64 -64
  97. data/lib/yard/registry_store.rb +34 -34
  98. data/lib/yard/rubygems/backports.rb +8 -0
  99. data/lib/yard/rubygems/backports/LICENSE.txt +57 -0
  100. data/lib/yard/rubygems/backports/MIT.txt +20 -0
  101. data/lib/yard/rubygems/backports/gem.rb +8 -0
  102. data/lib/yard/rubygems/backports/source_index.rb +353 -0
  103. data/lib/yard/rubygems/specification.rb +2 -2
  104. data/lib/yard/serializers/base.rb +20 -20
  105. data/lib/yard/serializers/file_system_serializer.rb +28 -24
  106. data/lib/yard/serializers/process_serializer.rb +3 -3
  107. data/lib/yard/serializers/stdout_serializer.rb +6 -6
  108. data/lib/yard/serializers/yardoc_serializer.rb +17 -17
  109. data/lib/yard/server/adapter.rb +12 -12
  110. data/lib/yard/server/commands/base.rb +26 -26
  111. data/lib/yard/server/commands/display_file_command.rb +3 -2
  112. data/lib/yard/server/commands/display_object_command.rb +5 -5
  113. data/lib/yard/server/commands/frames_command.rb +1 -1
  114. data/lib/yard/server/commands/library_command.rb +7 -7
  115. data/lib/yard/server/commands/library_index_command.rb +2 -2
  116. data/lib/yard/server/commands/list_command.rb +8 -8
  117. data/lib/yard/server/commands/search_command.rb +8 -8
  118. data/lib/yard/server/commands/static_file_command.rb +3 -3
  119. data/lib/yard/server/doc_server_helper.rb +6 -3
  120. data/lib/yard/server/doc_server_serializer.rb +1 -1
  121. data/lib/yard/server/library_version.rb +45 -45
  122. data/lib/yard/server/rack_adapter.rb +10 -10
  123. data/lib/yard/server/router.rb +28 -28
  124. data/lib/yard/server/static_caching.rb +5 -5
  125. data/lib/yard/server/templates/default/fulldoc/html/css/custom.css +3 -3
  126. data/lib/yard/server/templates/default/fulldoc/html/js/live.js +1 -1
  127. data/lib/yard/server/templates/default/layout/html/breadcrumb.erb +2 -2
  128. data/lib/yard/server/templates/default/layout/html/headers.erb +13 -8
  129. data/lib/yard/server/templates/default/layout/html/setup.rb +7 -0
  130. data/lib/yard/server/templates/doc_server/full_list/html/full_list.erb +2 -2
  131. data/lib/yard/server/templates/doc_server/full_list/html/setup.rb +14 -4
  132. data/lib/yard/server/templates/doc_server/library_list/html/contents.erb +2 -2
  133. data/lib/yard/server/templates/doc_server/library_list/html/headers.erb +2 -2
  134. data/lib/yard/server/templates/doc_server/processing/html/processing.erb +1 -1
  135. data/lib/yard/server/templates/doc_server/search/html/search.erb +1 -1
  136. data/lib/yard/server/webrick_adapter.rb +2 -2
  137. data/lib/yard/tags/default_factory.rb +19 -19
  138. data/lib/yard/tags/default_tag.rb +1 -1
  139. data/lib/yard/tags/library.rb +68 -63
  140. data/lib/yard/tags/option_tag.rb +1 -1
  141. data/lib/yard/tags/overload_tag.rb +9 -9
  142. data/lib/yard/tags/ref_tag_list.rb +2 -2
  143. data/lib/yard/tags/tag.rb +7 -7
  144. data/lib/yard/templates/engine.rb +31 -31
  145. data/lib/yard/templates/erb_cache.rb +1 -1
  146. data/lib/yard/templates/helpers/base_helper.rb +46 -32
  147. data/lib/yard/templates/helpers/filter_helper.rb +2 -2
  148. data/lib/yard/templates/helpers/html_helper.rb +120 -81
  149. data/lib/yard/templates/helpers/html_syntax_highlight_helper.rb +4 -4
  150. data/lib/yard/templates/helpers/markup/rdoc_markup.rb +9 -9
  151. data/lib/yard/templates/helpers/markup_helper.rb +37 -30
  152. data/lib/yard/templates/helpers/method_helper.rb +7 -7
  153. data/lib/yard/templates/helpers/text_helper.rb +7 -7
  154. data/lib/yard/templates/helpers/uml_helper.rb +3 -3
  155. data/lib/yard/templates/section.rb +14 -14
  156. data/lib/yard/templates/template.rb +54 -54
  157. data/lib/yard/verifier.rb +27 -27
  158. data/spec/cli/list_spec.rb +8 -0
  159. data/spec/cli/yardoc_spec.rb +58 -10
  160. data/spec/code_objects/extra_file_object_spec.rb +132 -0
  161. data/spec/code_objects/macro_object_spec.rb +154 -0
  162. data/spec/docstring_spec.rb +90 -0
  163. data/spec/handlers/base_spec.rb +22 -0
  164. data/spec/handlers/examples/macro_handler_001.rb.txt +73 -0
  165. data/spec/handlers/examples/method_handler_001.rb.txt +17 -0
  166. data/spec/handlers/macro_handler_spec.rb +140 -0
  167. data/spec/handlers/method_handler_spec.rb +28 -0
  168. data/spec/handlers/processor_spec.rb +4 -0
  169. data/spec/handlers/spec_helper.rb +1 -1
  170. data/spec/parser/c_parser_spec.rb +47 -16
  171. data/spec/parser/examples/extrafile.c.txt +8 -0
  172. data/spec/parser/examples/multifile.c.txt +6 -0
  173. data/spec/parser/ruby/ruby_parser_spec.rb +5 -0
  174. data/spec/parser/source_parser_spec.rb +235 -0
  175. data/spec/rake/yardoc_task_spec.rb +22 -17
  176. data/spec/serializers/file_system_serializer_spec.rb +6 -0
  177. data/spec/server/commands/library_command_spec.rb +39 -0
  178. data/spec/spec_helper.rb +14 -0
  179. data/spec/templates/examples/method001.html +6 -6
  180. data/spec/templates/examples/method002.html +4 -4
  181. data/spec/templates/examples/method003.html +10 -10
  182. data/spec/templates/examples/method005.html +2 -2
  183. data/spec/templates/examples/module001.dot +2 -0
  184. data/spec/templates/examples/module001.html +76 -37
  185. data/spec/templates/examples/module001.txt +1 -1
  186. data/spec/templates/helpers/base_helper_spec.rb +7 -2
  187. data/spec/templates/helpers/html_helper_spec.rb +49 -5
  188. data/spec/templates/helpers/markup_helper_spec.rb +9 -8
  189. data/spec/templates/module_spec.rb +7 -0
  190. data/spec/templates/onefile_spec.rb +47 -0
  191. data/templates/default/fulldoc/html/css/style.css +7 -5
  192. data/templates/default/fulldoc/html/full_list.erb +13 -10
  193. data/templates/default/fulldoc/html/full_list_files.erb +1 -1
  194. data/templates/default/fulldoc/html/js/app.js +16 -14
  195. data/templates/default/fulldoc/html/js/full_list.js +7 -6
  196. data/templates/default/fulldoc/html/setup.rb +78 -17
  197. data/templates/default/layout/html/files.erb +1 -1
  198. data/templates/default/layout/html/headers.erb +11 -7
  199. data/templates/default/layout/html/search.erb +4 -4
  200. data/templates/default/layout/html/setup.rb +28 -8
  201. data/templates/default/module/html/inherited_attributes.erb +17 -0
  202. data/templates/default/module/setup.rb +1 -1
  203. data/templates/default/onefile/html/files.erb +2 -2
  204. data/templates/default/onefile/html/layout.erb +1 -1
  205. data/templates/default/onefile/html/setup.rb +7 -5
  206. data/templates/default/tags/html/option.erb +1 -1
  207. data/templates/default/tags/html/tag.erb +3 -3
  208. data/templates/guide/class/html/setup.rb +1 -0
  209. data/templates/guide/docstring/html/setup.rb +1 -0
  210. data/templates/guide/fulldoc/html/css/style.css +91 -0
  211. data/templates/guide/fulldoc/html/js/app.js +33 -0
  212. data/templates/guide/fulldoc/html/setup.rb +54 -0
  213. data/templates/guide/layout/html/layout.erb +81 -0
  214. data/templates/guide/layout/html/setup.rb +24 -0
  215. data/templates/guide/method/html/header.erb +18 -0
  216. data/templates/guide/method/html/setup.rb +21 -0
  217. data/templates/guide/module/html/header.erb +7 -0
  218. data/templates/guide/module/html/method_list.erb +5 -0
  219. data/templates/guide/module/html/setup.rb +26 -0
  220. data/templates/guide/tags/html/setup.rb +8 -0
  221. metadata +40 -7
  222. data/lib/yard/handlers/ruby/legacy/process_handler.rb +0 -13
  223. data/lib/yard/handlers/ruby/process_handler.rb +0 -18
  224. data/spec/handlers/process_handler_spec.rb +0 -17
@@ -2,15 +2,14 @@ include Helpers::ModuleHelper
2
2
 
3
3
  def init
4
4
  options[:objects] = objects = run_verifier(options[:objects])
5
- options[:files] = ([options[:readme]] + options[:files]).compact.map {|t| t.to_s }
5
+ options[:files] = ([options[:readme]] + options[:files]).uniq.compact
6
6
  options[:readme] = options[:files].first
7
- options[:title] ||= "Documentation by YARD #{YARD::VERSION}"
8
7
 
9
8
  return serialize_onefile if options[:onefile]
10
9
  generate_assets
11
10
  serialize('_index.html')
12
11
  options[:files].each_with_index do |file, i|
13
- serialize_file(file, i == 0 ? options[:title] : nil)
12
+ serialize_file(file, file.title)
14
13
  end
15
14
 
16
15
  options.delete(:objects)
@@ -27,6 +26,9 @@ def init
27
26
  end
28
27
  end
29
28
 
29
+ # Generate an HTML document for the specified object. This method is used by
30
+ # most of the objects found in the Registry.
31
+ # @param [CodeObject] object to be saved to HTML
30
32
  def serialize(object)
31
33
  options[:object] = object
32
34
  serialize_index(options) if object == '_index.html' && options[:files].empty?
@@ -35,52 +37,104 @@ def serialize(object)
35
37
  end
36
38
  end
37
39
 
40
+ # Generate the documentation output in one file (--one-file) which will load the
41
+ # contents of all the javascript and css and output the entire contents without
42
+ # depending on any additional files
38
43
  def serialize_onefile
39
- options[:css_data] = file('css/style.css', true) + "\n" + file('css/common.css', true)
40
- options[:js_data] = file('js/jquery.js', true) + file('js/app.js', true)
44
+ layout = Object.new.extend(T('layout'))
45
+ options[:css_data] = layout.stylesheets.map {|sheet| file(sheet,true) }.join("\n")
46
+ options[:js_data] = layout.javascripts.map {|script| file(script,true) }.join("")
41
47
  Templates::Engine.with_serializer('index.html', options[:serializer]) do
42
48
  T('onefile').run(options)
43
49
  end
44
50
  end
45
51
 
52
+ # Generate the index document for the output
53
+ # @params [Hash] options contains data and flags that influence the output
46
54
  def serialize_index(options)
47
55
  Templates::Engine.with_serializer('index.html', options[:serializer]) do
48
56
  T('layout').run(options)
49
57
  end
50
58
  end
51
59
 
60
+ # Generate a single HTML file with the layout template applied. This is generally
61
+ # the README file or files specified on the command-line.
62
+ #
63
+ # @param [File] file object to be saved to the output
64
+ # @param [String] title currently unused
65
+ #
66
+ # @see layout#diskfile
52
67
  def serialize_file(file, title = nil)
53
68
  options[:object] = Registry.root
54
69
  options[:file] = file
55
- options[:page_title] = title
56
- options[:serialized_path] = 'file.' + File.basename(file.gsub(/\.[^.]+$/, '')) + '.html'
70
+ outfile = 'file.' + file.name + '.html'
57
71
 
58
72
  serialize_index(options) if file == options[:readme]
59
- Templates::Engine.with_serializer(options[:serialized_path], options[:serializer]) do
73
+ Templates::Engine.with_serializer(outfile, options[:serializer]) do
60
74
  T('layout').run(options)
61
75
  end
62
76
  options.delete(:file)
63
- options.delete(:serialized_path)
64
- options.delete(:page_title)
65
77
  end
66
78
 
79
+ #
80
+ # Generates a file to the output with the specified contents.
81
+ #
82
+ # @example saving a custom html file to the documenation root
83
+ #
84
+ # asset('my_custom.html','<html><body>Custom File</body></html>')
85
+ #
86
+ # @param [String] path relative to the document output where the file will be
87
+ # created.
88
+ # @param [String] content the contents that are saved to the file.
67
89
  def asset(path, content)
68
90
  options[:serializer].serialize(path, content) if options[:serializer]
69
91
  end
70
92
 
93
+ # @return [Array<String>] Stylesheet files that are additionally loaded for the
94
+ # searchable full lists, e.g., Class List, Method List, File List
95
+ # @since 0.7.0
96
+ def stylesheets_full_list
97
+ %w(css/full_list.css css/common.css)
98
+ end
99
+
100
+ # @return [Array<String>] Javascript files that are additionally loaded for the
101
+ # searchable full lists, e.g., Class List, Method List, File List.
102
+ # @since 0.7.0
103
+ def javascripts_full_list
104
+ %w(js/jquery.js js/full_list.js)
105
+ end
106
+
107
+ def menu_lists
108
+ Object.new.extend(T('layout')).menu_lists
109
+ end
110
+
111
+ # Generates all the javascript files, stylesheet files, menu lists
112
+ # (i.e. class, method, and file) based on the the values returned from the
113
+ # layout's menu_list method, and the frameset in the documentation output
114
+ #
71
115
  def generate_assets
72
- %w( js/jquery.js js/app.js js/full_list.js
73
- css/style.css css/full_list.css css/common.css ).each do |file|
116
+ @object = Registry.root
117
+
118
+ layout = Object.new.extend(T('layout'))
119
+ (layout.javascripts + javascripts_full_list +
120
+ layout.stylesheets + stylesheets_full_list).uniq.each do |file|
74
121
  asset(file, file(file, true))
75
122
  end
76
-
77
- @object = Registry.root
78
- generate_method_list
79
- generate_class_list
80
- generate_file_list
123
+ layout.menu_lists.each do |list|
124
+ list_generator_method = "generate_#{list[:type]}_list"
125
+ if respond_to?(list_generator_method)
126
+ send(list_generator_method)
127
+ else
128
+ log.error "Unable to generate '#{list[:title]}' list because no method " +
129
+ "'#{list_generator_method}' exists"
130
+ end
131
+ end
132
+
81
133
  generate_frameset
82
134
  end
83
135
 
136
+ # Generate a searchable method list in the output
137
+ # @see ModuleHelper#prune_method_listing
84
138
  def generate_method_list
85
139
  @items = prune_method_listing(Registry.all(:method), false)
86
140
  @items = @items.reject {|m| m.name.to_s =~ /=$/ && m.is_attribute? }
@@ -90,6 +144,7 @@ def generate_method_list
90
144
  asset('method_list.html', erb(:full_list))
91
145
  end
92
146
 
147
+ # Generate a searchable class list in the output
93
148
  def generate_class_list
94
149
  @items = options[:objects]
95
150
  @list_title = "Class List"
@@ -97,6 +152,7 @@ def generate_class_list
97
152
  asset('class_list.html', erb(:full_list))
98
153
  end
99
154
 
155
+ # Generate a searchable file list in the output
100
156
  def generate_file_list
101
157
  @file_list = true
102
158
  @items = options[:files]
@@ -106,10 +162,15 @@ def generate_file_list
106
162
  @file_list = nil
107
163
  end
108
164
 
165
+ # Generate the frame documentation in the output
109
166
  def generate_frameset
167
+ @javascripts = javascripts_full_list
168
+ @stylesheets = stylesheets_full_list
110
169
  asset('frames.html', erb(:frames))
111
170
  end
112
171
 
172
+ # @return [String] HTML output of the classes to be displayed in the
173
+ # full_list_class template.
113
174
  def class_list(root = Registry.root)
114
175
  out = ""
115
176
  children = run_verifier(root.children)
@@ -3,7 +3,7 @@
3
3
  <ul id="files">
4
4
  <% n = 1 %>
5
5
  <% @files.each_with_index do |file, i| %>
6
- <li class="r<%= n %>"><%= link_file(file, File.basename(file).gsub(/\.[^.]+$/, '')) %></li>
6
+ <li class="r<%= n %>"><%= link_file(file) %></li>
7
7
  <% n = n == 2 ? 1 : 2 %>
8
8
  <% end %>
9
9
  </ul>
@@ -1,13 +1,17 @@
1
1
  <meta http-equiv="Content-Type" content="text/html; charset=<%= charset %>" />
2
- <title><%= @page_title %></title>
3
- <link rel="stylesheet" href="<%= url_for("css/style.css") %>" type="text/css" media="screen" charset="utf-8" />
4
- <link rel="stylesheet" href="<%= url_for("css/common.css") %>" type="text/css" media="screen" charset="utf-8" />
5
- <% if @extra_css %>
6
- <link rel="stylesheet" href="<%= url_for @extra_css %>" type="text/css" media="screen" charset="utf-8" />
2
+ <title>
3
+ <%= h @page_title %>
4
+ <% if options[:title] && @page_title != options[:title] %>
5
+ &mdash; <%= h options[:title] %>
6
+ <% end %>
7
+ </title>
8
+ <% stylesheets.each do |stylesheet| %>
9
+ <link rel="stylesheet" href="<%= url_for(stylesheet) %>" type="text/css" media="screen" charset="utf-8" />
7
10
  <% end %>
8
11
  <script type="text/javascript" charset="utf-8">
9
12
  relpath = '<%= url_for('') %>';
10
13
  if (relpath != '') relpath += '/';
11
14
  </script>
12
- <script type="text/javascript" charset="utf-8" src="<%= url_for("js/jquery.js") %>"></script>
13
- <script type="text/javascript" charset="utf-8" src="<%= url_for("js/app.js") %>"></script>
15
+ <% javascripts.each do |javascript| %>
16
+ <script type="text/javascript" charset="utf-8" src="<%= url_for(javascript) %>"></script>
17
+ <% end %>
@@ -1,5 +1,5 @@
1
1
  <div id="search">
2
- <a id="class_list_link" href="#">Class List</a>
3
- <a id="method_list_link" href="#">Method List</a>
4
- <a id ="file_list_link" href="#">File List</a>
5
- </div>
2
+ <% menu_lists.each do |field| %>
3
+ <a id="<%= field[:type] %>_list_link" href="#"><%= field[:search_title] %></a>
4
+ <% end %>
5
+ </div>
@@ -1,14 +1,13 @@
1
1
  def init
2
- @breadcrumb = []
3
-
2
+ @breadcrumb = []
4
3
  if @onefile
5
4
  sections :layout
6
5
  elsif @file
7
- @contents = File.read(@file)
8
- @file = File.basename(@file)
9
- @fname = @file.gsub(/\.[^.]+$/, '')
10
- @breadcrumb_title = "File: " + @fname
11
- @page_title ||= @breadcrumb_title
6
+ if @file.attributes[:namespace]
7
+ @object = options[:object] = Registry.at(@file.attributes[:namespace]) || Registry.root
8
+ end
9
+ @breadcrumb_title = "File: " + @file.title
10
+ @page_title = @breadcrumb_title
12
11
  sections :layout, [:diskfile]
13
12
  elsif object
14
13
  case object
@@ -46,6 +45,27 @@ def index
46
45
  end
47
46
 
48
47
  def diskfile
49
- data = htmlify(markup_file_contents(@contents), markup_for_file(@contents, @file))
48
+ @file.attributes[:markup] ||= markup_for_file('', @file.filename)
49
+ data = htmlify(@file.contents, @file.attributes[:markup])
50
50
  "<div id='filecontents'>" + data + "</div>"
51
51
  end
52
+
53
+ # @return [Array<String>] core javascript files for layout
54
+ # @since 0.7.0
55
+ def javascripts
56
+ %w(js/jquery.js js/app.js)
57
+ end
58
+
59
+ # @return [Array<String>] core stylesheets for the layout
60
+ # @since 0.7.0
61
+ def stylesheets
62
+ %w(css/style.css css/common.css)
63
+ end
64
+
65
+ # @return [Array<Hash{Symbol=>String}>] the list of search links and drop-down menus
66
+ # @since 0.7.0
67
+ def menu_lists
68
+ [ { :type => 'class', :title => 'Classes', :search_title => 'Class List' },
69
+ { :type => 'method', :title => 'Methods', :search_title => 'Method List' },
70
+ { :type => 'file', :title => 'Files', :search_title => 'File List' } ]
71
+ end
@@ -0,0 +1,17 @@
1
+ <% found_method = false %>
2
+ <% object.inheritance_tree(true)[1..-1].each do |superclass| %>
3
+ <% next if superclass.is_a?(YARD::CodeObjects::Proxy) %>
4
+ <% attribs = superclass.attributes[:instance] %>
5
+ <% next if attribs.size == 0 %>
6
+ <% if attr_listing.size == 0 && !found_method %><h2>Instance Attribute Summary</h2><% end %>
7
+ <% found_method = true %>
8
+ <h3 class="inherited">Attributes <%= superclass.type == :class ? 'inherited' : 'included' %> from <%= linkify superclass %></h3>
9
+ <p class="inherited"><%=
10
+ attribs.sort_by {|args| args.first.to_s }.collect do |args|
11
+ name, methods = args
12
+ method = methods[:read] || methods[:write]
13
+ name = method.name.to_s.gsub(/^#/,'') if superclass.type == :module && object.class_mixins.include?(superclass)
14
+ linkify(method, name)
15
+ end.join(", ")
16
+ %></p>
17
+ <% end %>
@@ -3,7 +3,7 @@ include Helpers::ModuleHelper
3
3
  def init
4
4
  sections :header, :box_info, :pre_docstring, T('docstring'), :children,
5
5
  :constant_summary, [T('docstring')], :inherited_constants,
6
- :attribute_summary, [:item_summary],
6
+ :attribute_summary, [:item_summary], :inherited_attributes,
7
7
  :method_summary, [:item_summary], :inherited_methods,
8
8
  :methodmissing, [T('method_details')],
9
9
  :attribute_details, [T('method_details')],
@@ -1,5 +1,5 @@
1
1
  <% @files.each do |file| %>
2
- <% @file, @contents = file, read_file(file) %>
3
- <h2><%= file %></h2>
2
+ <% @file = file %>
3
+ <h2><%= file.title %></h2>
4
4
  <%= diskfile %>
5
5
  <% end %>
@@ -2,7 +2,7 @@
2
2
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
3
  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
4
  <head>
5
- <meta name="Content-Type" content="text/html; charset=<%= charset %>" />
5
+ <meta http-equiv="Content-Type" content="text/html; charset=<%= charset %>" />
6
6
  <title><%= @title %></title>
7
7
  <style type="text/css" media="screen">
8
8
  <%= @css_data %>
@@ -16,13 +16,9 @@ end
16
16
 
17
17
  private
18
18
 
19
- def read_file(file)
20
- File.read(file).force_encoding(charset)
21
- end
22
-
23
19
  def parse_top_comments_from_file
24
20
  data = ""
25
- tokens = TokenList.new(read_file(@readme))
21
+ tokens = TokenList.new(@readme.contents)
26
22
  tokens.each do |token|
27
23
  break unless token.is_a?(RubyToken::TkCOMMENT) || token.is_a?(RubyToken::TkNL)
28
24
  data << (token.text[/\A#\s{0,1}(.*)/, 1] || "\n")
@@ -31,7 +27,13 @@ def parse_top_comments_from_file
31
27
  end
32
28
 
33
29
  def override_serializer
30
+ return if @serializer.nil?
34
31
  class << @serializer
32
+ def serialize(object, data)
33
+ return unless object == 'index.html'
34
+ super
35
+ end
36
+
35
37
  def serialized_path(object)
36
38
  return object if object.is_a?(String)
37
39
  return 'index.html'
@@ -6,8 +6,8 @@
6
6
  <ul class="option">
7
7
  <% for tag in tags %>
8
8
  <li>
9
- <span class="type"><%= format_types(tag.pair.types || ['Object']) %></span>
10
9
  <span class="name"><%= tag.pair.name %></span>
10
+ <span class="type"><%= format_types(tag.pair.types || ['Object']) %></span>
11
11
  <span class="default">
12
12
  <% if tag.pair.defaults %>
13
13
  &mdash; default:
@@ -2,12 +2,12 @@
2
2
  <ul class="<%= @name %>">
3
3
  <% object.tags(@name).each do |tag| %>
4
4
  <li>
5
- <% unless @no_types %>
6
- <span class='type'><%= format_types(tag.types) %></span>
7
- <% end %>
8
5
  <% unless @no_names %>
9
6
  <span class='name'><%= h tag.name %></span>
10
7
  <% end %>
8
+ <% unless @no_types %>
9
+ <span class='type'><%= format_types(tag.types) %></span>
10
+ <% end %>
11
11
  <% if @name == :param && (o=object.parameters.assoc(tag.name.to_s)) && o[1] %>
12
12
  <em class="default">(defaults to: <tt><%= h o[1] %></tt>)</em>
13
13
  <% end %>
@@ -0,0 +1 @@
1
+ include T('guide/module/html')
@@ -0,0 +1 @@
1
+ include T('default/docstring/html')
@@ -0,0 +1,91 @@
1
+ body { color: #3e4349; font-family: Georgia, serif; font-size: 17px; margin: 0; }
2
+ h1, h2, h3, h4, h5, h6 { font-weight: normal; color: #000; font-family: Georgia, serif; }
3
+ h1 { color: #040; }
4
+ h2 { color: #060; }
5
+ #sidebar h2 { color: #2f2; }
6
+ strong { color: #000; }
7
+ .object_link, tt, code { font-family: 'Consolas', 'BitStream Vera Sans Mono', monospace; font-size: 14px; }
8
+ .method_header .path, .module_header .path { font-family: 'Consolas', 'BitStream Vera Sans Mono', monospace; }
9
+ .method_header .path.space, .module_header .path.space { padding-left: 5px; }
10
+ .method_header { font-size: 0.95em; }
11
+ .method_body { margin-left: 2em; }
12
+ .tags h3, .tags h4 { font-size: 0.9em; font-weight: bold; color: #3e4349; }
13
+ .tags .param .name { font-style: italic; }
14
+ .tags .option .name { font-family: monospace; color: #000; font-size: 0.8em; }
15
+ .tags .option .type, .tags .param .type { font-size: 10px; vertical-align: super; }
16
+ .tags .option .type tt, .tags .param .type tt,
17
+ .tags .option .type tt .object_link, .tags .param .type tt .object_link { font-size: 10px; }
18
+ .module_methods { margin-left: 2em; }
19
+ .method_header .since, .module_header .since { font-size: 0.75em; color: #888; vertical-align: super; }
20
+ ul { list-style: square; }
21
+ .inline { display: inline; }
22
+ .inline p:first-child { display: inline; }
23
+ .inline p { font-family: Georgia, serif; font-size: 16px; color: #3e4349; }
24
+ .docstring .note { margin: 1em 0; }
25
+ .docstring h1, .docstring h2, .docstring h3, .docstring h4 { padding: 0; border: 0; border-bottom: 1px dotted #bbb; }
26
+ .docstring h1 { font-size: 1.2em; }
27
+ .docstring h2 { font-size: 1.1em; }
28
+ .docstring h3 { font-size: 1.1em; }
29
+ #filecontents strong { font-weight: normal; color: #000; }
30
+ .readonly { font-size: 0.75em; color: #888; vertical-align: super; }
31
+
32
+ #page { width: 940px; margin: 0px auto; }
33
+ #top_nav { background: #8e0; padding: 4px 8px; }
34
+ #inner_nav { width: 940px; margin: 0px auto; }
35
+ #inner_nav a { border: 0; text-decoration: none; color: #777; }
36
+ #inner_nav a:hover { color: #eee; }
37
+ #top_nav .links { display: block; float: right; }
38
+ #content { margin-left: 30px; width: 660px; float: left; }
39
+ #sidebar { float: left; width: 200px; float: left; padding: 18px 10px; padding-top: 0; }
40
+ #sidebar h2 { font-weight: 100; color: #3e4349; font-size: 1.45em; }
41
+ #sidebar ol { padding-left: 19px; margin-left: 0; list-style: square; }
42
+ #sidebar a { color: #777; }
43
+ #sidebar ol.top { padding-left: 0; margin-left: 0; list-style: none; }
44
+ #sidebar a { font-size: 0.9em; }
45
+ #footer { margin: 0 auto; width: 940px; text-align: center; margin-top: 30px; padding: 20px 0; color: #888; font-size: 0.8em; border-top: 1px dotted #bbb; }
46
+ #footer a { color: #444; }
47
+ #links strong { font-size: 0.95em; font-weight: normal; color: #000; }
48
+
49
+ a { color: #268; text-decoration: none; }
50
+ a:hover { color: #060; background: #8e0; }
51
+
52
+ /* syntax highlighting */
53
+ .source_code { display: none; padding: 3px 8px; border-left: 8px solid #ddd; margin-top: 5px; }
54
+ #filecontents pre.code, .docstring pre.code, .source_code pre { font-family: monospace; }
55
+ #filecontents pre.code, .docstring pre.code { display: block; }
56
+ .source_code .lines { padding-right: 12px; color: #555; text-align: right; }
57
+ #filecontents pre.code, .docstring pre.code,
58
+ .tags .example {
59
+ font-size: 0.9em;
60
+ padding: 7px 30px;
61
+ margin: 15px -30px;
62
+ margin-left: -30px;
63
+ background: #eee;
64
+ line-height: 1.3em;
65
+ font-family: 'Consolas', 'BitStream Vera Sans Mono', monospace;
66
+ }
67
+ pre.code { color: #3e4349; }
68
+ pre.code .info.file { color: #555; }
69
+ pre.code .val { color: #036A07; }
70
+ pre.code .tstring_content,
71
+ pre.code .heredoc_beg, pre.code .heredoc_end,
72
+ pre.code .qwords_beg, pre.code .qwords_end,
73
+ pre.code .tstring, pre.code .dstring { color: #036A07; }
74
+ pre.code .fid, pre.code .id.new, pre.code .id.to_s,
75
+ pre.code .id.to_sym, pre.code .id.to_f,
76
+ pre.code .dot + pre.code .id,
77
+ pre.code .id.to_i pre.code .id.each { color: #0085FF; }
78
+ pre.code .comment { color: #0066FF; }
79
+ pre.code .const, pre.code .constant { color: #585CF6; }
80
+ pre.code .symbol { color: #C5060B; }
81
+ pre.code .kw,
82
+ pre.code .label,
83
+ pre.code .id.require,
84
+ pre.code .id.extend,
85
+ pre.code .id.include { color: #0000FF; }
86
+ pre.code .ivar { color: #318495; }
87
+ pre.code .gvar,
88
+ pre.code .id.backref,
89
+ pre.code .id.nth_ref { color: #6D79DE; }
90
+ pre.code .regexp, .dregexp { color: #036A07; }
91
+ pre.code a { border-bottom: 1px dotted #bbf; }