inch 0.6.0.rc5 → 0.6.0.rc6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4e0fbf4de3c8dff60c578af2acaddbd061645c03
4
- data.tar.gz: 16c82a3ace60404b68e622ab5e25e9750692ef6b
3
+ metadata.gz: c8e5fc3d5ed658a3353dd12bb0ddd920cabf969e
4
+ data.tar.gz: a5c679dcdd4ce2196d779f3fa536ee63e9a7784e
5
5
  SHA512:
6
- metadata.gz: 4f90b4d92ab6c91c07b7957ba2d4336ba6eaa26abb42487d18fddb9b8a937326c7e548a63050f8c9af88a80aaba83c3f11d442e9ecb256ef1719d1265620fbe4
7
- data.tar.gz: aeb3b4b108f805749237ceece228644828f5bda071b6cd4e490decb82ba66835df22cd86e122c3df1e7c8e59e4d466dfc53d91533bd611d0e2f93aabea98043a
6
+ metadata.gz: 1c05926dd14887882de1cc8bc6f99b1b4f8365fbc8915849b921ec9f99fb47a8b2d9b3b89217876e8eb3ecebc0eb9ad63cba96f1e184daa5ef91ac5691470d07
7
+ data.tar.gz: e836bc2a885bf658b7bf2b09e2b2f259326ce398f85490a547b77a8e38acee7467cd1f804593c1592ea721341fa5a7844c71bae9158f749bb44c679cf2fabcca
data/.travis.yml CHANGED
@@ -1,3 +1,4 @@
1
+ sudo: false
1
2
  language: ruby
2
3
  rvm:
3
4
  - 1.9.3
@@ -25,6 +25,7 @@ module Inch
25
25
  # @param config [Inch::Config::Codebase] configuration for codebase
26
26
  # @return [void]
27
27
  def parse(dir, config)
28
+ raise "Directory does not exist: #{dir}" if !File.exist?(dir)
28
29
  Dir.chdir(dir) do
29
30
  parse_objects(config.included_files, config.excluded_files,
30
31
  config.read_dump_file)
@@ -28,6 +28,7 @@ module Inch
28
28
  # @param config [Inch::Config::Codebase] configuration for codebase
29
29
  # @return [void]
30
30
  def parse(dir, config)
31
+ raise "Directory does not exist: #{dir}" if !File.exist?(dir)
31
32
  Dir.chdir(dir) do
32
33
  parse_objects(config.included_files, config.excluded_files,
33
34
  config.read_dump_file)
@@ -108,6 +108,12 @@ module Inch
108
108
  self[:has_doc?]
109
109
  end
110
110
 
111
+ # @return [Boolean] +true+ if the docstring mentions a given
112
+ # +member_name+.
113
+ def has_doc_for?(member_name)
114
+ docstring.mentions_member?(member_name)
115
+ end
116
+
111
117
  def has_multiple_code_examples?
112
118
  self[:has_multiple_code_examples?]
113
119
  end
@@ -16,6 +16,10 @@ module Inch
16
16
  self[:getter?]
17
17
  end
18
18
 
19
+ def has_doc?
20
+ super || mentioned_in_parent_docstring?
21
+ end
22
+
19
23
  def has_parameters?
20
24
  !parameters.empty?
21
25
  end
@@ -75,9 +79,20 @@ module Inch
75
79
  self[:source?]
76
80
  end
77
81
 
82
+ def undocumented?
83
+ super && !mentioned_in_parent_docstring?
84
+ end
85
+
78
86
  def questioning_name?
79
87
  self[:questioning_name?]
80
88
  end
89
+
90
+ private
91
+
92
+ def mentioned_in_parent_docstring?
93
+ parent && parent.has_doc_for?(name)
94
+ end
95
+
81
96
  end
82
97
  end
83
98
  end
@@ -35,6 +35,14 @@ module Inch
35
35
  end
36
36
  end
37
37
 
38
+ # Returns +true+ if the docstring mentions a member with the given
39
+ # +name+.
40
+ def mentions_member?(name)
41
+ mentions_parameter?(name)
42
+ end
43
+
44
+ # Returns +true+ if the docstring mentions a parameter with the
45
+ # given +name+.
38
46
  def mentions_parameter?(name)
39
47
  return false if name.nil?
40
48
  mention_parameter_regexps(name).any? do |pattern|
@@ -111,7 +119,7 @@ module Inch
111
119
  /\+#{expr}\+\:\:/, # +param1+::
112
120
  /<tt>#{expr}<\/tt>/, # <tt>param1</tt>
113
121
  /<tt>#{expr}<\/tt>\:\:/, # <tt>param1</tt>::
114
- /^#{expr}\ +\-\ / # param1 -
122
+ /^\s*#{expr}\ +\-\ / # param1 -
115
123
  ]
116
124
  end
117
125
 
@@ -206,9 +206,13 @@ module Inch
206
206
  []
207
207
  end
208
208
 
209
- # @return [Array,nil] the parent of the current object or +nil+
209
+ # @return [CodeObject::Base,nil] the parent of the current object or +nil+
210
210
  attr_reader :parent
211
211
 
212
+ def parent_fullname
213
+ parent && parent.fullname
214
+ end
215
+
212
216
  def __parent
213
217
  YARD::Object.for(object.parent) if object.parent
214
218
  end
@@ -52,6 +52,12 @@ module Inch
52
52
  parameters.find { |p| p.name == name.to_s }
53
53
  end
54
54
 
55
+ # Returns the original docstring unless it was generated by YARD.
56
+ # @return [String]
57
+ def original_docstring
58
+ implicit_docstring? ? "" : super
59
+ end
60
+
55
61
  def overridden?
56
62
  !!object.overridden_method
57
63
  end
@@ -21,6 +21,7 @@ module Inch
21
21
  # @param config [Inch::Config::Codebase] configuration for codebase
22
22
  # @return [void]
23
23
  def parse(dir, config)
24
+ raise "Directory does not exist: #{dir}" if !File.exist?(dir)
24
25
  Dir.chdir(dir) do
25
26
  parse_yard_objects(config.included_files,
26
27
  config.excluded_files,
data/lib/inch/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Inch
2
- VERSION = '0.6.0.rc5'
2
+ VERSION = '0.6.0.rc6'
3
3
  end
@@ -44,6 +44,28 @@ module Foo
44
44
  # @option params [Hash<Symbol, String>] :headers The default headers to supply in a request. Only used if params[:headers] is not supplied to Connection#request
45
45
  def method_with_indented_param_tag(params = {})
46
46
  end
47
+
48
+ ##
49
+ # Checks wether the given Foo allows this Actor to perform the given action.
50
+ #
51
+ # @param action [Symbol] a valid action for this Foo (see {DSL::Foo})
52
+ # @param resource [Foo] an authorized Foo
53
+ #
54
+ # @see Foo
55
+ #
56
+ def can?(action, resource)
57
+ resource.allows?(action, self)
58
+ end
59
+
60
+ ##
61
+ # Opposite of {#can?}.
62
+ #
63
+ # @param (see #can?)
64
+ # @return (see #can?)
65
+ #
66
+ def cannot?(*args)
67
+ !can?(*args)
68
+ end
47
69
  end
48
70
 
49
71
  module Overloading
@@ -0,0 +1,72 @@
1
+ # One entry of a cross-reference section or stream.
2
+ #
3
+ # An entry has the attributes +type+, +oid+, +gen+, +pos+ and +objstm+ and can be created like
4
+ # this:
5
+ #
6
+ # Entry.new(type, oid, gen, pos, objstm) -> entry
7
+ #
8
+ # The +type+ attribute can be:
9
+ #
10
+ # :free:: Denotes a free entry.
11
+ #
12
+ # :in_use:: A used entry that resides in the body of the PDF file. The +pos+ attribute defines
13
+ # the position in the file at which the object can be found.
14
+ #
15
+ # :compressed:: A used entry that resides in an object stream. The +objstm+ attribute contains
16
+ # the reference to the object stream in which the object can be found and the
17
+ # +pos+ attribute contains the index into the object stream.
18
+ #
19
+ # Objects in an object stream always have a generation number of 0!
20
+ #
21
+ # See: PDF1.7 s7.5.4, s7.5.8
22
+ StructWithRDoc = Struct.new(:type, :oid, :gen, :pos, :objstm, :member_without_doc)
23
+
24
+ # One entry of a cross-reference section or stream.
25
+ #
26
+ # An entry has the attributes +type+, +oid+, +gen+, +pos+ and +objstm+ and can be created like
27
+ # this:
28
+ #
29
+ # Entry.new(type, oid, gen, pos, objstm) -> entry
30
+ #
31
+ # The +type+ attribute can be:
32
+ #
33
+ # :free:: Denotes a free entry.
34
+ #
35
+ # :in_use:: A used entry that resides in the body of the PDF file. The +pos+ attribute defines
36
+ # the position in the file at which the object can be found.
37
+ #
38
+ # :compressed:: A used entry that resides in an object stream. The +objstm+ attribute contains
39
+ # the reference to the object stream in which the object can be found and the
40
+ # +pos+ attribute contains the index into the object stream.
41
+ #
42
+ # Objects in an object stream always have a generation number of 0!
43
+ #
44
+ # See: PDF1.7 s7.5.4, s7.5.8
45
+ class StructWithRDocAsInheritedClass < Struct.new(:type, :oid, :gen, :pos, :objstm, :member_without_doc)
46
+ end
47
+
48
+ # Representation of attributes of a user in the database
49
+ #
50
+ # @!attribute email
51
+ # @return [String] E-mail address (from Devise)
52
+ # @!attribute username
53
+ # @return [String] Username (from Devise)
54
+ StructWithYardDirectivesOutside = Struct.new(:email, :username, :member_without_doc)
55
+
56
+ # Representation of attributes of a user in the database
57
+ #
58
+ class StructWithYardDirectivesAsInheritedClass < Struct.new(:email, :username, :member_without_doc)
59
+ # @!attribute email
60
+ # @return [String] E-mail address (from Devise)
61
+ # @!attribute username
62
+ # @return [String] Username (from Devise)
63
+ end
64
+
65
+ # Representation of attributes of a user in the database
66
+ #
67
+ # @!attribute email
68
+ # @return [String] E-mail address (from Devise)
69
+ # @!attribute username
70
+ # @return [String] Username (from Devise)
71
+ class StructWithYardDirectivesOutsideAsInheritedClass < Struct.new(:email, :username, :member_without_doc)
72
+ end
@@ -501,4 +501,19 @@ describe ::Inch::Language::Ruby::CodeObject::MethodObject do
501
501
  assert_equal 100, m.score
502
502
  end
503
503
  end
504
+
505
+ describe 'YARDs reference tag on methods' do
506
+ #
507
+ it 'should recognize referenced docs' do
508
+ m1 = @objects.find('Foo#can?')
509
+ assert m1.has_doc?
510
+ refute m1.undocumented?
511
+ assert_equal 100, m1.score
512
+
513
+ m2 = @objects.find('Foo#cannot?')
514
+ assert m2.has_doc?
515
+ refute m2.undocumented?
516
+ assert_equal 100, m2.score
517
+ end
518
+ end
504
519
  end
@@ -0,0 +1,38 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../../../test_helper')
2
+
3
+ describe ::Inch::Language::Ruby::CodeObject::ClassObject do
4
+ before do
5
+ @codebase = test_codebase(:ruby, :structs)
6
+ @objects = @codebase.objects
7
+ end
8
+
9
+ describe 'Structs with RDoc comment mentioning members' do
10
+ #
11
+ it 'should recognize that the members are documented in the class docstring' do
12
+ %w(StructWithRDoc StructWithRDocAsInheritedClass).each do |class_name|
13
+ %w(type oid gen pos objstm).each do |member_name|
14
+ m = @objects.find("#{class_name}##{member_name}")
15
+ refute_equal 0, m.score, "#{class_name}##{member_name} should have score > 0"
16
+ refute m.undocumented?, "#{class_name}##{member_name} should not be undocumented"
17
+ end
18
+ m = @objects.find("#{class_name}#member_without_doc")
19
+ assert_equal 0, m.score, "#{class_name}#member_without_doc should have score == 0"
20
+ assert m.undocumented?, "#{class_name}#member_without_doc should be undocumented"
21
+ end
22
+ end
23
+ end
24
+
25
+ describe 'Structs with YARD directives' do
26
+ #
27
+ it 'should recognize that the members are documented via directives' do
28
+ %w(email username).each do |member_name|
29
+ m = @objects.find("StructWithYardDirectivesAsInheritedClass##{member_name}")
30
+ refute_equal 0, m.score, "StructWithYardDirectivesAsInheritedClass##{member_name} should have score > 0"
31
+ refute m.undocumented?, "StructWithYardDirectivesAsInheritedClass##{member_name} should not be undocumented"
32
+ end
33
+ m = @objects.find("StructWithYardDirectivesAsInheritedClass#member_without_doc")
34
+ assert_equal 0, m.score, "StructWithYardDirectivesAsInheritedClass#member_without_doc should have score == 0"
35
+ assert m.undocumented?, "StructWithYardDirectivesAsInheritedClass#member_without_doc should be undocumented"
36
+ end
37
+ end
38
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0.rc5
4
+ version: 0.6.0.rc6
5
5
  platform: ruby
6
6
  authors:
7
7
  - René Föhring
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-02 00:00:00.000000000 Z
11
+ date: 2015-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -331,6 +331,7 @@ files:
331
331
  - test/fixtures/ruby/simple/lib/nodoc.rb
332
332
  - test/fixtures/ruby/simple/lib/role_methods.rb
333
333
  - test/fixtures/ruby/simple/lib/role_namespaces.rb
334
+ - test/fixtures/ruby/structs/lib/structs_member.rb
334
335
  - test/fixtures/ruby/visibility/lib/foo.rb
335
336
  - test/fixtures/ruby/yardopts/.yardopts
336
337
  - test/fixtures/ruby/yardopts/foo/bar.rb
@@ -374,6 +375,7 @@ files:
374
375
  - test/unit/language/javascript/provider/jsdoc/docstring_test.rb
375
376
  - test/unit/language/ruby/code_object/alias_test.rb
376
377
  - test/unit/language/ruby/code_object/method_object_test.rb
378
+ - test/unit/language/ruby/code_object/structs_member_test.rb
377
379
  - test/unit/language/ruby/provider/yard/docstring_test.rb
378
380
  - test/unit/language/ruby/provider/yard/nodoc_helper_test.rb
379
381
  - test/unit/language/ruby/provider/yard/object/method_object_test.rb
@@ -427,6 +429,7 @@ test_files:
427
429
  - test/fixtures/ruby/simple/lib/nodoc.rb
428
430
  - test/fixtures/ruby/simple/lib/role_methods.rb
429
431
  - test/fixtures/ruby/simple/lib/role_namespaces.rb
432
+ - test/fixtures/ruby/structs/lib/structs_member.rb
430
433
  - test/fixtures/ruby/visibility/lib/foo.rb
431
434
  - test/fixtures/ruby/yardopts/.yardopts
432
435
  - test/fixtures/ruby/yardopts/foo/bar.rb
@@ -470,6 +473,7 @@ test_files:
470
473
  - test/unit/language/javascript/provider/jsdoc/docstring_test.rb
471
474
  - test/unit/language/ruby/code_object/alias_test.rb
472
475
  - test/unit/language/ruby/code_object/method_object_test.rb
476
+ - test/unit/language/ruby/code_object/structs_member_test.rb
473
477
  - test/unit/language/ruby/provider/yard/docstring_test.rb
474
478
  - test/unit/language/ruby/provider/yard/nodoc_helper_test.rb
475
479
  - test/unit/language/ruby/provider/yard/object/method_object_test.rb