yard 0.5.8 → 0.6.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 (211) hide show
  1. data/.yardopts +2 -0
  2. data/ChangeLog +1064 -0
  3. data/README.md +103 -42
  4. data/Rakefile +3 -2
  5. data/benchmarks/parsing.rb +2 -1
  6. data/bin/yard +4 -0
  7. data/bin/yard-graph +1 -1
  8. data/bin/yard-server +4 -0
  9. data/docs/GettingStarted.md +8 -8
  10. data/docs/Handlers.md +5 -5
  11. data/docs/Overview.md +5 -5
  12. data/docs/Parser.md +1 -1
  13. data/docs/Tags.md +1 -1
  14. data/docs/Templates.md +27 -6
  15. data/docs/WhatsNew.md +222 -2
  16. data/lib/rubygems_plugin.rb +1 -0
  17. data/lib/yard.rb +7 -1
  18. data/lib/yard/autoload.rb +46 -6
  19. data/lib/yard/cli/{base.rb → command.rb} +20 -6
  20. data/lib/yard/cli/command_parser.rb +87 -0
  21. data/lib/yard/cli/diff.rb +176 -0
  22. data/lib/yard/cli/gems.rb +74 -0
  23. data/lib/yard/cli/{yard_graph.rb → graph.rb} +9 -8
  24. data/lib/yard/cli/help.rb +18 -0
  25. data/lib/yard/cli/server.rb +137 -0
  26. data/lib/yard/cli/stats.rb +210 -0
  27. data/lib/yard/cli/yardoc.rb +315 -116
  28. data/lib/yard/cli/yri.rb +45 -4
  29. data/lib/yard/code_objects/base.rb +73 -30
  30. data/lib/yard/code_objects/class_object.rb +9 -1
  31. data/lib/yard/code_objects/method_object.rb +11 -0
  32. data/lib/yard/code_objects/namespace_object.rb +8 -2
  33. data/lib/yard/code_objects/proxy.rb +2 -2
  34. data/lib/yard/core_ext/array.rb +3 -49
  35. data/lib/yard/core_ext/file.rb +7 -0
  36. data/lib/yard/core_ext/insertion.rb +60 -0
  37. data/lib/yard/docstring.rb +34 -7
  38. data/lib/yard/globals.rb +2 -2
  39. data/lib/yard/handlers/base.rb +101 -20
  40. data/lib/yard/handlers/processor.rb +23 -7
  41. data/lib/yard/handlers/ruby/alias_handler.rb +1 -0
  42. data/lib/yard/handlers/ruby/attribute_handler.rb +8 -0
  43. data/lib/yard/handlers/ruby/base.rb +71 -2
  44. data/lib/yard/handlers/ruby/class_condition_handler.rb +10 -0
  45. data/lib/yard/handlers/ruby/class_handler.rb +7 -4
  46. data/lib/yard/handlers/ruby/class_variable_handler.rb +1 -0
  47. data/lib/yard/handlers/ruby/constant_handler.rb +1 -0
  48. data/lib/yard/handlers/ruby/exception_handler.rb +1 -0
  49. data/lib/yard/handlers/ruby/extend_handler.rb +2 -3
  50. data/lib/yard/handlers/ruby/legacy/alias_handler.rb +1 -0
  51. data/lib/yard/handlers/ruby/legacy/attribute_handler.rb +2 -0
  52. data/lib/yard/handlers/ruby/legacy/base.rb +15 -2
  53. data/lib/yard/handlers/ruby/legacy/class_condition_handler.rb +5 -0
  54. data/lib/yard/handlers/ruby/legacy/class_handler.rb +7 -4
  55. data/lib/yard/handlers/ruby/legacy/class_variable_handler.rb +1 -0
  56. data/lib/yard/handlers/ruby/legacy/constant_handler.rb +1 -0
  57. data/lib/yard/handlers/ruby/legacy/exception_handler.rb +1 -0
  58. data/lib/yard/handlers/ruby/legacy/extend_handler.rb +1 -3
  59. data/lib/yard/handlers/ruby/legacy/method_handler.rb +7 -3
  60. data/lib/yard/handlers/ruby/legacy/mixin_handler.rb +2 -1
  61. data/lib/yard/handlers/ruby/legacy/module_handler.rb +1 -0
  62. data/lib/yard/handlers/ruby/legacy/process_handler.rb +1 -0
  63. data/lib/yard/handlers/ruby/legacy/visibility_handler.rb +1 -0
  64. data/lib/yard/handlers/ruby/legacy/yield_handler.rb +1 -0
  65. data/lib/yard/handlers/ruby/method_condition_handler.rb +1 -0
  66. data/lib/yard/handlers/ruby/method_handler.rb +5 -1
  67. data/lib/yard/handlers/ruby/mixin_handler.rb +2 -1
  68. data/lib/yard/handlers/ruby/module_handler.rb +1 -0
  69. data/lib/yard/handlers/ruby/process_handler.rb +7 -1
  70. data/lib/yard/handlers/ruby/struct_handler_methods.rb +3 -0
  71. data/lib/yard/handlers/ruby/visibility_handler.rb +8 -2
  72. data/lib/yard/handlers/ruby/yield_handler.rb +1 -0
  73. data/lib/yard/logging.rb +7 -1
  74. data/lib/yard/parser/base.rb +1 -0
  75. data/lib/yard/parser/c_parser.rb +2 -0
  76. data/lib/yard/parser/ruby/ast_node.rb +82 -63
  77. data/lib/yard/parser/ruby/legacy/ruby_lex.rb +36 -10
  78. data/lib/yard/parser/ruby/legacy/ruby_parser.rb +1 -0
  79. data/lib/yard/parser/ruby/legacy/statement.rb +9 -5
  80. data/lib/yard/parser/ruby/legacy/statement_list.rb +20 -11
  81. data/lib/yard/parser/ruby/ruby_parser.rb +18 -1
  82. data/lib/yard/parser/source_parser.rb +6 -1
  83. data/lib/yard/registry.rb +284 -278
  84. data/lib/yard/registry_store.rb +4 -2
  85. data/lib/yard/serializers/base.rb +30 -13
  86. data/lib/yard/serializers/file_system_serializer.rb +10 -1
  87. data/lib/yard/server/adapter.rb +51 -0
  88. data/lib/yard/server/commands/base.rb +98 -0
  89. data/lib/yard/server/commands/display_file_command.rb +20 -0
  90. data/lib/yard/server/commands/display_object_command.rb +50 -0
  91. data/lib/yard/server/commands/frames_command.rb +31 -0
  92. data/lib/yard/server/commands/library_command.rb +83 -0
  93. data/lib/yard/server/commands/library_index_command.rb +23 -0
  94. data/lib/yard/server/commands/list_command.rb +44 -0
  95. data/lib/yard/server/commands/search_command.rb +67 -0
  96. data/lib/yard/server/commands/static_file_command.rb +45 -0
  97. data/lib/yard/server/doc_server_helper.rb +22 -0
  98. data/lib/yard/server/doc_server_serializer.rb +29 -0
  99. data/lib/yard/server/library_version.rb +86 -0
  100. data/lib/yard/server/rack_adapter.rb +38 -0
  101. data/lib/yard/server/router.rb +110 -0
  102. data/lib/yard/server/static_caching.rb +16 -0
  103. data/lib/yard/server/templates/default/fulldoc/html/css/custom.css +78 -0
  104. data/lib/yard/server/templates/default/fulldoc/html/images/processing.gif +0 -0
  105. data/lib/yard/server/templates/default/fulldoc/html/js/autocomplete.js +12 -0
  106. data/lib/yard/server/templates/default/fulldoc/html/js/live.js +32 -0
  107. data/lib/yard/server/templates/default/layout/html/breadcrumb.erb +46 -0
  108. data/lib/yard/server/templates/default/layout/html/headers.erb +11 -0
  109. data/lib/yard/server/templates/doc_server/frames/html/frames.erb +13 -0
  110. data/lib/yard/server/templates/doc_server/frames/html/setup.rb +3 -0
  111. data/lib/yard/server/templates/doc_server/full_list/html/full_list.erb +34 -0
  112. data/lib/yard/server/templates/doc_server/full_list/html/setup.rb +10 -0
  113. data/lib/yard/server/templates/doc_server/library_list/html/contents.erb +13 -0
  114. data/lib/yard/server/templates/doc_server/library_list/html/headers.erb +26 -0
  115. data/lib/yard/server/templates/doc_server/library_list/html/library_list.erb +12 -0
  116. data/lib/yard/server/templates/doc_server/library_list/html/setup.rb +3 -0
  117. data/lib/yard/server/templates/doc_server/library_list/html/title.erb +2 -0
  118. data/lib/yard/server/templates/doc_server/processing/html/processing.erb +51 -0
  119. data/lib/yard/server/templates/doc_server/processing/html/setup.rb +3 -0
  120. data/lib/yard/server/templates/doc_server/search/html/search.erb +19 -0
  121. data/lib/yard/server/templates/doc_server/search/html/setup.rb +8 -0
  122. data/lib/yard/server/webrick_adapter.rb +38 -0
  123. data/lib/yard/tags/default_factory.rb +0 -5
  124. data/lib/yard/tags/library.rb +61 -22
  125. data/lib/yard/tags/tag.rb +26 -4
  126. data/lib/yard/templates/engine.rb +12 -1
  127. data/lib/yard/templates/erb_cache.rb +2 -1
  128. data/lib/yard/templates/helpers/base_helper.rb +96 -3
  129. data/lib/yard/templates/helpers/filter_helper.rb +5 -0
  130. data/lib/yard/templates/helpers/html_helper.rb +204 -94
  131. data/lib/yard/templates/helpers/html_syntax_highlight_helper.rb +4 -0
  132. data/lib/yard/templates/helpers/markup_helper.rb +58 -3
  133. data/lib/yard/templates/helpers/method_helper.rb +7 -0
  134. data/lib/yard/templates/helpers/module_helper.rb +5 -0
  135. data/lib/yard/templates/helpers/text_helper.rb +10 -1
  136. data/lib/yard/templates/helpers/uml_helper.rb +13 -0
  137. data/lib/yard/templates/section.rb +106 -0
  138. data/lib/yard/templates/template.rb +20 -19
  139. data/lib/yard/verifier.rb +21 -2
  140. data/spec/cli/command_parser_spec.rb +43 -0
  141. data/spec/cli/diff_spec.rb +170 -0
  142. data/spec/cli/help_spec.rb +22 -0
  143. data/spec/cli/server_spec.rb +140 -0
  144. data/spec/cli/stats_spec.rb +75 -0
  145. data/spec/cli/yardoc_spec.rb +438 -182
  146. data/spec/cli/yri_spec.rb +13 -1
  147. data/spec/code_objects/base_spec.rb +51 -6
  148. data/spec/code_objects/class_object_spec.rb +15 -1
  149. data/spec/code_objects/method_object_spec.rb +29 -0
  150. data/spec/code_objects/namespace_object_spec.rb +150 -129
  151. data/spec/core_ext/array_spec.rb +4 -23
  152. data/spec/core_ext/insertion_spec.rb +37 -0
  153. data/spec/docstring_spec.rb +63 -0
  154. data/spec/handlers/attribute_handler_spec.rb +4 -0
  155. data/spec/handlers/base_spec.rb +98 -26
  156. data/spec/handlers/class_handler_spec.rb +5 -1
  157. data/spec/handlers/examples/attribute_handler_001.rb.txt +5 -0
  158. data/spec/handlers/examples/class_handler_001.rb.txt +4 -0
  159. data/spec/handlers/examples/module_handler_001.rb.txt +6 -1
  160. data/spec/handlers/examples/visibility_handler_001.rb.txt +4 -0
  161. data/spec/handlers/method_handler_spec.rb +5 -0
  162. data/spec/handlers/module_handler_spec.rb +4 -0
  163. data/spec/handlers/visibility_handler_spec.rb +6 -0
  164. data/spec/parser/source_parser_spec.rb +24 -0
  165. data/spec/registry_spec.rb +44 -8
  166. data/spec/server/adapter_spec.rb +38 -0
  167. data/spec/server/commands/base_spec.rb +87 -0
  168. data/spec/server/commands/static_file_command_spec.rb +67 -0
  169. data/spec/server/doc_server_serializer_spec.rb +58 -0
  170. data/spec/server/router_spec.rb +115 -0
  171. data/spec/server/spec_helper.rb +17 -0
  172. data/spec/server/static_caching_spec.rb +39 -0
  173. data/spec/server/webrick_servlet_spec.rb +20 -0
  174. data/spec/templates/constant_spec.rb +40 -0
  175. data/spec/templates/engine_spec.rb +9 -5
  176. data/spec/templates/examples/class002.html +1 -3
  177. data/spec/templates/examples/constant001.txt +25 -0
  178. data/spec/templates/examples/constant002.txt +7 -0
  179. data/spec/templates/examples/constant003.txt +11 -0
  180. data/spec/templates/examples/module001.txt +1 -1
  181. data/spec/templates/examples/module002.html +319 -0
  182. data/spec/templates/helpers/base_helper_spec.rb +2 -2
  183. data/spec/templates/helpers/html_helper_spec.rb +93 -3
  184. data/spec/templates/helpers/html_syntax_highlight_helper_spec.rb +5 -0
  185. data/spec/templates/helpers/markup_helper_spec.rb +94 -67
  186. data/spec/templates/helpers/shared_signature_examples.rb +9 -0
  187. data/spec/templates/helpers/text_helper_spec.rb +12 -0
  188. data/spec/templates/module_spec.rb +21 -4
  189. data/spec/templates/section_spec.rb +146 -0
  190. data/spec/templates/template_spec.rb +9 -20
  191. data/templates/default/class/setup.rb +5 -5
  192. data/templates/default/constant/text/header.erb +11 -0
  193. data/templates/default/constant/text/setup.rb +3 -0
  194. data/templates/default/fulldoc/html/css/style.css +29 -3
  195. data/templates/default/fulldoc/html/js/app.js +67 -1
  196. data/templates/default/fulldoc/html/js/full_list.js +3 -8
  197. data/templates/default/fulldoc/html/js/jquery.js +150 -15
  198. data/templates/default/fulldoc/html/setup.rb +9 -0
  199. data/templates/default/layout/html/footer.erb +1 -1
  200. data/templates/default/layout/html/setup.rb +7 -25
  201. data/templates/default/method_details/html/source.erb +1 -1
  202. data/templates/default/module/html/attribute_summary.erb +2 -2
  203. data/templates/default/module/html/method_summary.erb +2 -2
  204. data/templates/default/module/setup.rb +27 -4
  205. data/templates/default/onefile/html/files.erb +5 -0
  206. data/templates/default/onefile/html/layout.erb +22 -0
  207. data/templates/default/onefile/html/readme.erb +3 -0
  208. data/templates/default/onefile/html/setup.rb +40 -0
  209. data/templates/default/root/html/setup.rb +1 -0
  210. data/templates/default/tags/setup.rb +26 -33
  211. metadata +80 -10
data/docs/WhatsNew.md CHANGED
@@ -1,3 +1,223 @@
1
+ What's New in 0.6.x?
2
+ ====================
3
+
4
+ 1. **Local documentation server for RubyGems or projects (`yard server`)** (0.6.0)
5
+ 2. **Groups support for method listing** (0.6.0)
6
+ 3. **Single file template (`--one-file`) support** (0.6.0)
7
+ 4. **`yard` CLI executable with pluggable commands** (0.6.0)
8
+ 5. **`yard diff` command to object-diff two versions of a project** (0.6.0)
9
+ 6. **Added `--asset` option to `yardoc`** (0.6.0)
10
+ 7. **New template API** (0.6.0)
11
+ 8. **HTML template now adds inline Table of Contents for extra files pages** (0.6.0)
12
+ 9. **Removed `--incremental` in favour of `--use-cache`** (0.6.0)
13
+ 10. **Ad-hoc tag registration via `yardoc` CLI (`--tag`, etc.)** (0.6.0)
14
+ 11. **Added `--transitive-tags` to register transitive tags** (0.6.0)
15
+ 12. **`yardoc` now displays RDoc-like statistics (`--no-stats` to hide)** (0.6.0)
16
+ 13. **`yri` now works on constants** (0.6.0)
17
+
18
+ ## Local documentation server for RubyGems or projects (`yard server`) (0.6.0)
19
+
20
+ The new `yard server` command spawns a documentation server that can serve
21
+ either documentation for a local project or installed RubyGems. The server
22
+ will host (by default) on http://localhost:8808.
23
+
24
+ To serve documentation for the active project (in the current directory):
25
+
26
+ $ yard server
27
+
28
+ The server can also run in "incremental" mode for local projects. In this
29
+ situation, any modified sources will immediately be updated at each request,
30
+ ensuring that the server always serve the code exactly as it is on disk.
31
+ Documenting your code in this fashion essentially gives you an efficient a
32
+ live preview without running a separate command everytime you make a change.
33
+ To serve documentation for the active project in incremental mode:
34
+
35
+ $ yard server --reload
36
+
37
+ <span class="note">Note that in incremental mode, objects or method groupings
38
+ cannot be removed. If you have removed objects or modified groupings, you
39
+ will need to flush the cache by deleting `.yardoc` and (optionally)
40
+ restarting the server.</span>
41
+
42
+ The documentation server can also serve documentation for all installed gems
43
+ on your system, similar to `gem server`, but using YARD's functionality and
44
+ templates. To serve documentation for installed gems:
45
+
46
+ $ yard server --gems
47
+
48
+ <span class="note">Documentation for the gem need not be previously generated
49
+ at install-time. If documentation for the gem has not been generated, YARD
50
+ will do this for you on-the-fly. It is therefore possible to speed up your
51
+ gem installs by using `gem install GEMNAME --no-rdoc` without repercussion.
52
+ You can also add this switch to your `~/.gemrc` file so that you don't need
53
+ to re-type it each time. See [this link](http://stackoverflow.com/questions/1789376/how-do-i-make-no-ri-no-rdoc-the-default-for-gem-install)
54
+ for exact instructions.</span>
55
+
56
+ ## Groups support for method listing (0.6.0)
57
+
58
+ You can now organize methods in a class/module into logical separated groups.
59
+ These groups apply lexically and are listed in the order they are defined.
60
+ For instance, to define a group:
61
+
62
+ # @group Rendering an Object
63
+
64
+ # Documentation here
65
+ def foo; end
66
+
67
+ # Extra documentation...
68
+ def bar; end
69
+
70
+ # @group Another Group
71
+
72
+ def aaa; end
73
+
74
+ <span class="note">Note that these `@group` and `@endgroup` declarations are
75
+ not "tags" and should always be separated with at least 1 line of whitespace
76
+ from any other documentation or code.</span>
77
+
78
+ In the above example, "Rendering an Object" will be listed with "foo" and
79
+ "bar" above "Another Group", even though "aaa" comes before the two other
80
+ methods, alphabetically. To end a group, use `@endgroup`. It is not necessary
81
+ to end a group to start a new one, only if there is an object following the
82
+ group that should not belong in any group.
83
+
84
+ # @group Group 1
85
+
86
+ def foo; end
87
+
88
+ # @endgroup
89
+
90
+ # This method should not be listed in any group
91
+ def bar; end
92
+
93
+ ## Single file template (`--one-file`) support (0.6.0)
94
+
95
+ `yardoc` now has the `--one-file` option to generate a single-file template
96
+ for small scripts and libraries. In this case, any comments at the top of
97
+ the script file will be recognized as a README.
98
+
99
+ ## `yard` CLI executable with pluggable commands (0.6.0)
100
+
101
+ <span class="note">The `yardoc` and `yri` commands are not deprecated and can
102
+ continue to be used. They are shortcuts for `yard doc` and `yard ri`
103
+ respectively. However, `yard-graph` has been removed.</span>
104
+
105
+ YARD now has a `yard` executable which combines all pre-existing and new
106
+ commands into a single pluggable command that is both easier to remember and
107
+ access. To get a list of commands, type `yard --help`.
108
+
109
+ If you are a plugin developer, you can create your own `yard` command by first
110
+ subclassing the {YARD::CLI::Command} class and then registering this class
111
+ with the {YARD::CLI::CommandParser.commands} list. For instance:
112
+
113
+ YARD::CLI::CommandParser.commands[:my_command] = MyCommandClass
114
+
115
+ The above line will enable the user to execute `yard my_command [options]`.
116
+
117
+ ## `yard diff` command to object-diff two versions of a project (0.6.0)
118
+
119
+ One of the built-in commands that comes with the new `yard` executable is the
120
+ ability to do object-oriented diffing across multiple versions of the same
121
+ project, either by 2 versions of a gem, or 2 working copies. Just like
122
+ regular diffing tells you which lines have been added/removed in a file,
123
+ object diffing allows you to see what classes/methods/modules have been
124
+ added/removed between versions of a codebase.
125
+
126
+ For an overview of how to use `yard diff`, see [YARD Object Oriented Diffing](http://gnuu.org/2010/06/26/yard-object-oriented-diffing/).
127
+
128
+ ## `yard stats` to display statistics and undocumented objects (0.6.0)
129
+
130
+ YARD now outputs the following statistics when `yard stats` is run:
131
+
132
+ Files: 125
133
+ Modules: 35 ( 4 undocumented)
134
+ Classes: 139 ( 29 undocumented)
135
+ Constants: 53 ( 20 undocumented)
136
+ Methods: 602 ( 70 undocumented)
137
+ 85.16% documented
138
+
139
+ Note that these statistics are based on what you have set to show in your
140
+ documentation. If you use `@private` tags and/or do not display
141
+ private/protected methods in your documentation, these will not show up as
142
+ undocumented. Therefore this metric is contextual.
143
+
144
+ You can also specifically list all undocumented objects (and their file
145
+ locations) with the `--list-undoc` option.
146
+
147
+ ## Added `--asset` option to `yardoc` (0.6.0)
148
+
149
+ The `yardoc` command can now take the `--asset` option to copy over
150
+ files/directories (recursively) to the output path after generating
151
+ documentation. The format of the argument is "from:to" where from is the
152
+ source path and to is the destination. For instance, YARD uses the following
153
+ syntax in the `.yardopts` file to copy over image assets from the
154
+ 'docs/images' directory into the 'images' directory after generating HTML:
155
+
156
+ --asset docs/images:images
157
+
158
+ ## New template API (0.6.0)
159
+
160
+ The new template API allows for easier insertion of sections within an
161
+ inherited template. You should no longer need to insert by index, an
162
+ error-prone process that could break when a template is updated. Instead of:
163
+
164
+ sections.last.place(:my_section).before(:another_section)
165
+
166
+ use:
167
+
168
+ sections.place(:my_section).before_any(:another_section)
169
+
170
+ You can see more in the {file:docs/Templates.md#Inserting_and_Traversing_Sections}
171
+ document.
172
+
173
+ ## HTML template now adds inline Table of Contents for extra files pages (0.6.0)
174
+
175
+ A table of contents is now generated dynamically using JavaScript for extra
176
+ file pages (such as README's, or this document). It is generated based off the
177
+ headers (h1,h2,... tags) used in the document, and can be floated to the
178
+ right or listed inline on the page.
179
+
180
+ ## Ad-hoc tag registration via `yardoc` CLI (`--tag`, etc.) (0.6.0)
181
+
182
+ Simple meta-data tags can now be added at the command-line and registered to
183
+ display in templates in a number of pre-defined ways. For instance, to create
184
+ a freeform text tag, use the following:
185
+
186
+ --tag my_tag_name:"My Tag Title"
187
+
188
+ You can also create a "typed" tag (similar to `@return`), a typed named tag
189
+ (similar to `@param`) as well as various combinations. The full list of
190
+ options are listed in `yardoc --help` under the "Tag Options" section.
191
+
192
+ If you wish to create a tag to store data but do not wish to show this data
193
+ in the templates, use the `--hide-tag` option to hide it from generated output:
194
+
195
+ --hide-tag my_tag_name
196
+
197
+ ## Added `--transitive-tags` to register transitive tags (0.6.0)
198
+
199
+ Transitive tags are tags that apply to all descendents of a namespace (class
200
+ or module) when documented on that namespace. For instance, the `@since` tag
201
+ is a transitive tag. Applying `@since` to a class will automatically apply
202
+ `@since` to all methods in the class. Creating a `@since` tag directly on a
203
+ method will override the inherited value.
204
+
205
+ You can specify transitive tags on the command-line by using this option. Note
206
+ that the tags must already exist (built-in or created with the `--tag` option)
207
+ to be specified as transitive. If you wish to do this programmatically, see
208
+ the {YARD::Tags::Library.transitive_tags} attribute.
209
+
210
+ ## `yardoc` now displays RDoc-like statistics (`--no-stats` to hide) (0.6.0)
211
+
212
+ As seen in the `yard stats` feature overview, `yardoc` displays RDoc-like
213
+ statistics when it is run. The output is equivalent to typing `yard stats`.
214
+ To hide this output when yardoc is run, use `--no-stats`.
215
+
216
+ ## `yri` now works on constants (0.6.0)
217
+
218
+ Templates have now been added for text view of constants, which displays any
219
+ documentation and the constant value.
220
+
1
221
  What's New in 0.5.x?
2
222
  ====================
3
223
 
@@ -205,7 +425,7 @@ that existed but were previously omitted from the generated documentation.
205
425
 
206
426
  There is also a new templating engine (based on the tadpole templating library)
207
427
  to allow for much more user customization. You can read about it in
208
- {file:Templates.md}.
428
+ {file:docs/Templates.md}.
209
429
 
210
430
  yardoc `--query` argument
211
431
  -------------------------
@@ -252,7 +472,7 @@ use this tag sparingly, as it is not meant to be an equivalent to RDoc's
252
472
  This tag exists so that you can create a query (`--query !@private`) to
253
473
  ignore all of these private objects in your documentation. You can also
254
474
  use the new `--no-private` switch, which is a shortcut to the afformentioned
255
- query. You can read more about the new tags in the {file:GettingStarted.md}
475
+ query. You can read more about the new tags in the {file:docs/GettingStarted.md}
256
476
  guide.
257
477
 
258
478
  Default rake task is now `rake yard`
@@ -7,6 +7,7 @@ unless defined? Gem::DocManager.load_yardoc
7
7
  overwrite_accessor(:has_rdoc) { @has_rdoc }
8
8
  overwrite_accessor(:has_rdoc=) {|v| @has_rdoc = v }
9
9
 
10
+ # @since 0.5.3
10
11
  def has_yardoc=(value)
11
12
  @has_rdoc = 'yard'
12
13
  end
data/lib/yard.rb CHANGED
@@ -1,7 +1,13 @@
1
1
  module YARD
2
- VERSION = "0.5.8"
2
+ VERSION = "0.6.0"
3
+
4
+ # The root path for YARD source libraries
3
5
  ROOT = File.expand_path(File.dirname(__FILE__))
6
+
7
+ # The root path for YARD builtin templates
4
8
  TEMPLATE_ROOT = File.join(ROOT, '..', 'templates')
9
+
10
+ # The location where YARD stores user-specific settings
5
11
  CONFIG_DIR = File.expand_path('~/.yard')
6
12
 
7
13
  # An alias to {Parser::SourceParser}'s parsing method
data/lib/yard/autoload.rb CHANGED
@@ -3,10 +3,16 @@ def __p(*path) File.join(YARD::ROOT, 'yard', *path) end
3
3
 
4
4
  module YARD
5
5
  module CLI # Namespace for command-line interface components
6
- autoload :Base, __p('cli/base')
7
- autoload :YardGraph, __p('cli/yard_graph')
8
- autoload :Yardoc, __p('cli/yardoc')
9
- autoload :YRI, __p('cli/yri')
6
+ autoload :Command, __p('cli/command')
7
+ autoload :CommandParser, __p('cli/command_parser')
8
+ autoload :Diff, __p('cli/diff')
9
+ autoload :Gems, __p('cli/gems')
10
+ autoload :Graph, __p('cli/graph')
11
+ autoload :Help, __p('cli/help')
12
+ autoload :Server, __p('cli/server')
13
+ autoload :Stats, __p('cli/stats')
14
+ autoload :Yardoc, __p('cli/yardoc')
15
+ autoload :YRI, __p('cli/yri')
10
16
  end
11
17
 
12
18
  # A "code object" is defined as any entity in the Ruby language.
@@ -127,6 +133,38 @@ module YARD
127
133
  autoload :YardocSerializer, __p('serializers/yardoc_serializer')
128
134
  end
129
135
 
136
+ # Namespace for classes and modules that handle serving documentation over HTTP
137
+ # @since 0.6.0
138
+ module Server
139
+ module Commands
140
+ autoload :Base, __p('server/commands/base')
141
+ autoload :DisplayFileCommand, __p('server/commands/display_file_command')
142
+ autoload :DisplayObjectCommand, __p('server/commands/display_object_command')
143
+ autoload :FramesCommand, __p('server/commands/frames_command')
144
+ autoload :ListCommand, __p('server/commands/list_command')
145
+ autoload :ListClassesCommand, __p('server/commands/list_command')
146
+ autoload :ListFilesCommand, __p('server/commands/list_command')
147
+ autoload :ListMethodsCommand, __p('server/commands/list_command')
148
+ autoload :LibraryCommand, __p('server/commands/library_command')
149
+ autoload :LibraryIndexCommand, __p('server/commands/library_index_command')
150
+ autoload :SearchCommand, __p('server/commands/search_command')
151
+ autoload :StaticFileCommand, __p('server/commands/static_file_command')
152
+ end
153
+
154
+ autoload :Adapter, __p('server/adapter')
155
+ autoload :DocServerSerializer, __p('server/doc_server_serializer')
156
+ autoload :DocServerHelper, __p('server/doc_server_helper')
157
+ autoload :FinishRequest, __p('server/adapter')
158
+ autoload :LibraryVersion, __p('server/library_version')
159
+ autoload :NotFoundError, __p('server/adapter')
160
+ autoload :RackAdapter, __p('server/rack_adapter')
161
+ autoload :RackMiddleware, __p('server/rack_adapter')
162
+ autoload :Router, __p('server/router')
163
+ autoload :StaticCaching, __p('server/static_caching')
164
+ autoload :WebrickAdapter, __p('server/webrick_adapter')
165
+ autoload :WebrickServlet, __p('server/webrick_adapter')
166
+ end
167
+
130
168
  module Tags # Namespace for Tag components
131
169
  autoload :DefaultFactory, __p('tags/default_factory')
132
170
  autoload :DefaultTag, __p('tags/default_tag')
@@ -139,7 +177,8 @@ module YARD
139
177
  autoload :TagFormatError, __p('tags/tag_format_error')
140
178
  end
141
179
 
142
- module Templates # Namespace for templating system
180
+ # Namespace for templating system
181
+ module Templates
143
182
  module Helpers # Namespace for template helpers
144
183
  autoload :BaseHelper, __p('templates/helpers/base_helper')
145
184
  autoload :FilterHelper, __p('templates/helpers/filter_helper')
@@ -153,8 +192,9 @@ module YARD
153
192
  end
154
193
 
155
194
  autoload :Engine, __p('templates/engine')
156
- autoload :Template, __p('templates/template')
157
195
  autoload :ErbCache, __p('templates/erb_cache')
196
+ autoload :Section, __p('templates/section')
197
+ autoload :Template, __p('templates/template')
158
198
  end
159
199
 
160
200
  autoload :Docstring, __p('docstring')
@@ -6,11 +6,14 @@ module YARD
6
6
  # the option parser
7
7
  #
8
8
  # @abstract
9
- class Base
10
- def initialize
11
- log.show_backtraces = false
12
- end
13
-
9
+ # @since 0.6.0
10
+ class Command
11
+ # Helper method to run the utility on an instance.
12
+ # @see #run
13
+ def self.run(*args) new.run(*args) end
14
+
15
+ def description; '' end
16
+
14
17
  protected
15
18
 
16
19
  # Adds a set of common options to the tail of the OptionParser
@@ -20,6 +23,17 @@ module YARD
20
23
  def common_options(opts)
21
24
  opts.separator ""
22
25
  opts.separator "Other options:"
26
+ opts.on('-e', '--load FILE', 'A Ruby script to load before the source tree is parsed.') do |file|
27
+ begin
28
+ require(file.gsub(/\.rb$/, ''))
29
+ rescue LoadError
30
+ log.error "The file `#{file}' could not be loaded, check the path and try again."
31
+ exit
32
+ end
33
+ end
34
+ opts.on('--legacy', 'Use old style Ruby parser and handlers. Always on in 1.8.x.') do
35
+ YARD::Parser::SourceParser.parser_type = :ruby18
36
+ end
23
37
  opts.on_tail('-q', '--quiet', 'Show no warnings.') { log.level = Logger::ERROR }
24
38
  opts.on_tail('--verbose', 'Show more information.') { log.level = Logger::INFO }
25
39
  opts.on_tail('--debug', 'Show debugging information.') { log.level = Logger::DEBUG }
@@ -27,7 +41,7 @@ module YARD
27
41
  opts.on_tail('-v', '--version', 'Show version.') { puts "yard #{YARD::VERSION}"; exit }
28
42
  opts.on_tail('-h', '--help', 'Show this help.') { puts opts; exit }
29
43
  end
30
-
44
+
31
45
  # Parses the option and gracefully handles invalid switches
32
46
  #
33
47
  # @param [OptionParser] opts the option parser object
@@ -0,0 +1,87 @@
1
+ module YARD
2
+ module CLI
3
+ # This class parses a command name out of the +yard+ CLI command and calls
4
+ # that command in the form:
5
+ #
6
+ # $ yard command_name [options]
7
+ #
8
+ # If no command or arguments are specified, or if the arguments immediately
9
+ # begin with a +--opt+ (not +--help+), the {default_command} will be used
10
+ # (which itself defaults to +:doc+).
11
+ #
12
+ # == Adding a Command
13
+ #
14
+ # To add a custom command via plugin, create a mapping in {commands} from
15
+ # the Symbolic command name to the {Command} class that implements the
16
+ # command. To implement a command, see the documentation for the {Command}
17
+ # class.
18
+ #
19
+ # @see Command
20
+ # @see commands
21
+ # @see default_command
22
+ class CommandParser
23
+ class << self
24
+ # @return [Hash{Symbol => Command}] the mapping of command names to
25
+ # command classes to parse the user command.
26
+ attr_accessor :commands
27
+
28
+ # @return [Symbol] the default command name to use when no options
29
+ # are specified or
30
+ attr_accessor :default_command
31
+ end
32
+
33
+ self.commands = SymbolHash[
34
+ :diff => Diff,
35
+ :doc => Yardoc,
36
+ :gems => Gems,
37
+ :graph => Graph,
38
+ :help => Help,
39
+ :ri => YRI,
40
+ :server => Server,
41
+ :stats => Stats
42
+ ]
43
+
44
+ self.default_command = :doc
45
+
46
+ # Convenience method to create a new CommandParser and call {#run}
47
+ # @return (see #run)
48
+ def self.run(*args) new.run(*args) end
49
+
50
+ def initialize
51
+ log.show_backtraces = false
52
+ end
53
+
54
+ # Runs the {Command} object matching the command name of the first
55
+ # argument.
56
+ # @return [void]
57
+ def run(*args)
58
+ unless args == ['--help']
59
+ if args.size == 0 || args.first =~ /^-/
60
+ command_name = self.class.default_command
61
+ else
62
+ command_name = args.first.to_sym
63
+ args.shift
64
+ end
65
+ if commands.has_key?(command_name)
66
+ return commands[command_name].run(*args)
67
+ end
68
+ end
69
+ list_commands
70
+ end
71
+
72
+ private
73
+
74
+ def commands; self.class.commands end
75
+
76
+ def list_commands
77
+ puts "Usage: yard <command> [options]"
78
+ puts
79
+ puts "Commands:"
80
+ commands.keys.sort_by {|k| k.to_s }.each do |command_name|
81
+ command = commands[command_name].new
82
+ puts "%-8s %s" % [command_name, command.description]
83
+ end
84
+ end
85
+ end
86
+ end
87
+ end