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/README.md CHANGED
@@ -8,8 +8,8 @@ YARD: Yay! A Ruby Documentation Tool
8
8
  **Contributors**: See Contributors section below
9
9
  **Copyright**: 2007-2010
10
10
  **License**: MIT License
11
- **Latest Version**: 0.5.8 (codename "The Longest")
12
- **Release Date**: June 22nd 2010
11
+ **Latest Version**: 0.6.0 (codename "The Cubic")
12
+ **Release Date**: August 29th 2010
13
13
 
14
14
  Synopsis
15
15
  --------
@@ -37,7 +37,7 @@ important information about objects, such as what parameters they take and what
37
37
  they are expected to be, what type a
method should return, what exceptions it can
38
38
  raise, if it is deprecated, etc.. It also allows information to be better (and more
39
39
  consistently) organized
during the output generation phase. You can find a list
40
- of tags in the {file:Tags.md#taglist Tags.md} file.
40
+ of tags in the {file:docs/Tags.md#taglist Tags.md} file.
41
41
 
42
42
  YARD also supports an optional "types" declarations for certain tags.

43
43
  This allows the developer to document type signatures for ruby methods and

@@ -63,26 +63,26 @@ object returned by the method, and although this may be obvious for a

63
63
  'reverse' method, it becomes very useful when the method name may not be as

64
64
  descriptive.

65
65
 
66
- **3. Custom Constructs and Extensibility of YARD**: Take for instance the example:

66
+ **3. Custom Constructs and Extensibility of YARD**: YARD is designed to example:
be
67
+ extended and customized by plugins. Take for instance the scenario where you
68
+ need to document the following code:

67
69
 
68
- class A
69
- class << self
70
- def define_name(name, value)
71
- class_eval "def #{name}; #{value.inspect} end"
72
- end
73
- end
74
-
75
- # Documentation string for this name
76
- define_name :publisher, "O'Reilly"
70
+ class List
71
+ # Sets the publisher name for the list.
72
+ cattr_accessor :publisher
77
73
  end
78
74
 
79
75
  This custom declaration provides dynamically generated code that is hard for a
80
76
  documentation tool to properly document without help from the developer. To

81
77
  ease the pains of manually documenting the procedure, YARD can be extended by

82
- the developer to handled the `define_name` construct and add the required

83
- method to the defined methods of the class with its documentation. This makes

78
+ the developer to handle the `cattr_accessor` construct and automatically the required
create
79
+ an attribute on the class with the associated documentation. This makes

84
80
  documenting external API's, especially dynamic ones, a lot more consistent for
85
81
  consumption by the users.

82
+
83
+ YARD is also designed for extensibility everywhere else, allowing you to add
84
+ support for new programming languages, new data structures and even where/how
85
+ data is stored.
86
86
 
87
87
  **4. Raw Data Output**: YARD also outputs documented objects as raw data (the

88
88
  dumped Namespace) which can be reloaded to do generation at a later date, or

@@ -95,6 +95,13 @@ as throwing all the documentation into a database. Another useful way of

95
95
  exploiting this raw data format would be to write tools that can auto generate
96
96
  test cases, for example, or show possible unhandled exceptions in code.

97
97
 
98
+ **5. Local Documentation Server**: YARD can serve documentation for projects
99
+ or installed gems (similar to `gem server`) with the added benefit of dynamic
100
+ searching, as well as live reloading. Using the live reload feature, you can
101
+ document your code and immediately preview the results by refreshing the page;
102
+ YARD will do all the work in re-generating the HTML. This makes writing
103
+ documentation a much faster process.
104
+
98
105
 
99
106
  Installing
100
107
  ----------
@@ -119,21 +126,32 @@ Usage
119
126
  -----
120
127
 
121
128
  There are a couple of ways to use YARD. The first is via command-line, and the
122
- second is the Rake task. There are also the `yard-graph` and `yri` binaries to
123
- look at, if you want to poke around.
129
+ second is the Rake task.
130
+
131
+ **1. yard Command-line Tool**
132
+
133
+ YARD comes packaged with a executable named `yard` which can control the many
134
+ functions of YARD, including generating documentation, graphs running the
135
+ YARD server, and so on. To view a list of available YARD commands, type:
136
+
137
+ $ yard --help
138
+
139
+ Plugins can also add commands to the `yard` executable to provide extra
140
+ functionality.
141
+
142
+ #### Generating Documentation
124
143
 
125
- **1. yardoc Command-line Tool**
144
+ <span class="note">The `yardoc` executable is a shortcut for `yard doc`.</span>
126
145
 
127
- The most obvious way to run YARD is to run the `yardoc` binary file that comes
128
- with YARD. This will, among other things, generate the HTML documentation for
129
- your project code. You can type `yardoc --help` to see the options
130
- that YARD provides, but the easiest way to generate docs for your code is to
131
- simply type `yardoc` in your project root. This will assume your files are
146
+ The most common command you will probably use is `yard doc`, or `yardoc`. You
147
+ can type `yardoc --help` to see the options that YARD provides, but the
148
+ easiest way to generate docs for your code is to simply type `yardoc` in your
149
+ project root. This will assume your files are
132
150
  located in the `lib/` directory. If they are located elsewhere, you can specify
133
151
  paths and globs from the commandline via:
134
152
 
135
153
  $ yardoc 'lib/**/*.rb' 'app/**/*.rb' ...etc...
136
-
154
+
137
155
  The tool will generate a `.yardoc` file which will store the cached database
138
156
  of your source code and documentation. If you want to re-generate your docs
139
157
  with another template you can simply use the `--use-cache` (or -c)
@@ -164,7 +182,7 @@ You can also add a `.yardopts` file to your project directory which lists
164
182
  the switches separated by whitespace (newlines or space) to pass to yardoc
165
183
  whenever it is run.
166
184
 
167
- <h4>Queries</h4>
185
+ #### Queries
168
186
 
169
187
  The `yardoc` tool also supports a `--query` argument to only include objects
170
188
  that match a certain data or meta-data query. The query syntax is Ruby, though
@@ -220,12 +238,40 @@ separator. Only modules, classes and constants should use "::".
220
238
  You can also do lookups on any installed gems. Just make sure to build the
221
239
  .yardoc databases for installed gems with:
222
240
 
223
- $ sudo yardoc --build-gems
241
+ $ sudo yard gems
224
242
 
225
243
  If you don't have sudo access, it will write these files to your `~/.yard`
226
244
  directory. `yri` will also cache lookups there.
227
245
 
228
- **4. `yard-graph` Graphviz Generator**
246
+ **4. `yard server` Documentation Server**
247
+
248
+ The `yard server` command serves documentation for a local project or all installed
249
+ RubyGems. To serve documentation for a project you are working on, simply run:
250
+
251
+ $ yard server
252
+
253
+ And the project inside the current directory will be parsed (if the source has
254
+ not yet been scanned by YARD) and served at [http://localhost:8808](http://localhost:8808).
255
+
256
+ #### Live Reloading
257
+
258
+ If you want to serve documentation on a project while you document it so that
259
+ you can preview the results, simply pass `--reload` (`-r`) to the above command
260
+ and YARD will reload any changed files on each request. This will allow you to
261
+ change any documentation in the source and refresh to see the new contents.
262
+
263
+ #### Serving Gems
264
+
265
+ To serve documentation for all installed gems, call:
266
+
267
+ $ yard server --gems
268
+
269
+ This will also automatically build documentation for any gems that have not
270
+ been previously scanned. Note that in this case there will be a slight delay
271
+ between the first request of a newly parsed gem.
272
+
273
+
274
+ **5. `yard graph` Graphviz Generator**
229
275
 
230
276
  You can use `yard-graph` to generate dot graphs of your code. This, of course,
231
277
  requires [Graphviz](http://www.graphviz.org) and the `dot` binary. By default
@@ -236,12 +282,25 @@ option to show mixin inclusions. You can output to stdout or a file, or pipe dir
236
282
  to `dot`. The same public, protected and private visibility rules apply to yard-graph.
237
283
  More options can be seen by typing `yard-graph --help`, but here is an example:
238
284
 
239
- $ yard-graph --protected --full --dependencies
285
+ $ yard graph --protected --full --dependencies
240
286
 
241
287
 
242
288
  Changelog
243
289
  ---------
244
290
 
291
+ - **August.28.10**: 0.6.0 release
292
+ - Added dynamic local documentation server
293
+ - Added @group/@endgroup declarations to organize methods into groups
294
+ - Added `yard` executable to serve as main CLI tool with pluggable commands
295
+ - Added `--asset` switch to `yardoc` to copy files/dirs to output dir
296
+ - Added ability to register/manipulate tags via CLI (`--tag`, etc.)
297
+ - Added `yard diff` command
298
+ - Added statistics to `yardoc` output (and `yard stats` command)
299
+ - Added Javascript generated Table of Contents to file pages
300
+ - Updated various APIs
301
+ - Removed `yard-graph` executable
302
+ - See more changes in the {file:docs/WhatsNew.md what's new document}
303
+
245
304
  - **June.22.10**: 0.5.8 release
246
305
  - Merge fix from 0.6 branch for --no-private visibility checking
247
306
 
@@ -254,7 +313,7 @@ Changelog
254
313
 
255
314
  - **June.12.10**: 0.5.6 release
256
315
  - Bug fixes for RubyGems plugin, `has_rdoc=false` should now work
257
- - New API for registering custom parsers. See {file:WhatsNew.md}
316
+ - New API for registering custom parsers. See {file:docs/WhatsNew.md}
258
317
 
259
318
  - **May.22.10**: 0.5.5 release
260
319
  - Various bug fixes
@@ -281,7 +340,7 @@ Changelog
281
340
  - Added plugin support
282
341
  - New `@abstract` and `@private` tags
283
342
  - Changed default rake task to `rake yard`
284
- - Read about changes in {file:WhatsNew.md}
343
+ - Read about changes in {file:docs/WhatsNew.md}
285
344
 
286
345
  - **August.13.09**: 0.2.3.5 release
287
346
  - Minor bug fixes.
@@ -310,7 +369,7 @@ Changelog
310
369
  RDoc. To take advantage of this plugin, set `has_rdoc = 'yard'` in your
311
370
  .gemspec file.
312
371
 
313
- - **Jun.07.09**: 0.2.3 release. See the {file:WhatsNew.md} file for a
372
+ - **Jun.07.09**: 0.2.3 release. See the {file:docs/WhatsNew.md} file for a
314
373
  list of important new features.
315
374
 
316
375
  - **Jun.16.08**: 0.2.2 release. This is the largest changset since yard's
@@ -330,20 +389,22 @@ Contributors
330
389
 
331
390
  Special thanks to the following people for submitting patches:
332
391
 
333
- * Aman Gupta
334
- * Benjamin Bock
335
- * Denis Defreyne
392
+ * Nathan Weizenbaum
393
+ * Nick Plante
394
+ * Michael Edgar
395
+ * Yehuda Katz
336
396
  * Duane Johnson
397
+ * Postmodern
398
+ * Pieter van de Bruggen
399
+ * Leonid Borisenko
400
+ * Jeff Rafter
337
401
  * Elliottcable
338
402
  * James Rosen
339
- * Jeff Rafter
340
- * Leonid Borisenko
341
- * Loren Segal
342
- * Michael Edgar
343
- * Nathan Weizenbaum
344
- * Postmodern
345
- * Yehuda Katz
346
-
403
+ * Jake Kerr
404
+ * Gabriel Horner
405
+ * Denis Defreyne
406
+ * Benjamin Bock
407
+ * Aman Gupta
347
408
 
348
409
  Copyright
349
410
  ---------
data/Rakefile CHANGED
@@ -1,6 +1,7 @@
1
1
  require File.dirname(__FILE__) + '/lib/yard'
2
2
  require 'rbconfig'
3
3
 
4
+ YARD::VERSION.replace(ENV['YARD_VERSION']) if ENV['YARD_VERSION']
4
5
  WINDOWS = (Config::CONFIG['host_os'] =~ /mingw|win32|cygwin/ ? true : false) rescue false
5
6
  SUDO = WINDOWS ? '' : 'sudo'
6
7
 
@@ -8,7 +9,8 @@ task :default => :specs
8
9
 
9
10
  desc "Builds the gem"
10
11
  task :gem do
11
- sh "gem build yard.gemspec"
12
+ load 'yard.gemspec'
13
+ Gem::Builder.new(SPEC).build
12
14
  end
13
15
 
14
16
  desc "Installs the gem"
@@ -42,5 +44,4 @@ end
42
44
 
43
45
  YARD::Rake::YardocTask.new do |t|
44
46
  t.options += ['--title', "YARD #{YARD::VERSION} Documentation"]
45
- t.after = lambda { `cp -R docs/images/ doc/images/` }
46
47
  end
@@ -1,5 +1,6 @@
1
1
  require "benchmark"
2
- require 'lib/yard'
2
+ require 'yard'
3
+ require 'logger'
3
4
 
4
5
  PATH_ORDER = [
5
6
  'lib/yard/autoload.rb',
data/bin/yard ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../lib/yard'
3
+
4
+ YARD::CLI::CommandParser.run(*ARGV)
data/bin/yard-graph CHANGED
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
2
  require File.dirname(__FILE__) + '/../lib/yard'
3
3
 
4
- YARD::CLI::YardGraph.run(*ARGV)
4
+ YARD::CLI::Graph.run(*ARGV)
data/bin/yard-server ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../lib/yard'
3
+
4
+ YARD::CLI::Server.run(*ARGV)
@@ -113,7 +113,7 @@ Symbols:
113
113
  List of Tags
114
114
  ------------
115
115
 
116
- A list of tags can be found in {file:Tags.md#taglist}
116
+ A list of tags can be found in {file:docs/Tags.md#taglist}
117
117
 
118
118
  Other Extended Syntax
119
119
  ---------------------
@@ -123,7 +123,7 @@ Other Extended Syntax
123
123
  To minimize rewriting of documentation and to ease maintenance, a special
124
124
  tag syntax is allowed to reference tags from other objects. Doing this allows
125
125
  a tag to be added as meta-data for multiple objects. A full example of this
126
- syntax is found in the {file:Tags.md#reftags Tags} file.
126
+ syntax is found in the {file:docs/Tags.md#reftags Tags} file.
127
127
 
128
128
  **Inter-Document Links**
129
129
 
@@ -152,22 +152,22 @@ Extending YARD
152
152
  There are many ways to extend YARD to support non-standard Ruby syntax (DSLs),
153
153
  add new meta-data tags or programmatically access the intermediate metadata
154
154
  and documentation from code. An overview of YARD's full architecture can be
155
- found in the {file:Overview.md} document.
155
+ found in the {file:docs/Overview.md} document.
156
156
 
157
- For information on adding support for Ruby DSLs, see the {file:Handlers.md}
158
- and {file:Parser.md} architecture documents.
157
+ For information on adding support for Ruby DSLs, see the {file:docs/Handlers.md}
158
+ and {file:docs/Parser.md} architecture documents.
159
159
 
160
- For information on adding extra tags, see {file:Tags.md}.
160
+ For information on adding extra tags, see {file:docs/Tags.md}.
161
161
 
162
162
  For information on accessing the data YARD stores about your documentation,
163
- look at the {file:CodeObjects.md} architecture document.
163
+ look at the {file:docs/CodeObjects.md} architecture document.
164
164
 
165
165
  <a name="templating"></a>
166
166
  Templating YARD
167
167
  ===============
168
168
 
169
169
  In many cases you may want to change the style of YARD's templates or add extra
170
- information after extending it. The {file:Templates.md} architecture
170
+ information after extending it. The {file:docs/Templates.md} architecture
171
171
  document covers the basics of how YARD's templating system works.
172
172
 
173
173
  <a name="plugins"></a>
data/docs/Handlers.md CHANGED
@@ -4,14 +4,14 @@ Handlers Architecture
4
4
  Handlers allow the processing of parsed source code. Handling is done after
5
5
  parsing to abstract away the implementation details of lexical and semantic
6
6
  analysis on source and to only deal with the logic regarding recognizing
7
- source statements as {file:CodeObjects.md code objects}.
7
+ source statements as {file:docs/CodeObjects.md code objects}.
8
8
 
9
9
  ![Handlers Architecture Class Diagram](images/handlers-class-diagram.png)
10
10
 
11
11
  The Pipeline
12
12
  ------------
13
13
 
14
- After the {file:Parser.md parser component} finishes analyzing the
14
+ After the {file:docs/Parser.md parser component} finishes analyzing the
15
15
  source, it is handed off for post-processing to the {YARD::Handlers::Processor}
16
16
  class, which is responsible for traversing the set of statements given by
17
17
  the parser and delegating them to matching handlers. Handlers match when the
@@ -51,7 +51,7 @@ class method. A very simple handler that handles a module definition would be:
51
51
  end
52
52
 
53
53
  For details on what nodes are, and what node types are, see the
54
- {file:Parser.md parser architecture document}.
54
+ {file:docs/Parser.md parser architecture document}.
55
55
 
56
56
  In this case the node type being handled is the `:module` type. More than one
57
57
  node type or `handles` declarations may describe a single handler, for instance,
@@ -89,7 +89,7 @@ Creating a new Code Object
89
89
  --------------------------
90
90
 
91
91
  Usually (but not always) handling is performed to create new code objects to add
92
- to the registry (for information about code objects, see {file:CodeObjects.md this document}).
92
+ to the registry (for information about code objects, see {file:docs/CodeObjects.md this document}).
93
93
  Code objects should simply be created and added to the existing `namespace`. This
94
94
  will be enough to add them to the registry. There is also a convenience
95
95
  {YARD::Handlers::Base#register register} method which quickly sets standard attributed
@@ -132,7 +132,7 @@ Because the legacy handler uses the legacy parser and therefore a different kind
132
132
  of AST, there are subtle differences in the handler API. Most importantly, the
133
133
  `handles` method usually deals with either lexical tokens or source code as a string
134
134
  or RegExp object. The statement object, similarly, is made up of lexical tokens instead
135
- of semantically parsed nodes (this is described in the {file:Parser.md parser document}).
135
+ of semantically parsed nodes (this is described in the {file:docs/Parser.md parser document}).
136
136
 
137
137
  The module example above can be rewritten as a legacy handler as follows:
138
138
 
data/docs/Overview.md CHANGED
@@ -30,10 +30,10 @@ This component is made up of four sub-components, each of which have separate
30
30
  tasks during the data gathering process (*note: the tag architecture is not*
31
31
  *shown in the class diagram*). These sub-components are:
32
32
 
33
- * {file:Parser.md Parser Architecture}
34
- * {file:Handlers.md Handler Architecture}
35
- * {file:CodeObjects.md Code Object Architecture}
36
- * {file:Tags.md Tag Architecture}
33
+ * {file:docs/Parser.md Parser Architecture}
34
+ * {file:docs/Handlers.md Handler Architecture}
35
+ * {file:docs/CodeObjects.md Code Object Architecture}
36
+ * {file:docs/Tags.md Tag Architecture}
37
37
 
38
38
  The parser component reads source files and converts it into a set of statements
39
39
  which the handlers then process, creating code objects which in turn create tags
@@ -57,4 +57,4 @@ Post Processing & Templating System
57
57
  This component handles processing of objects from the registry through a templating
58
58
  engine that allows output to a variety of formats. Practically speaking, this is
59
59
  where templates can be implemented to change the design, output or structure of
60
- the data. See {file:Templates.md Templates Architecture} for a complete overview.
60
+ the data. See {file:docs/Templates.md Templates Architecture} for a complete overview.
data/docs/Parser.md CHANGED
@@ -3,7 +3,7 @@ Parser Architecture
3
3
 
4
4
  The parser component of YARD is the first component in the data processing pipeline
5
5
  that runs before any handling is done on the source. The parser is meant to translate
6
- the source into a set of statements that can be understood by the {file:Handlers.md Handlers}
6
+ the source into a set of statements that can be understood by the {file:docs/Handlers.md Handlers}
7
7
  that run immediately afterwards.
8
8
 
9
9
  The important classes are described in the class diagram of the entire parser
data/docs/Tags.md CHANGED
@@ -259,7 +259,7 @@ Programmatic API
259
259
  Accessing Tag Information
260
260
  -------------------------
261
261
 
262
- Tag metadata is added when a {YARD::Docstring} is added to a {file:CodeObjects.md code object}
262
+ Tag metadata is added when a {YARD::Docstring} is added to a {file:docs/CodeObjects.md code object}
263
263
  using the {YARD::CodeObjects::Base#docstring=} attribute. In addition to adding
264
264
  conventional comments, tags are parsed and associated with the object. The easiest
265
265
  way to access tags on an object is to use the {YARD::CodeObjects::Base#tag} and `#tags`
data/docs/Templates.md CHANGED
@@ -223,8 +223,8 @@ For instance, the first line in `default/class/html/setup.rb` is:
223
223
  This includes the 'default/module/html', which means it also includes 'default/module'
224
224
  by extension. This allows class to make use of any of module's erb files.
225
225
 
226
- Inserting Sections
227
- ------------------
226
+ Inserting and Traversing Sections
227
+ ---------------------------------
228
228
 
229
229
  The ability to insert sections was mentioned above. The class template, for
230
230
  instance, will modify the #init method to insert class specific sections:
@@ -238,10 +238,31 @@ instance, will modify the #init method to insert class specific sections:
238
238
 
239
239
  Observe how sections has been modified after the super method was called (the
240
240
  super method would have been defined in `default/module/setup.rb`). The
241
- custom method {Array#place} is added by YARD to allow sections to be inserted
242
- before or after another section by it's given name rather than index. This
243
- allows the overriding of templates in a way that does not depend on where
244
- the section is located (since it may have been overriden by another module).
241
+ `sections` object is of the {YARD::Templates::Section} class and allows sections to be inserted
242
+ before or after another section using {Array#place} by it's given name rather
243
+ than index. This allows the overriding of templates in a way that does not
244
+ depend on where the section is located (since it may have been overriden by
245
+ another module).
246
+
247
+ You can also use `sections[:name]` to find the first child section named `:name`.
248
+ For instance, with the following sections declaration:
249
+
250
+ sections :a, [:b, :c, [:d]]
251
+
252
+ You can get to the :d section with:
253
+
254
+ sections[:a][:c][:d]
255
+
256
+ You can use this to insert a section inside a nested set without using indexed
257
+ access. The following command would result in `[:a, [:b, :c, [:d, :e]]]`:
258
+
259
+ sections[:a][:c].place(:e).after(:d)
260
+
261
+ There are also two methods, {Insertion#before_any} and {Insertion#after_any},
262
+ which allow you to insert sections before or after the first matching section name
263
+ recursively. The above example could simply be rewritten as:
264
+
265
+ sections.place(:e).after_any(:d)
245
266
 
246
267
  Overriding Templates by Registering a Template Path
247
268
  ---------------------------------------------------