yard 0.8.5.2 → 0.8.6

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 (51) hide show
  1. checksums.yaml +4 -4
  2. data/LEGAL +0 -8
  3. data/README.md +9 -2
  4. data/bin/yard +1 -1
  5. data/bin/yardoc +1 -1
  6. data/bin/yri +1 -1
  7. data/docs/WhatsNew.md +38 -0
  8. data/lib/yard/autoload.rb +3 -0
  9. data/lib/yard/cli/command_parser.rb +13 -11
  10. data/lib/yard/cli/diff.rb +2 -1
  11. data/lib/yard/cli/display.rb +43 -0
  12. data/lib/yard/cli/markup_types.rb +33 -0
  13. data/lib/yard/code_objects/root_object.rb +1 -0
  14. data/lib/yard/docstring.rb +8 -4
  15. data/lib/yard/docstring_parser.rb +1 -1
  16. data/lib/yard/handlers/c/base.rb +1 -1
  17. data/lib/yard/handlers/ruby/legacy/method_handler.rb +8 -1
  18. data/lib/yard/logging.rb +2 -1
  19. data/lib/yard/parser/ruby/legacy/ruby_lex.rb +1 -0
  20. data/lib/yard/parser/ruby/legacy/token_list.rb +6 -1
  21. data/lib/yard/parser/source_parser.rb +1 -2
  22. data/lib/yard/tags/directives.rb +1 -1
  23. data/lib/yard/templates/helpers/base_helper.rb +3 -3
  24. data/lib/yard/templates/helpers/html_helper.rb +8 -3
  25. data/lib/yard/templates/helpers/markup/rdoc_markdown.rb +22 -0
  26. data/lib/yard/templates/helpers/markup/rdoc_markup.rb +5 -1
  27. data/lib/yard/templates/helpers/markup_helper.rb +5 -0
  28. data/lib/yard/version.rb +1 -1
  29. data/spec/cli/display_spec.rb +13 -0
  30. data/spec/cli/markup_types_spec.rb +22 -0
  31. data/spec/docstring_spec.rb +20 -0
  32. data/spec/handlers/c/method_handler_spec.rb +7 -6
  33. data/spec/handlers/c/spec_helper.rb +4 -2
  34. data/spec/parser/ruby/legacy/token_list_spec.rb +8 -0
  35. data/spec/parser/source_parser_spec.rb +1 -1
  36. data/spec/spec_helper.rb +4 -0
  37. data/spec/templates/helpers/base_helper_spec.rb +3 -3
  38. data/templates/default/class/text/setup.rb +1 -1
  39. data/templates/default/fulldoc/html/full_list_method.erb +1 -5
  40. data/templates/default/fulldoc/html/js/full_list.js +6 -1
  41. data/templates/default/fulldoc/html/setup.rb +1 -5
  42. data/templates/default/layout/html/headers.erb +1 -1
  43. data/templates/default/module/html/children.erb +1 -1
  44. data/templates/default/onefile/html/headers.erb +6 -0
  45. data/templates/default/onefile/html/layout.erb +1 -6
  46. data/templates/guide/fulldoc/html/setup.rb +20 -1
  47. data/templates/guide/layout/html/setup.rb +14 -10
  48. data/templates/guide/onefile/html/files.erb +4 -0
  49. data/templates/guide/onefile/html/setup.rb +5 -0
  50. data/templates/guide/onefile/html/toc.erb +3 -0
  51. metadata +11 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 286e9bb0543c0d2d846d703abf038d42c0d08948
4
- data.tar.gz: 1935aea9fce12ae0d560f0c2f4b65240aa688fac
3
+ metadata.gz: bc6d95eac959d222f86cce2a94f0b06616aa93fa
4
+ data.tar.gz: de628de21267d778d571fd25ba5aa1665395c5ef
5
5
  SHA512:
6
- metadata.gz: 425fa8cdc965cd68b71230050e1d5c5741b9339218aeedfc4027b20ba2d15484ba1771c61b4bc0a6663b5c1b009d941644b6be323d9dd8e5a13314464bcd0a8e
7
- data.tar.gz: 811d9eae07e7ded34d64e42858f2d9ddd2fad45847636c832f90f326a157fd0933000ce5168f9a6de97224084936c936e7adfbe8339ecdd6af75d9f09a0f5fdb
6
+ metadata.gz: f368b1eb2d0664d79ea633671dbd100252e6e10a382b39ae400be373264ef5569816706eff9cbd899d1bcbb09bc44394be36c7d642c751a156a0253fe2741560
7
+ data.tar.gz: 5c3db2fd3f06553727943a76375d48f70645aaba16828a051cc1ac5835ab96ea9987dea80f25c373e61d880d240c12aeb3d509c1e7d13e23172dc1d576eaec10
data/LEGAL CHANGED
@@ -4,14 +4,6 @@ LEGAL NOTICE INFORMATION
4
4
  All the files in this distribution are covered under either the MIT
5
5
  license (see the file LICENSE) except some files mentioned below.
6
6
 
7
- lib/parser/c_parser.rb:
8
-
9
- This file includes code from the RDoc distribution. It is under the Ruby
10
- license but adds the following copyright:
11
-
12
- RDoc is copyrighted free software by Dave Thomas, Eric Hodel, and others.
13
- It is licensed under the same terms as Ruby
14
-
15
7
  lib/parser/ruby/legacy/ruby_lex.rb:
16
8
 
17
9
  This file is under the Ruby license. YARD uses a modified version of it.
data/README.md CHANGED
@@ -7,8 +7,8 @@
7
7
  **Contributors**: See Contributors section below
8
8
  **Copyright**: 2007-2013
9
9
  **License**: MIT License
10
- **Latest Version**: 0.8.5.2
11
- **Release Date**: February 26th 2013
10
+ **Latest Version**: 0.8.6
11
+ **Release Date**: April 13th 2013
12
12
 
13
13
  ## Synopsis
14
14
 
@@ -283,6 +283,13 @@ More options can be seen by typing `yard graph --help`, but here is an example:
283
283
 
284
284
  ## Changelog
285
285
 
286
+ - **April.13.13**: 0.8.6 release
287
+ - Various fixes and improved Ruby 2.x compatibility support
288
+ - Added support for `asciidoc` markup type
289
+ - Added `yard markups` command to list available markup types
290
+ - Added `yard display` command to display and format an individual object
291
+ - See {file:docs/WhatsNew.md} for more information on added features.
292
+
286
293
  - **February.26.13**: 0.8.5.2 release
287
294
  - Support new keyword argument syntax in method signatures (Ruby 2.x)
288
295
 
data/bin/yard CHANGED
@@ -3,7 +3,7 @@
3
3
  # We do all this work just to find the proper load path
4
4
  path = __FILE__
5
5
  while File.symlink?(path)
6
- path = File.expand_path(File.readlink(__FILE__), File.dirname(__FILE__))
6
+ path = File.expand_path(File.readlink(path), File.dirname(path))
7
7
  end
8
8
  $:.unshift(File.join(File.dirname(File.expand_path(path)), '..', 'lib'))
9
9
 
data/bin/yardoc CHANGED
@@ -3,7 +3,7 @@
3
3
  # We do all this work just to find the proper load path
4
4
  path = __FILE__
5
5
  while File.symlink?(path)
6
- path = File.expand_path(File.readlink(__FILE__), File.dirname(__FILE__))
6
+ path = File.expand_path(File.readlink(path), File.dirname(path))
7
7
  end
8
8
  $:.unshift(File.join(File.dirname(File.expand_path(path)), '..', 'lib'))
9
9
 
data/bin/yri CHANGED
@@ -3,7 +3,7 @@
3
3
  # We do all this work just to find the proper load path
4
4
  path = __FILE__
5
5
  while File.symlink?(path)
6
- path = File.expand_path(File.readlink(__FILE__), File.dirname(__FILE__))
6
+ path = File.expand_path(File.readlink(path), File.dirname(path))
7
7
  end
8
8
  $:.unshift(File.join(File.dirname(File.expand_path(path)), '..', 'lib'))
9
9
 
data/docs/WhatsNew.md CHANGED
@@ -18,6 +18,9 @@
18
18
  14. **Added `--api` tag to generate documentation for API sets** (0.8.1)
19
19
  15. **Added `--non-transitive-tag` to disable transitive tag** (0.8.3)
20
20
  16. **Added `-B/--bind` to bind to a port in yard server** (0.8.4)
21
+ 17. **Added `asciidoc` markup type support** (0.8.6)
22
+ 18. **Added `yard markups` command to list available markup types** (0.8.6)
23
+ 18. **Added `yard display` command to display formatted objects** (0.8.6)
21
24
 
22
25
  ## Directives (new behavioural tag syntax) (0.8.0)
23
26
 
@@ -298,6 +301,41 @@ when parsing modules and classes.
298
301
  You can now bind the `yard server` command to a given local port
299
302
  with `yard server -B PORT` or `yard server --bind PORT`.
300
303
 
304
+ ## Added `asciidoc` markup type support (0.8.6)
305
+
306
+ Support for the AsciiDoc markup type is now introduced using the `asciidoc`
307
+ markup type (`yard doc -m asciidoc`). Requires the
308
+ [asciidoctor](http://rubygems.org/gems/asciidoctor) RubyGem library to be
309
+ installed before running YARD.
310
+
311
+ ## Added `yard markups` command to list available markup types (0.8.6)
312
+
313
+ You can now list all available markup types and their respective providers by
314
+ typing `yard markups`. This list also includes the file extensions used to
315
+ auto-identify markup types for extra files and READMEs. To use a markup in
316
+ the list, call `yard doc` with `-m MARKUP_TYPE`. To select a specific markup
317
+ provider library, pass the `-M PROVIDER_NAME` option.
318
+
319
+ ## Added `yard display` command to display formatted objects (0.8.6)
320
+
321
+ <p class="note">This feature requires the .yardoc registry to have already been
322
+ generated. To generate the registry, run <code>yard doc -n</code>.</p>
323
+
324
+ You can now display a single object (or a list of objects) in the YARD registry
325
+ using the `yard display OBJECT ...` command. For example, to display the
326
+ `YARD::CodeObjects` module as text (the way it is displayed in `yri`), type:
327
+
328
+ $ yard display YARD::CodeObjects
329
+
330
+ You can also format individual objects as HTML. For example, you can format
331
+ the above object as HTML and pipe the contents into a file readable by a
332
+ web browser:
333
+
334
+ $ yard display -f html YARD::CodeObjects > codeobjects.html
335
+
336
+ Custom templating options from `yard doc` can also be used, see
337
+ `yard display --help` for more options.
338
+
301
339
  # What's New in 0.7.x?
302
340
 
303
341
  1. **Macro support and detection of DSL methods** (0.7.0)
data/lib/yard/autoload.rb CHANGED
@@ -7,10 +7,12 @@ module YARD
7
7
  autoload :CommandParser, __p('cli/command_parser')
8
8
  autoload :Config, __p('cli/config')
9
9
  autoload :Diff, __p('cli/diff')
10
+ autoload :Display, __p('cli/display')
10
11
  autoload :Gems, __p('cli/gems')
11
12
  autoload :Graph, __p('cli/graph')
12
13
  autoload :Help, __p('cli/help')
13
14
  autoload :List, __p('cli/list')
15
+ autoload :MarkupTypes, __p('cli/markup_types')
14
16
  autoload :Server, __p('cli/server')
15
17
  autoload :Stats, __p('cli/stats')
16
18
  autoload :Yardoc, __p('cli/yardoc')
@@ -253,6 +255,7 @@ module YARD
253
255
  module Helpers # Namespace for template helpers
254
256
  module Markup # Namespace for markup providers
255
257
  autoload :RDocMarkup, __p('templates/helpers/markup/rdoc_markup')
258
+ autoload :RDocMarkdown, __p('templates/helpers/markup/rdoc_markdown')
256
259
  end
257
260
 
258
261
  autoload :BaseHelper, __p('templates/helpers/base_helper')
@@ -31,17 +31,19 @@ module YARD
31
31
  end
32
32
 
33
33
  self.commands = SymbolHash[
34
- :config => Config,
35
- :diff => Diff,
36
- :doc => Yardoc,
37
- :gems => Gems,
38
- :graph => Graph,
39
- :help => Help,
40
- :list => List,
41
- :ri => YRI,
42
- :server => Server,
43
- :stats => Stats,
44
- :i18n => I18n
34
+ :config => Config,
35
+ :diff => Diff,
36
+ :display => Display,
37
+ :doc => Yardoc,
38
+ :gems => Gems,
39
+ :graph => Graph,
40
+ :help => Help,
41
+ :list => List,
42
+ :markups => MarkupTypes,
43
+ :ri => YRI,
44
+ :server => Server,
45
+ :stats => Stats,
46
+ :i18n => I18n
45
47
  ]
46
48
 
47
49
  self.default_command = :doc
data/lib/yard/cli/diff.rb CHANGED
@@ -101,6 +101,7 @@ module YARD
101
101
  end
102
102
 
103
103
  def load_git_commit(commit)
104
+ Registry.clear
104
105
  commit_path = 'git_commit' + commit.gsub(/\W/, '_')
105
106
  tmpdir = File.join(Dir.tmpdir, commit_path)
106
107
  log.info "Expanding #{commit} to #{tmpdir}..."
@@ -266,4 +267,4 @@ module YARD
266
267
  end
267
268
  end
268
269
  end
269
- end
270
+ end
@@ -0,0 +1,43 @@
1
+ module YARD
2
+ module CLI
3
+ # Display one object
4
+ # @since 0.8.6
5
+ class Display < Yardoc
6
+ def description; 'Displays a formatted object' end
7
+
8
+ def initialize(*args)
9
+ super
10
+ options.format = :text # default for this command
11
+ end
12
+
13
+ # Runs the commandline utility, parsing arguments and displaying an object
14
+ # from the {Registry}.
15
+ #
16
+ # @param [Array<String>] args the list of arguments.
17
+ # @return [void]
18
+ def run(*args)
19
+ return unless parse_arguments(*args)
20
+ @objects.each do |obj|
21
+ log.puts obj.format(options)
22
+ end
23
+ end
24
+
25
+ # Parses commandline options.
26
+ # @param [Array<String>] args each tokenized argument
27
+ def parse_arguments(*args)
28
+ opts = OptionParser.new
29
+ opts.banner = "Usage: yard display [options] OBJECT [OTHER OBJECTS]"
30
+ general_options(opts)
31
+ output_options(opts)
32
+ parse_options(opts, args)
33
+
34
+ Registry.load
35
+ @objects = args.map {|o| Registry.at(o) }
36
+
37
+ # validation
38
+ return false if @objects.any? {|o| o.nil? }
39
+ verify_markup_options
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,33 @@
1
+ module YARD
2
+ module CLI
3
+ # Lists all markup types
4
+ # @since 0.8.6
5
+ class MarkupTypes < Command
6
+ def description; 'Lists all available markup types and libraries' end
7
+
8
+ # Runs the commandline utility, parsing arguments and displaying a
9
+ # list of markup types
10
+ #
11
+ # @param [Array<String>] args the list of arguments.
12
+ # @return [void]
13
+ def run(*args)
14
+ log.puts "Available markup types for `doc' command:"
15
+ log.puts
16
+ types = Templates::Helpers::MarkupHelper::MARKUP_PROVIDERS
17
+ exts = Templates::Helpers::MarkupHelper::MARKUP_EXTENSIONS
18
+ types.sort_by {|name, _| name.to_s }.each do |name, providers|
19
+ log.puts "[#{name}]"
20
+ libs = providers.map {|p| p[:lib] }.compact
21
+ if libs.size > 0
22
+ log.puts " Providers: #{libs.join(" ")}"
23
+ end
24
+ if exts[name]
25
+ log.puts " Extensions: #{exts[name].map {|e| ".#{e}"}.join(" ")}"
26
+ end
27
+
28
+ log.puts
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -6,6 +6,7 @@ module YARD
6
6
  def path; @path ||= "" end
7
7
  def inspect; @inspect ||= "#<yardoc root>" end
8
8
  def root?; true end
9
+ def title; 'Top Level Namespace' end
9
10
  def equal?(other)
10
11
  other == :root ? true : super(other)
11
12
  end
@@ -71,11 +71,14 @@ module YARD
71
71
  # docstring. May be nil.
72
72
  # @param [String] raw_data the complete docstring, including all
73
73
  # original formatting and any unparsed tags/directives.
74
- def self.new!(text, tags = [], object = nil, raw_data = nil)
74
+ # @param [CodeObjects::Base, nil] A reference object used for the base set
75
+ # of documentation / tag information.
76
+ def self.new!(text, tags = [], object = nil, raw_data = nil, ref_object = nil)
75
77
  docstring = allocate
76
78
  docstring.replace(text, false)
77
79
  docstring.object = object
78
80
  docstring.add_tag(*tags)
81
+ docstring.instance_variable_set("@unresolved_reference", ref_object)
79
82
  docstring.instance_variable_set("@all", raw_data) if raw_data
80
83
  docstring
81
84
  end
@@ -168,13 +171,14 @@ module YARD
168
171
  def summary
169
172
  resolve_reference
170
173
  return @summary if @summary
174
+ stripped = self.gsub(/<.+?>/m, '').strip
171
175
  open_parens = ['{', '(', '[']
172
176
  close_parens = ['}', ')', ']']
173
177
  num_parens = 0
174
178
  idx = length.times do |index|
175
- case self[index, 1]
179
+ case stripped[index, 1]
176
180
  when ".", "\r", "\n"
177
- next_char = self[index + 1, 1].to_s
181
+ next_char = stripped[index + 1, 1].to_s
178
182
  if num_parens == 0 && next_char =~ /^\s*$/
179
183
  break index - 1
180
184
  end
@@ -184,7 +188,7 @@ module YARD
184
188
  num_parens -= 1
185
189
  end
186
190
  end
187
- @summary = self[0..idx]
191
+ @summary = stripped[0..idx]
188
192
  if !@summary.empty? && @summary !~ /\A\s*\{include:.+\}\s*\Z/
189
193
  @summary += '.'
190
194
  end
@@ -92,7 +92,7 @@ module YARD
92
92
  # @return [Docstring] translates parsed text into
93
93
  # a Docstring object.
94
94
  def to_docstring
95
- Docstring.new!(text, tags, object, raw_text)
95
+ Docstring.new!(text, tags, object, raw_text, reference)
96
96
  end
97
97
 
98
98
  # @!group Parsing Methods
@@ -85,7 +85,7 @@ module YARD
85
85
  # @group Processing other files
86
86
 
87
87
  def process_file(file, object)
88
- file = File.cleanpath(File.relative_path(statement.file, file))
88
+ file = File.cleanpath(file)
89
89
  return if processed_files[file]
90
90
  processed_files[file] = file
91
91
  begin
@@ -10,7 +10,14 @@ class YARD::Handlers::Ruby::Legacy::MethodHandler < YARD::Handlers::Ruby::Legacy
10
10
  meth, args = $1, $2
11
11
  meth.gsub!(/\s+/,'')
12
12
  args = tokval_list(YARD::Parser::Ruby::Legacy::TokenList.new(args), :all)
13
- args.map! {|a| k, v = *a.split('=', 2); [k.strip, (v ? v.strip : nil)] } if args
13
+ args.map! do |a|
14
+ k, v, r = *a.split(/(:)|=/, 2)
15
+ if r
16
+ k += v
17
+ v = r
18
+ end
19
+ [k.strip, (v ? v.strip : nil)]
20
+ end if args
14
21
  else
15
22
  raise YARD::Parser::UndocumentableError, "method: invalid name"
16
23
  end
data/lib/yard/logging.rb CHANGED
@@ -12,7 +12,8 @@ module YARD
12
12
 
13
13
  # @return [IO] the IO object being logged to
14
14
  # @since 0.8.2
15
- attr_accessor :io
15
+ def io; @logdev end
16
+ def io=(pipe) @logdev = pipe end
16
17
 
17
18
  # @return [Boolean] whether backtraces should be shown (by default
18
19
  # this is on).
@@ -200,6 +200,7 @@ module YARD
200
200
  [:TkINTEGER, TkVal],
201
201
  [:TkFLOAT, TkVal],
202
202
  [:TkSYMBOL, TkVal],
203
+ [:TkLABEL, TkVal],
203
204
  [:TkSTRING, TkVal],
204
205
  [:TkXSTRING, TkVal],
205
206
  [:TkREGEXP, TkVal],
@@ -53,7 +53,12 @@ module YARD
53
53
  end
54
54
 
55
55
  def convert_token(lex, tk)
56
- if TkSYMBEG === tk && next_tk = lex.token
56
+ if TkIDENTIFIER === tk && lex.peek == ':'
57
+ next_tk = lex.token
58
+ sym = TkLABEL.new(tk.line_no, tk.char_no, nil)
59
+ sym.lex_state = lex.lex_state
60
+ sym.set_text(tk.text + next_tk.text)
61
+ elsif TkSYMBEG === tk && next_tk = lex.token
57
62
  sym = TkSYMBOL.new(tk.line_no, tk.char_no, nil)
58
63
  sym.lex_state = lex.lex_state
59
64
  sym.set_text(tk.text + next_tk.text)
@@ -470,7 +470,6 @@ module YARD
470
470
  if content =~ ENCODING_LINE
471
471
  content.force_encoding($1)
472
472
  else
473
- old_encoding = content.encoding
474
473
  content.force_encoding('binary')
475
474
  ENCODING_BYTE_ORDER_MARKS.each do |encoding, bom|
476
475
  bom.force_encoding('binary')
@@ -479,7 +478,7 @@ module YARD
479
478
  return content
480
479
  end
481
480
  end
482
- content.force_encoding(old_encoding)
481
+ content.force_encoding('utf-8') # UTF-8 is default encoding
483
482
  content
484
483
  end
485
484
  end
@@ -404,7 +404,7 @@ module YARD
404
404
  obj.signature = method_signature
405
405
  obj.parameters = OverloadTag.new(:overload, method_signature).parameters
406
406
  obj.docstring = Docstring.new!(parser.text, parser.tags, obj,
407
- parser.raw_text)
407
+ parser.raw_text, parser.reference)
408
408
  handler.register_module_function(obj)
409
409
  obj
410
410
  end
@@ -121,9 +121,9 @@ module YARD::Templates::Helpers
121
121
 
122
122
  case object
123
123
  when YARD::CodeObjects::Base, YARD::CodeObjects::Proxy
124
- object.path
124
+ object.title
125
125
  when String, Symbol
126
- P(object).path
126
+ P(object).title
127
127
  else
128
128
  object
129
129
  end
@@ -195,7 +195,7 @@ module YARD::Templates::Helpers
195
195
  when YARD::CodeObjects::RootObject
196
196
  "Top Level Namespace"
197
197
  else
198
- format_object_type(object) + ": " + object.path
198
+ format_object_type(object) + ": " + object.title
199
199
  end
200
200
  end
201
201
 
@@ -67,6 +67,13 @@ module YARD
67
67
  end
68
68
  end
69
69
 
70
+ # Converts Asciidoc to HTML
71
+ # @param [String] text input Asciidoc text
72
+ # @return [String] output HTML
73
+ def html_markup_asciidoc(text)
74
+ markup_class(:asciidoc).render(text)
75
+ end
76
+
70
77
  # Converts Textile to HTML
71
78
  # @param [String] text the input Textile text
72
79
  # @return [String] output HTML
@@ -246,9 +253,7 @@ module YARD
246
253
  def link_object(obj, otitle = nil, anchor = nil, relative = true)
247
254
  return otitle if obj.nil?
248
255
  obj = Registry.resolve(object, obj, true, true) if obj.is_a?(String)
249
- if !otitle && obj.root?
250
- title = "Top Level Namespace"
251
- elsif otitle
256
+ if otitle
252
257
  title = otitle.to_s
253
258
  elsif object.is_a?(CodeObjects::Base)
254
259
  # Check if we're linking to a class method in the current
@@ -0,0 +1,22 @@
1
+ module YARD
2
+ module Templates
3
+ module Helpers
4
+ module Markup
5
+ begin require 'rdoc'; rescue LoadError; end
6
+ begin
7
+ require 'rdoc/markdown'
8
+ rescue LoadError
9
+ raise NameError, "could not load RDoc Markdown support (rdoc is too old)"
10
+ end
11
+
12
+ class RDocMarkdown < RDocMarkup
13
+ def initialize(text)
14
+ super RDoc::Markdown.new.parse(text)
15
+ end
16
+
17
+ def fix_typewriter(html) html end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -13,7 +13,11 @@ module YARD
13
13
  if defined?(RDoc::VERSION) && RDoc::VERSION >= '4.0.0' &&
14
14
  defined?(RDoc::Options)
15
15
  then
16
- def initialize; super(RDoc::Options.new) end
16
+ def initialize
17
+ options = RDoc::Options.new
18
+ options.pipe = true
19
+ super(options)
20
+ end
17
21
  end
18
22
  end
19
23
  rescue LoadError
@@ -28,6 +28,7 @@ module YARD
28
28
  {:lib => :bluecloth, :const => 'BlueCloth'},
29
29
  {:lib => :maruku, :const => 'Maruku'},
30
30
  {:lib => :'rpeg-markdown', :const => 'PEGMarkdown'},
31
+ {:lib => :rdoc, :const => 'YARD::Templates::Helpers::Markup::RDocMarkdown'},
31
32
  ],
32
33
  :textile => [
33
34
  {:lib => :redcloth, :const => 'RedCloth'},
@@ -38,6 +39,9 @@ module YARD
38
39
  :rdoc => [
39
40
  {:lib => nil, :const => 'YARD::Templates::Helpers::Markup::RDocMarkup'},
40
41
  ],
42
+ :asciidoc => [
43
+ {:lib => :asciidoctor, :const => 'Asciidoctor'}
44
+ ],
41
45
  :ruby => [],
42
46
  :text => [],
43
47
  :pre => [],
@@ -53,6 +57,7 @@ module YARD
53
57
  :html => ['htm', 'html', 'shtml'],
54
58
  :text => ['txt'],
55
59
  :textile => ['textile', 'txtile'],
60
+ :asciidoc => ['asciidoc'],
56
61
  :markdown => ['markdown', 'md', 'mdown', 'mkd'],
57
62
  :rdoc => ['rdoc'],
58
63
  :ruby => ['rb', 'ru']
data/lib/yard/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module YARD
2
- VERSION = "0.8.5.2"
2
+ VERSION = "0.8.6"
3
3
  end
@@ -0,0 +1,13 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe YARD::CLI::Display do
4
+ it "displays an object" do
5
+ Registry.stub(:load)
6
+ foo = CodeObjects::ClassObject.new(:root, :Foo)
7
+ foo.docstring = 'Foo bar'
8
+ output = foo.format
9
+
10
+ YARD::CLI::Display.run('-f', 'text', 'Foo')
11
+ log.io.string.strip.should eq(output.strip)
12
+ end
13
+ end
@@ -0,0 +1,22 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe YARD::CLI::MarkupTypes do
4
+ it "lists all available markup types" do
5
+ YARD::CLI::MarkupTypes.run
6
+ data = log.io.string
7
+ exts = YARD::Templates::Helpers::MarkupHelper::MARKUP_EXTENSIONS
8
+ YARD::Templates::Helpers::MarkupHelper::MARKUP_PROVIDERS.each do |name, providers|
9
+ data.should match(/\b#{name}\b/)
10
+
11
+ # Match all extensions
12
+ exts[name].each do |ext|
13
+ data.should include(".#{ext}")
14
+ end if exts[name]
15
+
16
+ # Match all provider libs
17
+ providers.each do |provider|
18
+ data.should match(/\b#{provider[:lib]}\b/)
19
+ end
20
+ end
21
+ end
22
+ end
@@ -52,6 +52,11 @@ describe YARD::Docstring do
52
52
  5.times { o1.summary.should == "Hello." }
53
53
  end
54
54
 
55
+ it "should strip HTML before summarizing" do
56
+ doc = Docstring.new("<p>Hello <b>world</b></p>.")
57
+ doc.summary.should == 'Hello world.'
58
+ end
59
+
55
60
  it "should return the first sentence" do
56
61
  o = Docstring.new("DOCSTRING. Another sentence")
57
62
  o.summary.should == "DOCSTRING."
@@ -302,4 +307,19 @@ describe YARD::Docstring do
302
307
  doc.dup.line_range.should == doc.line_range
303
308
  end
304
309
  end
310
+
311
+ describe 'reference docstrings' do
312
+ it 'allows for construction of docstring with ref object' do
313
+ YARD.parse_string <<-eof
314
+ class A
315
+ # Docstring
316
+ def a; end
317
+ # (see #a)
318
+ def b; end
319
+ end
320
+ eof
321
+ YARD::Registry.at('A#b').docstring.should == 'Docstring'
322
+ YARD::Registry.clear
323
+ end
324
+ end
305
325
  end
@@ -184,16 +184,17 @@ describe YARD::Handlers::C::MethodHandler do
184
184
  * Foo bar!
185
185
  */
186
186
  eof
187
- File.should_receive(:read).with('other.c').and_return(other)
188
- parse <<-eof
187
+ File.should_receive(:read).with('foo/bar/other.c').and_return(other)
188
+ src = <<-eof
189
189
  void Init_Foo() {
190
190
  mFoo = rb_define_module("Foo");
191
- rb_define_method(mFoo, "foo", foo, 0); // in other.c
192
- rb_define_method(mFoo, "initialize", foo, 0); // in other.c
193
- mBar = rb_define_module_under(mFoo, "Bar"); // in other.c
194
- rb_define_method(mBar, "baz", foo, 0); // in other.c
191
+ rb_define_method(mFoo, "foo", foo, 0); // in foo/bar/other.c
192
+ rb_define_method(mFoo, "initialize", foo, 0); // in foo/bar/other.c
193
+ mBar = rb_define_module_under(mFoo, "Bar"); // in foo/bar/other.c
194
+ rb_define_method(mBar, "baz", foo, 0); // in foo/bar/other.c
195
195
  }
196
196
  eof
197
+ parse(src, 'foo/bar/baz/init.c')
197
198
  Registry.at('Foo#foo').docstring.should == 'Foo bar!'
198
199
  Registry.at('Foo#initialize').docstring.should == 'Foo bar!'
199
200
  Registry.at('Foo::Bar#baz').docstring.should == 'Foo bar!'
@@ -1,8 +1,10 @@
1
1
  require File.dirname(__FILE__) + "/../spec_helper"
2
2
 
3
- def parse(src)
3
+ def parse(src, file = '(stdin)')
4
4
  YARD::Registry.clear
5
- YARD.parse_string(src, :c)
5
+ parser = YARD::Parser::SourceParser.new(:c)
6
+ parser.file = file
7
+ parser.parse(StringIO.new(src))
6
8
  end
7
9
 
8
10
  def parse_init(src)
@@ -33,6 +33,14 @@ describe YARD::Parser::Ruby::Legacy::TokenList do
33
33
  x[4].class.should == TkDSTRING
34
34
  x.to_s.should == 'x = "hello #{world}"' + "\n"
35
35
  end
36
+
37
+ it 'handles label syntax' do
38
+ x = TokenList.new('a:1,b:2')
39
+ x[0].class.should == TkLABEL
40
+ x[0].text.should == 'a:'
41
+ x[3].class.should == TkLABEL
42
+ x[3].text.should == 'b:'
43
+ end
36
44
  end
37
45
 
38
46
  describe '#to_s' do
@@ -548,7 +548,7 @@ describe YARD::Parser::SourceParser do
548
548
  result = parser.parse("tmpfile")
549
549
  if HAVE_RIPPER && YARD.ruby19?
550
550
  if msg == :should_not
551
- default_encoding = YARD.ruby2? ? 'UTF-8' : 'US-ASCII'
551
+ default_encoding = 'UTF-8'
552
552
  result.enumerator[0].source.encoding.to_s.should eq(default_encoding)
553
553
  else
554
554
  ['Shift_JIS', 'Windows-31J', 'UTF-8'].send(msg, include(
data/spec/spec_helper.rb CHANGED
@@ -121,4 +121,8 @@ module Kernel
121
121
  end
122
122
  end if ENV['TM_APP_PATH']
123
123
 
124
+ RSpec.configure do |config|
125
+ config.before(:each) { log.io = StringIO.new }
126
+ end
127
+
124
128
  include YARD
@@ -43,7 +43,7 @@ describe YARD::Templates::Helpers::BaseHelper do
43
43
  end
44
44
 
45
45
  it "should return a path if argument is a Proxy or object" do
46
- link_object(Registry.root).should == ""
46
+ link_object(Registry.root).should == "Top Level Namespace"
47
47
  link_object(P("Array")).should == "Array"
48
48
  end
49
49
 
@@ -165,10 +165,10 @@ describe YARD::Templates::Helpers::BaseHelper do
165
165
  format_object_title(Registry.root).should == "Top Level Namespace"
166
166
  end
167
167
 
168
- it "should return 'type: path' in other cases" do
168
+ it "should return 'type: title' in other cases" do
169
169
  obj = mock(:object)
170
170
  obj.stub!(:type).and_return(:class)
171
- obj.stub!(:path).and_return("A::B::C")
171
+ obj.stub!(:title).and_return("A::B::C")
172
172
  format_object_title(obj).should == "Class: A::B::C"
173
173
  end
174
174
  end
@@ -7,5 +7,5 @@ def init
7
7
  end
8
8
 
9
9
  def format_object_title(object)
10
- "Class: #{object.path} < #{object.superclass.path}"
10
+ "Class: #{object.title} < #{object.superclass.title}"
11
11
  end
@@ -2,11 +2,7 @@
2
2
  <% @items.each do |item| %>
3
3
  <li class="r<%= n %> <%= item.has_tag?(:deprecated) ? 'deprecated' : '' %>">
4
4
  <%= linkify item, h(item.name(true)) %>
5
- <% if item.namespace && !item.namespace.root? %>
6
- <small><%= item.namespace %></small>
7
- <% else %>
8
- <small>Top Level Namespace</small>
9
- <% end %>
5
+ <small><%= item.namespace.title %></small>
10
6
  </li>
11
7
  <% n = n == 2 ? 1 : 2 %>
12
8
  <% end %>
@@ -17,6 +17,7 @@ function fullListSearch() {
17
17
  searchCache = [];
18
18
  $('#full_list li').each(function() {
19
19
  var link = $(this).find('.object_link a');
20
+ if (link.length === 0) return;
20
21
  var fullName = link.attr('title').split(' ')[0];
21
22
  searchCache.push({name:link.text(), fullName:fullName, node:$(this), link:link});
22
23
  });
@@ -41,7 +42,7 @@ function fullListSearch() {
41
42
  $('#full_list li').removeClass('found').each(function() {
42
43
 
43
44
  var link = $(this).find('.object_link a');
44
- link.text(link.text());
45
+ if (link.length > 0) link.text(link.text());
45
46
  });
46
47
  if (clicked) {
47
48
  clicked.parents('ul').each(function() {
@@ -110,6 +111,10 @@ clicked = null;
110
111
  function linkList() {
111
112
  $('#full_list li, #full_list li a:last').click(function(evt) {
112
113
  if ($(this).hasClass('toggle')) return true;
114
+ if ($(this).find('.object_link a').length === 0) {
115
+ $(this).children('a.toggle').click();
116
+ return false;
117
+ }
113
118
  if (this.tagName.toLowerCase() == "li") {
114
119
  var toggle = $(this).children('a.toggle');
115
120
  if (toggle.size() > 0 && evt.pageX < toggle.offset().left) {
@@ -192,11 +192,7 @@ def class_list(root = Registry.root)
192
192
  out << linkify(child, name)
193
193
  out << " &lt; #{child.superclass.name}" if child.is_a?(CodeObjects::ClassObject) && child.superclass
194
194
  out << "<small class='search_info'>"
195
- if !child.namespace || child.namespace.root?
196
- out << "Top Level Namespace"
197
- else
198
- out << child.namespace.path
199
- end
195
+ out << child.namespace.title
200
196
  out << "</small>"
201
197
  out << "</li>"
202
198
  out << "<ul>#{class_list(child)}</ul>" if has_children
@@ -6,7 +6,7 @@
6
6
  <% end %>
7
7
  </title>
8
8
  <% stylesheets.each do |stylesheet| %>
9
- <link rel="stylesheet" href="<%= url_for(stylesheet) %>" type="text/css" media="screen" charset="utf-8" />
9
+ <link rel="stylesheet" href="<%= url_for(stylesheet) %>" type="text/css" charset="utf-8" />
10
10
  <% end %>
11
11
  <%= erb :script_setup %>
12
12
  <% javascripts.each do |javascript| %>
@@ -2,7 +2,7 @@
2
2
  <p class="children">
3
3
  <% @inner.each do |name, list| %>
4
4
  <% if list.size > 0 %>
5
- <strong class="<%= name %>"><%= name.to_s.capitalize %>:</strong> <%= list.map {|child| linkify(child, child.name) }.join(", ") %>
5
+ <strong class="<%= name %>"><%= name.to_s.capitalize %>:</strong> <%= list.map {|child| linkify(child, child.name(true)) }.join(", ") %>
6
6
  <% end %>
7
7
  <% end %>
8
8
  </p>
@@ -0,0 +1,6 @@
1
+ <style type="text/css">
2
+ <%= @css_data %>
3
+ </style>
4
+ <script type="text/javascript" charset="utf-8">
5
+ <%= @js_data %>
6
+ </script>
@@ -4,12 +4,7 @@
4
4
  <head>
5
5
  <meta http-equiv="Content-Type" content="text/html; charset=<%= charset %>" />
6
6
  <title><%= @title %></title>
7
- <style type="text/css" media="screen">
8
- <%= @css_data %>
9
- </style>
10
- <script type="text/javascript" charset="utf-8">
11
- <%= @js_data %>
12
- </script>
7
+ <%= erb(:headers) %>
13
8
  </head>
14
9
  <body>
15
10
  <div id="content">
@@ -6,6 +6,14 @@ module OverrideFileLinks
6
6
  log.enter_level(Logger::ERROR) { result = super }
7
7
  result
8
8
  end
9
+
10
+ def url_for(object, *args)
11
+ if CodeObjects::ExtraFileObject === object && object == options.readme
12
+ 'index.html'
13
+ else
14
+ super
15
+ end
16
+ end
9
17
  end
10
18
 
11
19
  Template.extra_includes << OverrideFileLinks
@@ -14,13 +22,15 @@ def init
14
22
  class << options.serializer
15
23
  def serialized_path(object)
16
24
  if CodeObjects::ExtraFileObject === object
17
- super.sub(/^file\./, '')
25
+ super.sub(/^file\./, '').downcase
18
26
  else
19
27
  super
20
28
  end
21
29
  end
22
30
  end if options.serializer
23
31
 
32
+ return serialize_onefile if options.onefile
33
+
24
34
  generate_assets
25
35
  options.delete(:objects)
26
36
  options.files.each {|file| serialize_file(file) }
@@ -52,3 +62,12 @@ def serialize_file(file)
52
62
  end
53
63
  options.delete(:file)
54
64
  end
65
+
66
+ def serialize_onefile
67
+ layout = Object.new.extend(T('layout'))
68
+ options.css_data = layout.stylesheets.map {|sheet| file(sheet,true) }.join("\n")
69
+ options.js_data = layout.javascripts.map {|script| file(script,true) }.join("")
70
+ Templates::Engine.with_serializer('onefile.html', options.serializer) do
71
+ T('onefile').run(options)
72
+ end
73
+ end
@@ -4,17 +4,21 @@ def init
4
4
  super
5
5
 
6
6
  @topfile = options.readme
7
- @toptitle = options.readme.attributes[:title] || "Documentation Overview"
8
- if @file == options.readme
9
- @page_title = options.title
10
- else
11
- @page_title = @file.title
12
- end
7
+ if options.files
8
+ if @topfile
9
+ @toptitle = @topfile.attributes[:title] || "Documentation Overview"
10
+ end
11
+ if @file == options.readme
12
+ @page_title = options.title
13
+ else
14
+ @page_title = @file.title
15
+ end
13
16
 
14
- index = options.files.index(@file)
15
- if index
16
- @prevfile = index > 0 ? (options.files[index - 1] || options.readme) : nil
17
- @nextfile = options.files[index + 1]
17
+ index = options.files.index(@file)
18
+ if index
19
+ @prevfile = index > 0 ? (options.files[index - 1] || options.readme) : nil
20
+ @nextfile = options.files[index + 1]
21
+ end
18
22
  end
19
23
  end
20
24
 
@@ -0,0 +1,4 @@
1
+ <% @files.each do |file| %>
2
+ <% @file = file %>
3
+ <%= diskfile %>
4
+ <% end %>
@@ -0,0 +1,5 @@
1
+ include T('default/onefile/html')
2
+
3
+ def init
4
+ sections :layout, [:toc, :files]
5
+ end
@@ -0,0 +1,3 @@
1
+ <h1><%= @title %></h1>
2
+ <h2>Table of Contents</h2>
3
+ <div id="toc" class="one-file"></div>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.5.2
4
+ version: 0.8.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Loren Segal
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-02-26 00:00:00.000000000 Z
11
+ date: 2013-04-13 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |2
14
14
  YARD is a documentation generation tool for the Ruby programming language.
@@ -53,11 +53,13 @@ files:
53
53
  - lib/yard/cli/command_parser.rb
54
54
  - lib/yard/cli/config.rb
55
55
  - lib/yard/cli/diff.rb
56
+ - lib/yard/cli/display.rb
56
57
  - lib/yard/cli/gems.rb
57
58
  - lib/yard/cli/graph.rb
58
59
  - lib/yard/cli/help.rb
59
60
  - lib/yard/cli/i18n.rb
60
61
  - lib/yard/cli/list.rb
62
+ - lib/yard/cli/markup_types.rb
61
63
  - lib/yard/cli/server.rb
62
64
  - lib/yard/cli/stats.rb
63
65
  - lib/yard/cli/yardoc.rb
@@ -226,6 +228,7 @@ files:
226
228
  - lib/yard/templates/helpers/filter_helper.rb
227
229
  - lib/yard/templates/helpers/html_helper.rb
228
230
  - lib/yard/templates/helpers/html_syntax_highlight_helper.rb
231
+ - lib/yard/templates/helpers/markup/rdoc_markdown.rb
229
232
  - lib/yard/templates/helpers/markup/rdoc_markup.rb
230
233
  - lib/yard/templates/helpers/markup_helper.rb
231
234
  - lib/yard/templates/helpers/method_helper.rb
@@ -242,11 +245,13 @@ files:
242
245
  - spec/cli/command_spec.rb
243
246
  - spec/cli/config_spec.rb
244
247
  - spec/cli/diff_spec.rb
248
+ - spec/cli/display_spec.rb
245
249
  - spec/cli/gems_spec.rb
246
250
  - spec/cli/graph_spec.rb
247
251
  - spec/cli/help_spec.rb
248
252
  - spec/cli/i18n_spec.rb
249
253
  - spec/cli/list_spec.rb
254
+ - spec/cli/markup_types_spec.rb
250
255
  - spec/cli/server_spec.rb
251
256
  - spec/cli/stats_spec.rb
252
257
  - spec/cli/yardoc_spec.rb
@@ -512,6 +517,7 @@ files:
512
517
  - templates/default/module/text/instance_meths_list.erb
513
518
  - templates/default/module/text/setup.rb
514
519
  - templates/default/onefile/html/files.erb
520
+ - templates/default/onefile/html/headers.erb
515
521
  - templates/default/onefile/html/layout.erb
516
522
  - templates/default/onefile/html/readme.erb
517
523
  - templates/default/onefile/html/setup.rb
@@ -543,6 +549,9 @@ files:
543
549
  - templates/guide/module/html/header.erb
544
550
  - templates/guide/module/html/method_list.erb
545
551
  - templates/guide/module/html/setup.rb
552
+ - templates/guide/onefile/html/files.erb
553
+ - templates/guide/onefile/html/setup.rb
554
+ - templates/guide/onefile/html/toc.erb
546
555
  - templates/guide/tags/html/setup.rb
547
556
  - benchmarks/builtins_vs_eval.rb
548
557
  - benchmarks/concat_vs_join.rb