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.
- data/.yardopts +1 -0
- data/ChangeLog +723 -0
- data/README.md +16 -6
- data/docs/CodeObjects.md +10 -16
- data/docs/GettingStarted.md +232 -32
- data/docs/Glossary.md +1 -2
- data/docs/Handlers.md +10 -16
- data/docs/Overview.md +14 -13
- data/docs/Parser.md +13 -22
- data/docs/Tags.md +209 -16
- data/docs/Templates.md +237 -26
- data/docs/WhatsNew.md +178 -2
- data/lib/yard.rb +13 -10
- data/lib/yard/autoload.rb +22 -18
- data/lib/yard/cli/command.rb +13 -12
- data/lib/yard/cli/command_parser.rb +20 -19
- data/lib/yard/cli/config.rb +19 -19
- data/lib/yard/cli/diff.rb +46 -21
- data/lib/yard/cli/gems.rb +11 -11
- data/lib/yard/cli/graph.rb +13 -13
- data/lib/yard/cli/help.rb +1 -1
- data/lib/yard/cli/list.rb +22 -0
- data/lib/yard/cli/server.rb +17 -17
- data/lib/yard/cli/stats.rb +32 -32
- data/lib/yard/cli/yardoc.rb +181 -135
- data/lib/yard/cli/yri.rb +29 -29
- data/lib/yard/code_objects/base.rb +101 -101
- data/lib/yard/code_objects/class_object.rb +20 -20
- data/lib/yard/code_objects/constant_object.rb +1 -1
- data/lib/yard/code_objects/extended_method_object.rb +5 -5
- data/lib/yard/code_objects/extra_file_object.rb +89 -0
- data/lib/yard/code_objects/macro_object.rb +215 -0
- data/lib/yard/code_objects/method_object.rb +30 -30
- data/lib/yard/code_objects/module_object.rb +1 -1
- data/lib/yard/code_objects/namespace_object.rb +39 -39
- data/lib/yard/code_objects/proxy.rb +38 -38
- data/lib/yard/code_objects/root_object.rb +1 -1
- data/lib/yard/config.rb +40 -40
- data/lib/yard/core_ext/array.rb +2 -2
- data/lib/yard/core_ext/file.rb +11 -11
- data/lib/yard/core_ext/insertion.rb +10 -10
- data/lib/yard/core_ext/module.rb +2 -2
- data/lib/yard/core_ext/string.rb +2 -2
- data/lib/yard/core_ext/symbol_hash.rb +14 -14
- data/lib/yard/docstring.rb +122 -54
- data/lib/yard/globals.rb +2 -2
- data/lib/yard/handlers/base.rb +216 -127
- data/lib/yard/handlers/processor.rb +65 -27
- data/lib/yard/handlers/ruby/alias_handler.rb +6 -3
- data/lib/yard/handlers/ruby/attribute_handler.rb +7 -6
- data/lib/yard/handlers/ruby/base.rb +50 -31
- data/lib/yard/handlers/ruby/class_condition_handler.rb +11 -11
- data/lib/yard/handlers/ruby/class_handler.rb +10 -10
- data/lib/yard/handlers/ruby/class_variable_handler.rb +3 -3
- data/lib/yard/handlers/ruby/constant_handler.rb +7 -7
- data/lib/yard/handlers/ruby/exception_handler.rb +2 -2
- data/lib/yard/handlers/ruby/extend_handler.rb +1 -1
- data/lib/yard/handlers/ruby/legacy/alias_handler.rb +8 -5
- data/lib/yard/handlers/ruby/legacy/attribute_handler.rb +6 -5
- data/lib/yard/handlers/ruby/legacy/base.rb +42 -27
- data/lib/yard/handlers/ruby/legacy/class_condition_handler.rb +9 -9
- data/lib/yard/handlers/ruby/legacy/class_handler.rb +13 -12
- data/lib/yard/handlers/ruby/legacy/class_variable_handler.rb +3 -6
- data/lib/yard/handlers/ruby/legacy/constant_handler.rb +5 -8
- data/lib/yard/handlers/ruby/legacy/exception_handler.rb +1 -1
- data/lib/yard/handlers/ruby/legacy/extend_handler.rb +1 -0
- data/lib/yard/handlers/ruby/legacy/macro_handler.rb +40 -0
- data/lib/yard/handlers/ruby/legacy/method_handler.rb +10 -10
- data/lib/yard/handlers/ruby/legacy/mixin_handler.rb +4 -3
- data/lib/yard/handlers/ruby/legacy/module_handler.rb +2 -1
- data/lib/yard/handlers/ruby/legacy/private_constant_handler.rb +4 -4
- data/lib/yard/handlers/ruby/legacy/visibility_handler.rb +2 -1
- data/lib/yard/handlers/ruby/legacy/yield_handler.rb +3 -3
- data/lib/yard/handlers/ruby/macro_handler.rb +41 -0
- data/lib/yard/handlers/ruby/macro_handler_methods.rb +130 -0
- data/lib/yard/handlers/ruby/method_condition_handler.rb +1 -1
- data/lib/yard/handlers/ruby/method_handler.rb +13 -13
- data/lib/yard/handlers/ruby/mixin_handler.rb +4 -4
- data/lib/yard/handlers/ruby/module_handler.rb +2 -1
- data/lib/yard/handlers/ruby/private_constant_handler.rb +4 -4
- data/lib/yard/handlers/ruby/struct_handler_methods.rb +11 -11
- data/lib/yard/handlers/ruby/visibility_handler.rb +1 -1
- data/lib/yard/handlers/ruby/yield_handler.rb +5 -5
- data/lib/yard/logging.rb +11 -11
- data/lib/yard/parser/base.rb +8 -8
- data/lib/yard/parser/c_parser.rb +42 -33
- data/lib/yard/parser/ruby/ast_node.rb +62 -61
- data/lib/yard/parser/ruby/legacy/ruby_lex.rb +66 -66
- data/lib/yard/parser/ruby/legacy/ruby_parser.rb +4 -4
- data/lib/yard/parser/ruby/legacy/statement.rb +11 -11
- data/lib/yard/parser/ruby/legacy/statement_list.rb +15 -15
- data/lib/yard/parser/ruby/legacy/token_list.rb +9 -9
- data/lib/yard/parser/ruby/ruby_parser.rb +51 -37
- data/lib/yard/parser/source_parser.rb +271 -46
- data/lib/yard/rake/yardoc_task.rb +18 -17
- data/lib/yard/registry.rb +64 -64
- data/lib/yard/registry_store.rb +34 -34
- data/lib/yard/rubygems/backports.rb +8 -0
- data/lib/yard/rubygems/backports/LICENSE.txt +57 -0
- data/lib/yard/rubygems/backports/MIT.txt +20 -0
- data/lib/yard/rubygems/backports/gem.rb +8 -0
- data/lib/yard/rubygems/backports/source_index.rb +353 -0
- data/lib/yard/rubygems/specification.rb +2 -2
- data/lib/yard/serializers/base.rb +20 -20
- data/lib/yard/serializers/file_system_serializer.rb +28 -24
- data/lib/yard/serializers/process_serializer.rb +3 -3
- data/lib/yard/serializers/stdout_serializer.rb +6 -6
- data/lib/yard/serializers/yardoc_serializer.rb +17 -17
- data/lib/yard/server/adapter.rb +12 -12
- data/lib/yard/server/commands/base.rb +26 -26
- data/lib/yard/server/commands/display_file_command.rb +3 -2
- data/lib/yard/server/commands/display_object_command.rb +5 -5
- data/lib/yard/server/commands/frames_command.rb +1 -1
- data/lib/yard/server/commands/library_command.rb +7 -7
- data/lib/yard/server/commands/library_index_command.rb +2 -2
- data/lib/yard/server/commands/list_command.rb +8 -8
- data/lib/yard/server/commands/search_command.rb +8 -8
- data/lib/yard/server/commands/static_file_command.rb +3 -3
- data/lib/yard/server/doc_server_helper.rb +6 -3
- data/lib/yard/server/doc_server_serializer.rb +1 -1
- data/lib/yard/server/library_version.rb +45 -45
- data/lib/yard/server/rack_adapter.rb +10 -10
- data/lib/yard/server/router.rb +28 -28
- data/lib/yard/server/static_caching.rb +5 -5
- data/lib/yard/server/templates/default/fulldoc/html/css/custom.css +3 -3
- data/lib/yard/server/templates/default/fulldoc/html/js/live.js +1 -1
- data/lib/yard/server/templates/default/layout/html/breadcrumb.erb +2 -2
- data/lib/yard/server/templates/default/layout/html/headers.erb +13 -8
- data/lib/yard/server/templates/default/layout/html/setup.rb +7 -0
- data/lib/yard/server/templates/doc_server/full_list/html/full_list.erb +2 -2
- data/lib/yard/server/templates/doc_server/full_list/html/setup.rb +14 -4
- data/lib/yard/server/templates/doc_server/library_list/html/contents.erb +2 -2
- data/lib/yard/server/templates/doc_server/library_list/html/headers.erb +2 -2
- data/lib/yard/server/templates/doc_server/processing/html/processing.erb +1 -1
- data/lib/yard/server/templates/doc_server/search/html/search.erb +1 -1
- data/lib/yard/server/webrick_adapter.rb +2 -2
- data/lib/yard/tags/default_factory.rb +19 -19
- data/lib/yard/tags/default_tag.rb +1 -1
- data/lib/yard/tags/library.rb +68 -63
- data/lib/yard/tags/option_tag.rb +1 -1
- data/lib/yard/tags/overload_tag.rb +9 -9
- data/lib/yard/tags/ref_tag_list.rb +2 -2
- data/lib/yard/tags/tag.rb +7 -7
- data/lib/yard/templates/engine.rb +31 -31
- data/lib/yard/templates/erb_cache.rb +1 -1
- data/lib/yard/templates/helpers/base_helper.rb +46 -32
- data/lib/yard/templates/helpers/filter_helper.rb +2 -2
- data/lib/yard/templates/helpers/html_helper.rb +120 -81
- data/lib/yard/templates/helpers/html_syntax_highlight_helper.rb +4 -4
- data/lib/yard/templates/helpers/markup/rdoc_markup.rb +9 -9
- data/lib/yard/templates/helpers/markup_helper.rb +37 -30
- data/lib/yard/templates/helpers/method_helper.rb +7 -7
- data/lib/yard/templates/helpers/text_helper.rb +7 -7
- data/lib/yard/templates/helpers/uml_helper.rb +3 -3
- data/lib/yard/templates/section.rb +14 -14
- data/lib/yard/templates/template.rb +54 -54
- data/lib/yard/verifier.rb +27 -27
- data/spec/cli/list_spec.rb +8 -0
- data/spec/cli/yardoc_spec.rb +58 -10
- data/spec/code_objects/extra_file_object_spec.rb +132 -0
- data/spec/code_objects/macro_object_spec.rb +154 -0
- data/spec/docstring_spec.rb +90 -0
- data/spec/handlers/base_spec.rb +22 -0
- data/spec/handlers/examples/macro_handler_001.rb.txt +73 -0
- data/spec/handlers/examples/method_handler_001.rb.txt +17 -0
- data/spec/handlers/macro_handler_spec.rb +140 -0
- data/spec/handlers/method_handler_spec.rb +28 -0
- data/spec/handlers/processor_spec.rb +4 -0
- data/spec/handlers/spec_helper.rb +1 -1
- data/spec/parser/c_parser_spec.rb +47 -16
- data/spec/parser/examples/extrafile.c.txt +8 -0
- data/spec/parser/examples/multifile.c.txt +6 -0
- data/spec/parser/ruby/ruby_parser_spec.rb +5 -0
- data/spec/parser/source_parser_spec.rb +235 -0
- data/spec/rake/yardoc_task_spec.rb +22 -17
- data/spec/serializers/file_system_serializer_spec.rb +6 -0
- data/spec/server/commands/library_command_spec.rb +39 -0
- data/spec/spec_helper.rb +14 -0
- data/spec/templates/examples/method001.html +6 -6
- data/spec/templates/examples/method002.html +4 -4
- data/spec/templates/examples/method003.html +10 -10
- data/spec/templates/examples/method005.html +2 -2
- data/spec/templates/examples/module001.dot +2 -0
- data/spec/templates/examples/module001.html +76 -37
- data/spec/templates/examples/module001.txt +1 -1
- data/spec/templates/helpers/base_helper_spec.rb +7 -2
- data/spec/templates/helpers/html_helper_spec.rb +49 -5
- data/spec/templates/helpers/markup_helper_spec.rb +9 -8
- data/spec/templates/module_spec.rb +7 -0
- data/spec/templates/onefile_spec.rb +47 -0
- data/templates/default/fulldoc/html/css/style.css +7 -5
- data/templates/default/fulldoc/html/full_list.erb +13 -10
- data/templates/default/fulldoc/html/full_list_files.erb +1 -1
- data/templates/default/fulldoc/html/js/app.js +16 -14
- data/templates/default/fulldoc/html/js/full_list.js +7 -6
- data/templates/default/fulldoc/html/setup.rb +78 -17
- data/templates/default/layout/html/files.erb +1 -1
- data/templates/default/layout/html/headers.erb +11 -7
- data/templates/default/layout/html/search.erb +4 -4
- data/templates/default/layout/html/setup.rb +28 -8
- data/templates/default/module/html/inherited_attributes.erb +17 -0
- data/templates/default/module/setup.rb +1 -1
- data/templates/default/onefile/html/files.erb +2 -2
- data/templates/default/onefile/html/layout.erb +1 -1
- data/templates/default/onefile/html/setup.rb +7 -5
- data/templates/default/tags/html/option.erb +1 -1
- data/templates/default/tags/html/tag.erb +3 -3
- data/templates/guide/class/html/setup.rb +1 -0
- data/templates/guide/docstring/html/setup.rb +1 -0
- data/templates/guide/fulldoc/html/css/style.css +91 -0
- data/templates/guide/fulldoc/html/js/app.js +33 -0
- data/templates/guide/fulldoc/html/setup.rb +54 -0
- data/templates/guide/layout/html/layout.erb +81 -0
- data/templates/guide/layout/html/setup.rb +24 -0
- data/templates/guide/method/html/header.erb +18 -0
- data/templates/guide/method/html/setup.rb +21 -0
- data/templates/guide/module/html/header.erb +7 -0
- data/templates/guide/module/html/method_list.erb +5 -0
- data/templates/guide/module/html/setup.rb +26 -0
- data/templates/guide/tags/html/setup.rb +8 -0
- metadata +40 -7
- data/lib/yard/handlers/ruby/legacy/process_handler.rb +0 -13
- data/lib/yard/handlers/ruby/process_handler.rb +0 -18
- data/spec/handlers/process_handler_spec.rb +0 -17
data/docs/Templates.md
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
Templates Architecture
|
2
|
-
|
1
|
+
# @title Templates Architecture
|
2
|
+
|
3
|
+
# Templates Architecture
|
3
4
|
|
4
5
|
Templates are the main component in the output rendering process of YARD,
|
5
6
|
which is invoked when conventional HTML/text output needs to be rendered
|
6
7
|
for a set of code objects.
|
7
8
|
|
8
|
-
Design Goals
|
9
|
-
------------
|
9
|
+
## Design Goals
|
10
10
|
|
11
11
|
The general design attempts to be as abstracted from actual content and templates
|
12
12
|
as possible. Unlike RDoc which uses one file to describe the entire template,
|
@@ -30,15 +30,13 @@ The design goals can be summarized as follows:
|
|
30
30
|
any existing sections in the document. This allows for easy modification
|
31
31
|
of templates by plugins.
|
32
32
|
|
33
|
-
Templates
|
34
|
-
---------
|
33
|
+
## Templates
|
35
34
|
|
36
35
|
Template modules are the objects used to orchestrate the design goals listed
|
37
36
|
above. Specifically, they organize the sections and render the template contents
|
38
37
|
depending on the format.
|
39
38
|
|
40
|
-
Engine
|
41
|
-
------
|
39
|
+
## Engine
|
42
40
|
|
43
41
|
The Engine class orchestrates the creation and rendering of Template modules and
|
44
42
|
handles serialization or specific rendering scenarios (like HTML). To create
|
@@ -63,8 +61,7 @@ object. For instance, the above render example is equivalent to the simple
|
|
63
61
|
call `myobject.format`. The `generate` method is a special kind of render
|
64
62
|
and is called from the {YARD::CLI::Yardoc} command line utility.
|
65
63
|
|
66
|
-
Template Options
|
67
|
-
----------------
|
64
|
+
## Template Options
|
68
65
|
|
69
66
|
A template keeps state when it is rendering output. This state is kept in
|
70
67
|
an options hash which is initially passed to it during instantiation. Some
|
@@ -75,8 +72,7 @@ HTML instead of text can be done as follows:
|
|
75
72
|
|
76
73
|
myobject.format(:format => :html)
|
77
74
|
|
78
|
-
Serializer
|
79
|
-
----------
|
75
|
+
## Serializer
|
80
76
|
|
81
77
|
This class abstracts the logic involved in deciding how to serialize data to
|
82
78
|
the expected endpoint. For instance, there is both a {YARD::Serializers::StdoutSerializer StdoutSerializer}
|
@@ -91,8 +87,7 @@ otherwise the rendered object is returned as a string to its parent. Nested
|
|
91
87
|
Templates automatically set the serializer to nil so that they return
|
92
88
|
as a String to their parent.
|
93
89
|
|
94
|
-
Creating a Template
|
95
|
-
-------------------
|
90
|
+
## Creating a Template
|
96
91
|
|
97
92
|
Templates are represented by a directory inside the {YARD::Templates::Engine.template_paths}
|
98
93
|
on disk. A standard template directory looks like the following tree:
|
@@ -137,8 +132,7 @@ files are the sections that make up the template.
|
|
137
132
|
Note that the subdirectory `html/` is also its own "template" that inherits
|
138
133
|
from the parent directory. We will see more on this later.
|
139
134
|
|
140
|
-
setup.rb
|
141
|
-
--------
|
135
|
+
## setup.rb
|
142
136
|
|
143
137
|
Every template should have at least one `setup.rb` file that defines the
|
144
138
|
{YARD::Templates::Template#init #init} method to set the
|
@@ -153,8 +147,7 @@ A standard setup.rb file looks like:
|
|
153
147
|
sections :section1, :section2, :section3
|
154
148
|
end
|
155
149
|
|
156
|
-
Sections
|
157
|
-
--------
|
150
|
+
## Sections
|
158
151
|
|
159
152
|
Sections are smaller components that correlate to template
|
160
153
|
fragments. Practically speaking, a section can either be a template fragment
|
@@ -162,8 +155,7 @@ fragments. Practically speaking, a section can either be a template fragment
|
|
162
155
|
(which returns a String) or another {YARD::Templates::Template} (which in turn has its own
|
163
156
|
list of sections).
|
164
157
|
|
165
|
-
Nested Sections
|
166
|
-
---------------
|
158
|
+
## Nested Sections
|
167
159
|
|
168
160
|
Sections often require the ability to encapsulate a set of sub-sections in markup
|
169
161
|
(HTML, for instance). Rather than use heavier Template subclass objects, a more
|
@@ -198,8 +190,7 @@ to each individually (in order) until there are no more left to yield to.
|
|
198
190
|
In the vast majority of cases, you'd want to use `yieldall`, since `yield`
|
199
191
|
makes it hard for users to override your template.
|
200
192
|
|
201
|
-
Inheriting Templates
|
202
|
-
--------------------
|
193
|
+
## Inheriting Templates
|
203
194
|
|
204
195
|
Parent directory templates are automatically inherited (or mixed in, to be
|
205
196
|
more accurate) by the current template. This means that the 'default/class/html'
|
@@ -223,8 +214,7 @@ For instance, the first line in `default/class/html/setup.rb` is:
|
|
223
214
|
This includes the 'default/module/html', which means it also includes 'default/module'
|
224
215
|
by extension. This allows class to make use of any of module's erb files.
|
225
216
|
|
226
|
-
Inserting and Traversing Sections
|
227
|
-
---------------------------------
|
217
|
+
## Inserting and Traversing Sections
|
228
218
|
|
229
219
|
The ability to insert sections was mentioned above. The class template, for
|
230
220
|
instance, will modify the #init method to insert class specific sections:
|
@@ -264,8 +254,7 @@ recursively. The above example could simply be rewritten as:
|
|
264
254
|
|
265
255
|
sections.place(:e).after_any(:d)
|
266
256
|
|
267
|
-
Overriding Templates by Registering a Template Path
|
268
|
-
---------------------------------------------------
|
257
|
+
## Overriding Templates by Registering a Template Path
|
269
258
|
|
270
259
|
Inheriting templates explicitly is useful when creating a customized template
|
271
260
|
that wants to take advantage of code re-use. However, most users who want
|
@@ -305,3 +294,225 @@ The `setup.rb` file would look like:
|
|
305
294
|
|
306
295
|
Now, when a class object is formatted as HTML, our customsection.erb will be
|
307
296
|
appended to the rendered data.
|
297
|
+
|
298
|
+
|
299
|
+
### Overriding Stylesheets and Javascripts
|
300
|
+
|
301
|
+
Template authors can override existing stylesheets and javascripts by creating
|
302
|
+
a file with the same name as existing files within the `fulldoc` template. The
|
303
|
+
documentation output will utilize the new replacement file.
|
304
|
+
|
305
|
+
YARD's `fulldoc` template defines three stylesheets:
|
306
|
+
|
307
|
+
/yard/templates/default/:
|
308
|
+
|-- fulldoc
|
309
|
+
| |-- html
|
310
|
+
| | |-- css
|
311
|
+
| | | |-- common.css
|
312
|
+
| | | |-- full_list.css
|
313
|
+
| | | |-- style.css
|
314
|
+
|
315
|
+
The `style.css` is the primary stylesheet for the HTML output.
|
316
|
+
|
317
|
+
The `full_list.css` is an additional stylesheet loaded specifically for the
|
318
|
+
search field menus (i.e. class list, method list, and file list).
|
319
|
+
|
320
|
+
The `common.css` is an empty css file that an template author can easily override
|
321
|
+
to provide custom styles for their plugin. However, if a user installs multiple
|
322
|
+
plugins that utilize this same file to deliver styles, it is possible that they
|
323
|
+
will be overridden.
|
324
|
+
|
325
|
+
YARD's `fulldoc` template defines three javascript files:
|
326
|
+
|
327
|
+
/yard/templates/default/:
|
328
|
+
|-- fulldoc
|
329
|
+
| |-- html
|
330
|
+
| | |-- js
|
331
|
+
| | | |-- app.js
|
332
|
+
| | | |-- full_list.js
|
333
|
+
| | | |-- jquery.js
|
334
|
+
|
335
|
+
The `app.js` is the primary javascript file for the HTML output.
|
336
|
+
|
337
|
+
The `full_list.js` defines additional javascript loaded specifically for the
|
338
|
+
search field menus (i.e. class list, method list, and file list).
|
339
|
+
|
340
|
+
The `jquery.js` is copy of the jquery javascript library.
|
341
|
+
|
342
|
+
### Adding a Custom Stylesheet or Javascript
|
343
|
+
|
344
|
+
To load additional stylesheets and javascripts with every page (except the search
|
345
|
+
field menus) generated from the base `layout` template:
|
346
|
+
|
347
|
+
1. Define your own custom stylesheet and/or javascript file
|
348
|
+
(default/ is the default template name inside of the /template root directory):
|
349
|
+
|
350
|
+
/template/default/:
|
351
|
+
|-- fulldoc
|
352
|
+
| |-- html
|
353
|
+
| | |-- css
|
354
|
+
| | | |-- custom.css
|
355
|
+
| | |-- js
|
356
|
+
| | | |-- custom.js
|
357
|
+
|
358
|
+
2. Create a `setup.rb` in the `layout` template directory and override the methods
|
359
|
+
`stylesheets` and `javascripts`. The path to the template would be:
|
360
|
+
|
361
|
+
/template/default/:
|
362
|
+
|-- layout
|
363
|
+
| |-- html
|
364
|
+
| | |-- setup.rb
|
365
|
+
|
366
|
+
And the code would look like:
|
367
|
+
|
368
|
+
def stylesheets
|
369
|
+
# Load the existing stylesheets while appending the custom one
|
370
|
+
super + %w(css/custom.css)
|
371
|
+
end
|
372
|
+
|
373
|
+
def javascripts
|
374
|
+
# Load the existing javascripts while appending the custom one
|
375
|
+
super + %w(js/custom.js)
|
376
|
+
end
|
377
|
+
|
378
|
+
|
379
|
+
To load additional stylesheets and javascripts for the search menus loaded from
|
380
|
+
the `fulldoc` template:
|
381
|
+
|
382
|
+
1. Define your own custom stylesheet and/or javascript file.
|
383
|
+
|
384
|
+
/path/to/mytemplates/:
|
385
|
+
|-- fulldoc
|
386
|
+
| |-- html
|
387
|
+
| | |-- css
|
388
|
+
| | | |-- custom_full_menu.css
|
389
|
+
| | |-- js
|
390
|
+
| | | |-- custom_full_menu.js
|
391
|
+
|
392
|
+
|
393
|
+
3. Override the methods `stylesheets_full_list` and `javascripts_full_list`
|
394
|
+
in the `setup.rb` file inside fulldoc/html.
|
395
|
+
|
396
|
+
def stylesheets_full_list
|
397
|
+
# Load the existing stylesheets while appending the custom one
|
398
|
+
super + %w(css/custom.css)
|
399
|
+
end
|
400
|
+
|
401
|
+
def javascripts_full_list
|
402
|
+
# Load the existing javascripts while appending the custom one
|
403
|
+
super + %w(js/custom.js)
|
404
|
+
end
|
405
|
+
|
406
|
+
### Overriding Search Menus
|
407
|
+
|
408
|
+
By default YARD's `fulldoc` template generates three search fields:
|
409
|
+
|
410
|
+
* Class List
|
411
|
+
* Method List
|
412
|
+
* File List
|
413
|
+
|
414
|
+
Their contents are rendered in methods within the `fulldoc` template:
|
415
|
+
|
416
|
+
* `generate_class_list`
|
417
|
+
* `generate_method_list`
|
418
|
+
* `generate_file_list`
|
419
|
+
|
420
|
+
To override these lists you will need to:
|
421
|
+
|
422
|
+
1. Create a `setup.rb` in the `fulldoc` template directory and override the
|
423
|
+
particular method.
|
424
|
+
|
425
|
+
/path/to/mytemplates/:
|
426
|
+
|-- fulldoc
|
427
|
+
| |-- html
|
428
|
+
| | |-- setup.rb
|
429
|
+
|
430
|
+
def generate_method_list
|
431
|
+
@items = prune_method_listing(Registry.all(:method), false)
|
432
|
+
@items = @items.reject {|m| m.name.to_s =~ /=$/ && m.is_attribute? }
|
433
|
+
|
434
|
+
# Here we changed the functionality to reverse the order of displayed methods
|
435
|
+
@items = @items.sort_by {|m| m.name.to_s }.reverse
|
436
|
+
@list_title = "Method List"
|
437
|
+
@list_type = "methods"
|
438
|
+
asset('method_list.html', erb(:full_list))
|
439
|
+
end
|
440
|
+
|
441
|
+
### Adding Additional Search Menus
|
442
|
+
|
443
|
+
By default YARD's `fulldoc` template generates three search fields:
|
444
|
+
|
445
|
+
* Class List
|
446
|
+
* Method List
|
447
|
+
* File List
|
448
|
+
|
449
|
+
These are defined in the `layout` template method `menu_lists` and pulled into
|
450
|
+
the `fulldoc` template through a similarly named method.
|
451
|
+
|
452
|
+
To load an additional menu item:
|
453
|
+
|
454
|
+
|
455
|
+
1. Create a `setup.rb` in the `layout` template directory and override the methods
|
456
|
+
`menu_lists`. The `type` informs the search field the name of the file.
|
457
|
+
The `title` is the name that appears above the section when viewed in frames.
|
458
|
+
The `search_title` is the name that appears in the search field tab on the page.
|
459
|
+
|
460
|
+
|
461
|
+
/path/to/mytemplates/:
|
462
|
+
|-- layout
|
463
|
+
| |-- html
|
464
|
+
| | |-- setup.rb
|
465
|
+
|
466
|
+
def menu_lists
|
467
|
+
# Load the existing menus
|
468
|
+
super + [ { :type => 'feature', :title => 'Features', :search_title => 'Feature List' } ]
|
469
|
+
end
|
470
|
+
|
471
|
+
2. Create a `setup.rb` in the `fulldoc` template directory and create a method
|
472
|
+
to generate a menu for the specified `type`.
|
473
|
+
The method `generate_assets` will look for a function with a signature prefixed
|
474
|
+
with `generate`, the type value specified, and the suffix `list`. Within that
|
475
|
+
method you can configure and load the specific objects you wish to display.
|
476
|
+
|
477
|
+
/path/to/mytemplates/:
|
478
|
+
|-- fulldoc
|
479
|
+
| |-- html
|
480
|
+
| | |-- setup.rb
|
481
|
+
|
482
|
+
def generate_feature_list
|
483
|
+
|
484
|
+
# load all the features from the Registry
|
485
|
+
@items = Registry.all(:feature)
|
486
|
+
@list_title = "Feature List"
|
487
|
+
@list_type = "feature"
|
488
|
+
|
489
|
+
# optional: the specified stylesheet class
|
490
|
+
# when not specified it will default to the value of @list_type
|
491
|
+
@list_class = "class"
|
492
|
+
|
493
|
+
# Generate the full list html file with named feature_list.html
|
494
|
+
# @note this file must be match the name of the type
|
495
|
+
asset('feature_list.html', erb(:full_list))
|
496
|
+
end
|
497
|
+
|
498
|
+
|
499
|
+
3. Define custom javascript to load the search fields and the keyboard shortcuts.
|
500
|
+
|
501
|
+
function featureSearchFrameLinks() {
|
502
|
+
$('#feature_list_link').click(function() {
|
503
|
+
toggleSearchFrame(this, relpath + 'feature_list.html');
|
504
|
+
});
|
505
|
+
}
|
506
|
+
|
507
|
+
function featureKeyboardShortcuts() {
|
508
|
+
if (window.top.frames.main) return;
|
509
|
+
$(document).keypress(function(evt) {
|
510
|
+
if (evt.altKey || evt.ctrlKey || evt.metaKey || evt.shiftKey) return;
|
511
|
+
if (typeof evt.orignalTarget !== "undefined" &&
|
512
|
+
(evt.originalTarget.nodeName == "INPUT" ||
|
513
|
+
evt.originalTarget.nodeName == "TEXTAREA")) return;
|
514
|
+
switch (evt.charCode) {
|
515
|
+
case 82: case 114: $('#feature_list_link').click(); break; // 'r'
|
516
|
+
}
|
517
|
+
});
|
518
|
+
}
|
data/docs/WhatsNew.md
CHANGED
@@ -1,5 +1,181 @@
|
|
1
|
-
What's New
|
2
|
-
|
1
|
+
# @title What's New?
|
2
|
+
|
3
|
+
# What's New in 0.7.x?
|
4
|
+
|
5
|
+
1. **Macro support and detection of DSL methods** (0.7.0)
|
6
|
+
2. **Inherited attributes now show in HTML output** (0.7.0)
|
7
|
+
3. **The 'app' directory is now parsed by default** (0.7.0)
|
8
|
+
4. **Added support for metadata (@title, @markup) in extra files/readmes** (0.7.0)
|
9
|
+
5. **Added `yard list` command (alias for `yardoc --list`)** (0.7.0)
|
10
|
+
6. **Added Git support in `yard diff`** (0.7.0)
|
11
|
+
7. **Added `{include:file:FILENAME}` syntax** (0.7.0)
|
12
|
+
8. **Added `{render:OBJECT}` syntax to embed object docs in extra files** (0.7.0)
|
13
|
+
9. **Added improved templates API for custom CSS/JS/menus** (0.7.0)
|
14
|
+
10. **Added Ruby markup type (`-m ruby`)** (0.7.0)
|
15
|
+
11. **Added state tracking variables to Parser/Handler architecture** (0.7.0)
|
16
|
+
12. **Added before/after callbacks to SourceParser** (0.7.0)
|
17
|
+
13. **Can now use `--yardopts FILE` to specify a custom yardopts file** (0.7.0)
|
18
|
+
14. **Added new `-t guide` template for guide based docs** (0.7.0)
|
19
|
+
|
20
|
+
## Macro support and detection of DSL methods (0.7.0)
|
21
|
+
|
22
|
+
YARD will now automatically detect class level method calls, similar to the
|
23
|
+
way it knows what an `attr_accessor` is. By simply adding documentation to
|
24
|
+
your class level declarations, YARD can automatically detect them as methods
|
25
|
+
or attributes in your class. Consider DataMapper's "property" declaration:
|
26
|
+
|
27
|
+
class Post
|
28
|
+
# @attribute
|
29
|
+
# @return [String] the title of the post
|
30
|
+
property :title, String
|
31
|
+
end
|
32
|
+
|
33
|
+
The above declaration would be created as the `Post#title`. The optional
|
34
|
+
`@attribute` tag tells YARD that the property is an "attribute", and not just
|
35
|
+
a regular method.
|
36
|
+
|
37
|
+
In addition to basic DSL method detection, YARD also supports macros to create
|
38
|
+
docstrings that can be copies to other objects; these macros can also be
|
39
|
+
"attached" to class level methods to create implicit documentation for macros.
|
40
|
+
|
41
|
+
Macros and DSL method detection are discussed in much more detail in the
|
42
|
+
{file:docs/GettingStarted.md}, so you should read about them there if you're
|
43
|
+
interested in this feature.
|
44
|
+
|
45
|
+
## Inherited attributes now show in HTML output (0.7.0)
|
46
|
+
|
47
|
+
Inherited attributes will now show up in HTML documentation using the default
|
48
|
+
template in the same manner that inherited methods do.
|
49
|
+
|
50
|
+
## The 'app' directory is now parsed by default (0.7.0)
|
51
|
+
|
52
|
+
YARD tries to follow the "It Just Works" attitude in writing developer tools,
|
53
|
+
and therefore has added `app/**/*.rb` to the default list of globs that it
|
54
|
+
searches for code in. You no longer need to create a `.yardopts` just to
|
55
|
+
list your app directory when documenting your code on rubydoc.info.
|
56
|
+
We should have done this a while ago! And don't worry, YARD still checks
|
57
|
+
lib and ext by default, too.
|
58
|
+
|
59
|
+
## Added support for metadata (@title, @markup) in extra files/readmes (0.7.0)
|
60
|
+
|
61
|
+
Extra files (READMEs, ChangeLogs, LICENSE files, and other guides) now support
|
62
|
+
metadata tags, just like docstrings in code comments. By adding @tag values
|
63
|
+
to the top of a file (no whitespace preceding it) inside of a `# comment` line,
|
64
|
+
YARD will detect and parse these tags and store it for later usage.
|
65
|
+
|
66
|
+
Tags can contain arbitrary data as well as arbitrary tag names, however the
|
67
|
+
tag names @title and @markup are reserved to specify the document title and
|
68
|
+
markup format respectively. The title will be used in the file list menu,
|
69
|
+
index page, as well as any linking of the file via the `{file:Filename}`
|
70
|
+
syntax. An example of a document with metadata would be:
|
71
|
+
|
72
|
+
# @title The Best Project Ever!
|
73
|
+
# @markup rdoc
|
74
|
+
# @author Foo Bar (custom tag, does not display in templates)
|
75
|
+
|
76
|
+
= This Project Rules
|
77
|
+
|
78
|
+
== Contents
|
79
|
+
|
80
|
+
...
|
81
|
+
|
82
|
+
Note that previous versions of YARD recommended specifying the markup of an
|
83
|
+
extra file with the `#!markup` shebang, but the `@markup` metadata tag is now
|
84
|
+
the "best practice" for specifying the markup format of an extra file.
|
85
|
+
|
86
|
+
## Added `yard list` command (alias for `yardoc --list`) (0.7.0)
|
87
|
+
|
88
|
+
The `yardoc --list` command is used to list objects that are parsed from
|
89
|
+
a codebase. This can be used to grep methods/classes in a codebase from the
|
90
|
+
command line. `yard list` now calls `yardoc --list` as a convenience command.
|
91
|
+
|
92
|
+
Note that the `yardoc --list` command may eventually be replaced by a more
|
93
|
+
feature-filled `yard list` command, so `yard list` should be used instead of
|
94
|
+
`yardoc --list` when possible.
|
95
|
+
|
96
|
+
## Added Git support in `yard diff` (0.7.0)
|
97
|
+
|
98
|
+
The `yard diff` command can now perform object diffing on git repositories.
|
99
|
+
Provide the `--git` switch to `yard diff` with 2 commit/branches like so:
|
100
|
+
|
101
|
+
$ yard diff --git HEAD~5 HEAD
|
102
|
+
Added objects:
|
103
|
+
|
104
|
+
YARD::Parser::SourceParser#contents
|
105
|
+
YARD::Parser::SourceParser#globals
|
106
|
+
...
|
107
|
+
|
108
|
+
## Added `{include:file:FILENAME}` syntax (0.7.0)
|
109
|
+
|
110
|
+
You can now use the `{include:file:FILENAME}` syntax to embed the contents
|
111
|
+
of an extra file marked up in its markup format. This syntax supports embedding
|
112
|
+
Ruby source files and performing syntax highlighting on the code.
|
113
|
+
|
114
|
+
## Added `{render:OBJECT}` syntax to embed object docs in extra files (0.7.0)
|
115
|
+
|
116
|
+
You can now use the `{render:Object}` syntax to embed the documentation
|
117
|
+
rendering of an entire object (method, class, module) inside of an extra file.
|
118
|
+
This is useful when writing non-API based guides that might require listing
|
119
|
+
a few helper methods or classes. The {file:docs/GettingStarted.md} discussed
|
120
|
+
this syntax in more detail (with example usage).
|
121
|
+
|
122
|
+
## Added improved templates API for custom CSS/JS/menus (0.7.0)
|
123
|
+
|
124
|
+
Plugin & template developers can now more easily insert custom stylesheet
|
125
|
+
or JavaScript files in their customized templates, thanks to an abstraction
|
126
|
+
of the template API. This is documented in the {docs/Templates.md} document.
|
127
|
+
In addition to custom CSS/JS, developers can also create custom menu tabs
|
128
|
+
in both the framed and non framed version of the default theme.
|
129
|
+
|
130
|
+
## Added Ruby markup type (`-m ruby`) (0.7.0)
|
131
|
+
|
132
|
+
The Ruby markup type (`-m ruby`) will now use syntax highlighting for all
|
133
|
+
formatting. This is probably not useful as a global switch, but can be used
|
134
|
+
on individual extra files using the metadata markup specification discussed
|
135
|
+
above.
|
136
|
+
|
137
|
+
## Added state tracking variables to Parser/Handler architecture (0.7.0)
|
138
|
+
|
139
|
+
The parser and handler architecture now contain state variables
|
140
|
+
{YARD::Handlers::Base#extra_state} and {YARD::Handlers::Processor#globals}
|
141
|
+
to share data across handlers and the entire processing phase. `#extra_state`
|
142
|
+
provided a place to store per-file data, while `#globals` gives the developer
|
143
|
+
access to inter-file state when parsing multiple files at once.
|
144
|
+
|
145
|
+
## Added before/after callbacks to SourceParser (0.7.0)
|
146
|
+
|
147
|
+
The {YARD::Parser::SourceParser} class can now register callbacks to execute
|
148
|
+
code before and after parsing of file globs, as well as before and after
|
149
|
+
parsing of individual files. This allows plugin developers to perform
|
150
|
+
setup/teardown (and set global state or update the {YARD::Registry}).
|
151
|
+
|
152
|
+
See the documentation for the following methods:
|
153
|
+
|
154
|
+
* {YARD::Parser::SourceParser.before_parse_list}
|
155
|
+
* {YARD::Parser::SourceParser.after_parse_list}
|
156
|
+
* {YARD::Parser::SourceParser.before_parse_file}
|
157
|
+
* {YARD::Parser::SourceParser.after_parse_file}
|
158
|
+
|
159
|
+
## Can now use `--yardopts FILE` to specify a custom yardopts file (0.7.0)
|
160
|
+
|
161
|
+
The `yardoc` command now supports `--yardopts FILE` to specify custom .yardopts
|
162
|
+
options files. This is useful if you have multiple documentation sets, such
|
163
|
+
as a guide documentation set and an API documentation set.
|
164
|
+
|
165
|
+
## Added new `-t guide` template for guide based docs (0.7.0)
|
166
|
+
|
167
|
+
You can now write guide style documentation using a new 'guide' template that
|
168
|
+
only generates documentation for extra files. You would use it in the form:
|
169
|
+
|
170
|
+
yardoc -t guide - README GettingStarted FAQ TroubleShooting LICENSE
|
171
|
+
|
172
|
+
This creates the sections for the readme, a getting started, frequently asked
|
173
|
+
questions, trouble shooting and license page.
|
174
|
+
|
175
|
+
If you need to refer to class / method documentation, you can embed API documentation
|
176
|
+
using the `{render:Object}` tag discussed above.
|
177
|
+
|
178
|
+
# What's New in 0.6.x?
|
3
179
|
|
4
180
|
1. **Local documentation server for RubyGems or projects (`yard server`)** (0.6.0)
|
5
181
|
2. **Groups support for method listing** (0.6.0)
|