inch 0.5.0.rc1 → 0.5.0.rc2

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: 9b627b3f3280cb1d20ff03e3a90decafe62cae3e
4
- data.tar.gz: 5489c5a9d46a46e20d924aef08063bd4a2663998
3
+ metadata.gz: 2cbc0d4c804e51d845b747f3e98dbb627e4cc03d
4
+ data.tar.gz: 19b9076a8005cafc3e80c8f73fb906710c9277e9
5
5
  SHA512:
6
- metadata.gz: 748f0227ada481c78e398ba26e9c30397293acdefa22244c4b2482accaac8893f0eb10076ce4eb1c2484c91cc8253acd7619b5071e2e9c8189eb1b8676905603
7
- data.tar.gz: 4e82d4927c776c8c825187821af1d6e4d5abfdbd56d7c5c4f73dbe093d50d85b901d24fc8934bae81dc1c6fd22b7ceac8bc39aa0c52569bc7cb9c32be3a2bfa8
6
+ metadata.gz: 74beefa52167ddb75d108ecc78c0cf3401cae9534796778fcfa12564a1f47dc86e87a5951a241134df1d8a00dd32b6be49667e55f341be8613a7028a8b221a31
7
+ data.tar.gz: 71546c69d7edf6e0ed626c448bba5ab263d98d7e5358f3cdd8ccafa40d1acdfc9da136e46f8d06443a74cc7d018650f3012df5b1b9a5f917960ef3f294f7d8ac
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Inch [![Build Status](https://travis-ci.org/rrrene/inch.png)](https://travis-ci.org/rrrene/inch) [![Code Climate](https://codeclimate.com/github/rrrene/inch.png)](https://codeclimate.com/github/rrrene/inch) [![Inline docs](http://inch-pages.github.io/github/rrrene/inch.png)](http://inch-pages.github.io/github/rrrene/inch)
1
+ # Inch [![Build Status](https://travis-ci.org/rrrene/inch.png)](https://travis-ci.org/rrrene/inch) [![Code Climate](https://codeclimate.com/github/rrrene/inch.png)](https://codeclimate.com/github/rrrene/inch) [![Inline docs](http://inch-ci.org/github/rrrene/inch.png)](http://inch-ci.org/github/rrrene/inch)
2
2
 
3
3
  `inch` gives you hints where to improve your docs. One Inch at a time.
4
4
 
@@ -102,24 +102,49 @@ module Inch
102
102
 
103
103
  private
104
104
 
105
- # Returns +true+ if the docstring was generated by YARD
105
+ # Returns @return tags that are assigned to the getter
106
+ # corresponding to this setter.
107
+ #
108
+ # @return [Array<::YARD::Tag>]
109
+ def attributed_return_tags
110
+ if setter? && object.tags(:return).empty?
111
+ method = corresponding_getter
112
+ if method
113
+ return method.object.tags(:return)
114
+ end
115
+ end
116
+ []
117
+ end
118
+
119
+ # @return [MethodObject,nil]
120
+ def corresponding_getter
121
+ clean_name = name.to_s.gsub(/(\=)$/, '')
122
+ parent.child(clean_name.to_sym)
123
+ end
124
+
125
+ # Returns +true+ if the docstring was generated by YARD.
106
126
  def implicit_docstring?
107
127
  YARD.implicit_docstring?(docstring, self)
108
128
  end
109
129
 
130
+ # @return [Array<::YARD::Tag>]
110
131
  def overload_tags
111
132
  object.tags(:overload)
112
133
  end
113
134
 
114
- def return_tags
115
- object.tags(:return) + overloaded_return_tags
116
- end
117
-
135
+ # @return [Array<::YARD::Tag>]
118
136
  def overloaded_return_tags
119
137
  overload_tags.map do |overload_tag|
120
138
  overload_tag.tag(:return)
121
139
  end.compact
122
140
  end
141
+
142
+ # @return [Array<::YARD::Tag>]
143
+ def return_tags
144
+ object.tags(:return) +
145
+ overloaded_return_tags +
146
+ attributed_return_tags
147
+ end
123
148
  end
124
149
  end
125
150
  end
@@ -8,7 +8,7 @@ module Inch
8
8
  attr_reader :method, :docstring
9
9
 
10
10
  # @param method [Provider::YARD::Object::MethodObject]
11
- # @param method [::YARD::Tags::Tag,nil] if nil, the method's normal signature is used
11
+ # @param yard_tag [::YARD::Tags::Tag,nil] if nil, the method's normal signature is used
12
12
  def initialize(method, yard_tag = nil)
13
13
  @method = method
14
14
  @yard_tag = yard_tag
@@ -1,3 +1,3 @@
1
1
  module Inch
2
- VERSION = "0.5.0.rc1"
2
+ VERSION = "0.5.0.rc2"
3
3
  end
@@ -34,9 +34,42 @@ module Foo
34
34
  # @return HasH
35
35
  def method_with_wrong_return_tag
36
36
  end
37
+
38
+ # Redirect to the given URL
39
+ # @param url [String] the destination URL
40
+ # @param status [Fixnum] the http code
41
+ def method_with_named_parameter(url, status: 302)
42
+ end
43
+ end
44
+
45
+ # Representation of attributes of a user in the database
46
+ #
47
+ # @!attribute email
48
+ # @return [String] E-mail address (from Devise)
49
+ class Attributes
50
+ # @return [String] Username (from Devise)
51
+ attr_accessor :username
37
52
  end
38
53
 
39
54
  module Overloading
55
+ # @overload many_overloads(&block)
56
+ # @overload many_overloads(scope, &block)
57
+ # @param scope [Symbol] `:example`, `:context`, or `:suite` (defaults to `:example`)
58
+ # @overload many_overloads(scope, conditions, &block)
59
+ # @param scope [Symbol] `:example`, `:context`, or `:suite` (defaults to `:example`)
60
+ # @param conditions [Hash]
61
+ # constrains this hook to examples matching these conditions e.g.
62
+ # `many_overloads(:example, :ui => true) { ... }` will only run with examples or
63
+ # groups declared with `:ui => true`.
64
+ # @overload many_overloads(conditions, &block)
65
+ # @param conditions [Hash]
66
+ # constrains this hook to examples matching these conditions e.g.
67
+ # `many_overloads(:example, :ui => true) { ... }` will only run with examples or
68
+ # groups declared with `:ui => true`.
69
+ def many_overloads(*args, &block)
70
+ hooks.register :append, :before, *args, &block
71
+ end
72
+
40
73
  # Creates a {Sass::Script::Value::Color Color} object from red, green, and
41
74
  # blue values.
42
75
  #
@@ -18,6 +18,16 @@ def assert_roles(object, expected, unexpected)
18
18
  end
19
19
  end
20
20
 
21
+ def count_roles(object, role_class, object_name = nil)
22
+ find_roles(object, role_class, object_name).size
23
+ end
24
+
25
+ def find_roles(object, role_class, object_name = nil)
26
+ object.roles.select do |r|
27
+ r.class == role_class && (object_name.nil? || r.object.name == object_name)
28
+ end
29
+ end
30
+
21
31
  def fixture_path(name)
22
32
  File.join(File.dirname(__FILE__), "fixtures", name.to_s)
23
33
  end
@@ -329,6 +329,37 @@ describe ::Inch::CodeObject::Proxy::MethodObject do
329
329
  refute m.has_doc? # it may be mentioned in the docs, but it's malformed.
330
330
  end
331
331
 
332
+ def test_attribute_directive_on_reader
333
+ m = @objects.find("Attributes#email")
334
+ refute_equal 0, m.score
335
+ refute m.undocumented?
336
+ end
337
+
338
+ def test_attribute_directive_on_writer
339
+ m = @objects.find("Attributes#email=")
340
+ refute_equal 0, m.score
341
+ refute m.undocumented?
342
+ end
343
+
344
+ def test_attr_accessor_on_reader
345
+ m = @objects.find("Attributes#username")
346
+ refute_equal 0, m.score
347
+ refute m.undocumented?
348
+ end
349
+
350
+ def test_attr_accessor_on_writer
351
+ m = @objects.find("Attributes#username=")
352
+ refute_equal 0, m.score
353
+ refute m.undocumented?
354
+ end
355
+
356
+ def test_overloading_with_many_overloads
357
+ m = @objects.find("Overloading#many_overloads")
358
+ assert_equal 1, count_roles(m, Inch::Evaluation::Role::Method::WithoutReturnDescription)
359
+ assert_equal 1, count_roles(m, Inch::Evaluation::Role::Method::WithoutReturnType)
360
+ assert_equal 1, count_roles(m, Inch::Evaluation::Role::MethodParameter::WithoutMention, 'block')
361
+ end
362
+
332
363
  def test_overloading_with_bad_doc
333
364
  m = @objects.find("Overloading#params_only_in_overloads")
334
365
  unexpected_roles = [
@@ -350,4 +381,13 @@ describe ::Inch::CodeObject::Proxy::MethodObject do
350
381
  ]
351
382
  assert_roles m, expected_roles, unexpected_roles
352
383
  end
384
+
385
+ def test_documenting_named_parameters
386
+ m = @objects.find("Foo#method_with_named_parameter")
387
+ unexpected_roles = [
388
+ Inch::Evaluation::Role::MethodParameter::WithoutMention,
389
+ Inch::Evaluation::Role::MethodParameter::WithoutType,
390
+ ]
391
+ assert_roles m, [], unexpected_roles
392
+ end
353
393
  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.5.0.rc1
4
+ version: 0.5.0.rc2
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: 2014-06-02 00:00:00.000000000 Z
11
+ date: 2014-06-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler