yard 0.9.23 → 0.9.24
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.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +30 -0
- data/CHANGELOG.md +8 -0
- data/Gemfile +2 -2
- data/lib/yard/code_objects/namespace_mapper.rb +30 -3
- data/lib/yard/parser/ruby/token_resolver.rb +3 -1
- data/lib/yard/registry_resolver.rb +10 -24
- data/lib/yard/serializers/yardoc_serializer.rb +1 -1
- data/lib/yard/version.rb +1 -1
- data/spec/code_objects/namespace_mapper_spec.rb +32 -0
- data/spec/parser/ruby/ruby_parser_spec.rb +12 -0
- data/spec/registry_resolver_spec.rb +15 -0
- data/spec/serializers/yardoc_serializer_spec.rb +12 -0
- data/spec/templates/helpers/html_helper_spec.rb +0 -21
- data/spec/templates/markup_processor_integrations/integration_spec_helper.rb +4 -0
- data/spec/templates/markup_processor_integrations/rdoc_markdown_spec.rb +0 -11
- data/spec/templates/markup_processor_integrations/redcarpet_spec.rb +6 -1
- data/spec/templates/markup_processor_integrations/redcloth_spec.rb +16 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 53bb10d04117e8e6b53dc07a0b93520b0a08b713a77588254c85dfeec52ace67
|
4
|
+
data.tar.gz: 4945cd96795da8c07ef2eb571536ba0ad5f6a9a0f185717c6ba20943e5cc3153
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 50ee44093b616fddc463b77168111c4c5047995a83582968792c9bab6ec4ace104ccd074397e4925c7fbe5e2c2c273413c9163a00ad016a3c4a895d433b0b1d4
|
7
|
+
data.tar.gz: 824c71f1724f55ccc7f4a0e98e69df583d0f553ae908ec75fe1d080b596e1bed028c12d6d422f3a9841a5b50e07394cd2059c4412a91c48efb23840977346f44
|
@@ -0,0 +1,30 @@
|
|
1
|
+
name: Unit Tests
|
2
|
+
|
3
|
+
on: [push, pull_request]
|
4
|
+
jobs:
|
5
|
+
build:
|
6
|
+
name: "Ruby: ${{ matrix.ruby }} OS: ${{ matrix.os }}"
|
7
|
+
runs-on: ${{ matrix.os }}
|
8
|
+
strategy:
|
9
|
+
fail-fast: false
|
10
|
+
matrix:
|
11
|
+
os: [macos-latest, windows-latest, ubuntu-latest]
|
12
|
+
ruby: ["2.4", "2.5", "2.6", "2.7"]
|
13
|
+
steps:
|
14
|
+
- name: Checkout
|
15
|
+
uses: actions/checkout@v2
|
16
|
+
- name: Select Ruby Version
|
17
|
+
uses: eregon/use-ruby-action@master
|
18
|
+
with:
|
19
|
+
ruby-version: ${{ matrix.ruby }}
|
20
|
+
base: update
|
21
|
+
- name: Update RubyGems & Bundler
|
22
|
+
run: gem update --system --no-document --conservative
|
23
|
+
- name: Install Dependencies
|
24
|
+
run: bundle install --jobs=3 --retry=3
|
25
|
+
- name: Run Test
|
26
|
+
run: |
|
27
|
+
ruby -v
|
28
|
+
bundle exec rake
|
29
|
+
env:
|
30
|
+
CI: true
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# master
|
2
2
|
|
3
|
+
# 0.9.24 - January 8th, 2020
|
4
|
+
|
5
|
+
[0.9.24]: https://github.com/lsegal/yard/compare/v0.9.23...v0.9.24
|
6
|
+
|
7
|
+
- Add {YARD::CodeObjects::NamespaceMapper.on_invalidate} callback when separator
|
8
|
+
cache is changed.
|
9
|
+
- Fix issue where Registry fails to resolve first-time lookups on instance methods.
|
10
|
+
|
3
11
|
# 0.9.23 - January 5th, 2020
|
4
12
|
|
5
13
|
[0.9.23]: https://github.com/lsegal/yard/compare/v0.9.22...v0.9.23
|
data/Gemfile
CHANGED
@@ -11,6 +11,9 @@ module YARD
|
|
11
11
|
# Registers a separator with an optional set of valid types that
|
12
12
|
# must follow the separator lexically.
|
13
13
|
#
|
14
|
+
# Calls all callbacks defined by {NamespaceMapper.on_invalidate} after
|
15
|
+
# the separator is registered.
|
16
|
+
#
|
14
17
|
# @param sep [String] the separator string for the namespace
|
15
18
|
# @param valid_types [Array<Symbol>] a list of object types that
|
16
19
|
# must follow the separator. If the list is empty, any type can
|
@@ -20,6 +23,7 @@ module YARD
|
|
20
23
|
# register_separator "#", :method
|
21
24
|
# # Anything after a "." denotes a method object
|
22
25
|
# register_separator ".", :method
|
26
|
+
# @see .on_invalidate
|
23
27
|
def register_separator(sep, *valid_types)
|
24
28
|
NamespaceMapper.invalidate
|
25
29
|
|
@@ -32,6 +36,19 @@ module YARD
|
|
32
36
|
NamespaceMapper.map[sep] += valid_types
|
33
37
|
end
|
34
38
|
|
39
|
+
# Unregisters a separator by a type.
|
40
|
+
#
|
41
|
+
# @param type [Symbol] the type to unregister
|
42
|
+
# @see #register_separator
|
43
|
+
def unregister_separator_by_type(type)
|
44
|
+
seps = NamespaceMapper.rev_map[type]
|
45
|
+
return unless seps
|
46
|
+
|
47
|
+
seps.each {|s| NamespaceMapper.map.delete(s) }
|
48
|
+
NamespaceMapper.rev_map.delete(type)
|
49
|
+
NamespaceMapper.invalidate
|
50
|
+
end
|
51
|
+
|
35
52
|
# Clears the map of separators.
|
36
53
|
#
|
37
54
|
# @return [void]
|
@@ -50,6 +67,7 @@ module YARD
|
|
50
67
|
# default_separator "::"
|
51
68
|
def default_separator(value = nil)
|
52
69
|
if value
|
70
|
+
NamespaceMapper.invalidate
|
53
71
|
NamespaceMapper.default_separator = Regexp.quote value
|
54
72
|
else
|
55
73
|
NamespaceMapper.default_separator
|
@@ -71,17 +89,25 @@ module YARD
|
|
71
89
|
# @param sep [String] the separator to return types for
|
72
90
|
# @return [Array<Symbol>] a list of types registered to a separator
|
73
91
|
def types_for_separator(sep)
|
74
|
-
NamespaceMapper.map[sep]
|
92
|
+
NamespaceMapper.map[sep] || []
|
75
93
|
end
|
76
94
|
|
77
95
|
# @param type [String] the type to return separators for
|
78
96
|
# @return [Array<Symbol>] a list of separators registered to a type
|
79
97
|
def separators_for_type(type)
|
80
|
-
NamespaceMapper.rev_map[type]
|
98
|
+
NamespaceMapper.rev_map[type] || []
|
81
99
|
end
|
82
100
|
|
83
101
|
# Internal methods to act as a singleton registry
|
84
102
|
class << self
|
103
|
+
# @!group Invalidation callbacks
|
104
|
+
|
105
|
+
# Adds a callback that triggers when a new separator is registered or
|
106
|
+
# the cache is cleared by invalidation.
|
107
|
+
def on_invalidate(&block)
|
108
|
+
(@invalidation_callbacks ||= []).push(block)
|
109
|
+
end
|
110
|
+
|
85
111
|
# @!visibility private
|
86
112
|
|
87
113
|
# @return [Hash] a mapping of types to separators
|
@@ -98,11 +124,12 @@ module YARD
|
|
98
124
|
# @return [void]
|
99
125
|
def invalidate
|
100
126
|
@map_match = nil
|
127
|
+
(@invalidation_callbacks || []).each(&:call)
|
101
128
|
end
|
102
129
|
|
103
130
|
# @return [Regexp] the full list of separators as a regexp match
|
104
131
|
def map_match
|
105
|
-
@map_match ||=
|
132
|
+
@map_match ||= map.keys.map {|k| Regexp.quote k }.join('|')
|
106
133
|
end
|
107
134
|
|
108
135
|
# @return [String] the default separator when no separator can begin
|
@@ -7,6 +7,7 @@ module YARD
|
|
7
7
|
# constant or identifier token.
|
8
8
|
class TokenResolver
|
9
9
|
include Enumerable
|
10
|
+
include CodeObjects::NamespaceMapper
|
10
11
|
|
11
12
|
# Creates a token resolver for given source.
|
12
13
|
#
|
@@ -114,7 +115,8 @@ module YARD
|
|
114
115
|
|
115
116
|
if toktype == :const
|
116
117
|
types.any? do |type|
|
117
|
-
prefix =
|
118
|
+
prefix = type ? type.path : ""
|
119
|
+
prefix += last_sep.to_s if separators.include?(last_sep.to_s)
|
118
120
|
self.object = Registry.resolve(@default_namespace, "#{prefix}#{name}", true)
|
119
121
|
end
|
120
122
|
else # ident
|
@@ -16,6 +16,9 @@ module YARD
|
|
16
16
|
def initialize(registry = Registry)
|
17
17
|
@registry = registry
|
18
18
|
@default_sep = nil
|
19
|
+
|
20
|
+
# Preload all code objects for separator declarations
|
21
|
+
YARD::CodeObjects.constants.map {|t| YARD::CodeObjects.const_get(t) }
|
19
22
|
end
|
20
23
|
|
21
24
|
# Performs a lookup on a given path in the registry. Resolution will occur
|
@@ -186,46 +189,29 @@ module YARD
|
|
186
189
|
nss
|
187
190
|
end
|
188
191
|
|
189
|
-
# @see NamespaceMapper#register_separator
|
190
|
-
def register_separator(*)
|
191
|
-
super
|
192
|
-
invalidate_memoized_matchers
|
193
|
-
end
|
194
|
-
|
195
|
-
# @see NamespaceMapper#clear_separators
|
196
|
-
def clear_separators
|
197
|
-
super
|
198
|
-
invalidate_memoized_matchers
|
199
|
-
end
|
200
|
-
|
201
|
-
# @see NamespaceMapper#default_separator
|
202
|
-
def default_separator(value = nil)
|
203
|
-
@starts_with_default_separator_match = nil if value
|
204
|
-
super
|
205
|
-
end
|
206
|
-
|
207
192
|
# @return [Regexp] the regexp match of the default separator
|
208
193
|
def starts_with_default_separator_match
|
209
|
-
|
194
|
+
@@starts_with_default_separator_match ||= /\A#{default_separator}/
|
210
195
|
end
|
211
196
|
|
212
197
|
# @return [Regexp] the regexp that matches strings starting with
|
213
198
|
# a separator
|
214
199
|
def starts_with_separator_match
|
215
|
-
|
200
|
+
@@starts_with_separator_match ||= /\A(#{separators_match})/
|
216
201
|
end
|
217
202
|
|
218
203
|
# @return [Regexp] the regexp that can be used to split a string on all
|
219
204
|
# occurrences of separator tokens
|
220
205
|
def split_on_separators_match
|
221
|
-
|
206
|
+
@@split_on_separators_match ||= /(.+?)(#{separators_match}|$)/
|
222
207
|
end
|
223
208
|
|
224
209
|
# Additional invalidations to done when NamespaceMapper API methods are
|
225
210
|
# called on this class
|
226
|
-
|
227
|
-
|
228
|
-
|
211
|
+
YARD::CodeObjects::NamespaceMapper.on_invalidate do
|
212
|
+
@@starts_with_default_separator_match = nil
|
213
|
+
@@starts_with_separator_match = nil
|
214
|
+
@@split_on_separators_match = nil
|
229
215
|
end
|
230
216
|
end
|
231
217
|
end
|
data/lib/yard/version.rb
CHANGED
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
3
|
+
|
4
|
+
RSpec.describe YARD::CodeObjects::NamespaceMapper do
|
5
|
+
include YARD::CodeObjects::NamespaceMapper
|
6
|
+
|
7
|
+
describe '#register_separator' do
|
8
|
+
it 'should allow separators to be registered' do
|
9
|
+
register_separator '!', :test_type
|
10
|
+
|
11
|
+
expect(separators_for_type(:test_type)).to eq ['!']
|
12
|
+
expect(types_for_separator('!')).to eq [:test_type]
|
13
|
+
|
14
|
+
unregister_separator_by_type :test_type
|
15
|
+
|
16
|
+
expect(separators_for_type(:test_type)).to be_empty
|
17
|
+
expect(types_for_separator('!')).to be_empty
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '.on_invalidate' do
|
22
|
+
it 'receives a callback when a new separator is added' do
|
23
|
+
invalidated = false
|
24
|
+
NamespaceMapper.on_invalidate { invalidated = true }
|
25
|
+
|
26
|
+
register_separator '!', :test_type
|
27
|
+
expect(invalidated).to be true
|
28
|
+
|
29
|
+
unregister_separator_by_type :test_type
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -504,5 +504,17 @@ eof
|
|
504
504
|
it "handles compile errors" do
|
505
505
|
expect { stmt(":~$ Do not clobber") }.to raise_error(Parser::ParserSyntaxError)
|
506
506
|
end
|
507
|
+
|
508
|
+
it "handles cls/mod comments without line spacing" do
|
509
|
+
ast = stmt <<-eof
|
510
|
+
module A
|
511
|
+
# comment 1
|
512
|
+
# comment 2
|
513
|
+
class B
|
514
|
+
end
|
515
|
+
end
|
516
|
+
eof
|
517
|
+
expect(ast.jump(:class).docstring).to eq "comment 1\ncomment 2"
|
518
|
+
end
|
507
519
|
end
|
508
520
|
end if HAVE_RIPPER
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
RSpec.describe YARD::RegistryResolver do
|
4
|
+
include YARD::CodeObjects::NamespaceMapper
|
5
|
+
|
6
|
+
describe '#starts_with_separator_match' do
|
7
|
+
subject { RegistryResolver.new }
|
8
|
+
|
9
|
+
it 'should clear cache when a namespace separator is registered' do
|
10
|
+
expect(subject.send(:starts_with_separator_match).to_s).not_to include('!')
|
11
|
+
register_separator '!', :test_type
|
12
|
+
expect(subject.send(:starts_with_separator_match).to_s).to include('!')
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -45,6 +45,18 @@ RSpec.describe YARD::Serializers::YardocSerializer do
|
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
+
describe "#serialized_path" do
|
49
|
+
it "handles String path name" do
|
50
|
+
path = @serializer.serialized_path('Path::To#object')
|
51
|
+
expect(path).to eq('objects/Path/To/object_i.dat')
|
52
|
+
end
|
53
|
+
|
54
|
+
it "handles special encoding characters" do
|
55
|
+
path = @serializer.serialized_path('object$')
|
56
|
+
expect(path).to eq('objects/object_24.dat')
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
48
60
|
describe "#lock_for_writing" do
|
49
61
|
it "creates a lock file during writing and cleans up" do
|
50
62
|
expect(File).to receive(:open!).with(@serializer.processing_path, 'w')
|
@@ -106,16 +106,6 @@ RSpec.describe YARD::Templates::Helpers::HtmlHelper do
|
|
106
106
|
end
|
107
107
|
|
108
108
|
describe "#htmlify" do
|
109
|
-
it "does not use hard breaks for textile markup (RedCloth specific)" do
|
110
|
-
begin; require 'redcloth'; rescue LoadError; pending 'test requires redcloth gem' end
|
111
|
-
expect(htmlify("A\nB", :textile)).not_to include("<br")
|
112
|
-
end
|
113
|
-
|
114
|
-
it "uses hard breaks for textile_strict markup (RedCloth specific)" do
|
115
|
-
begin; require 'redcloth'; rescue LoadError; pending 'test requires redcloth gem' end
|
116
|
-
expect(htmlify("A\nB", :textile_strict)).to include("<br")
|
117
|
-
end
|
118
|
-
|
119
109
|
it "handles various encodings" do
|
120
110
|
allow(self).to receive(:object).and_return(Registry.root)
|
121
111
|
text = String.new("\xB0\xB1")
|
@@ -159,17 +149,6 @@ RSpec.describe YARD::Templates::Helpers::HtmlHelper do
|
|
159
149
|
expect(htmlify("test {include:file:foo.rdoc}", :rdoc).gsub(/[\r?\n]+/, '')).to eq '<p>test HI</p>'
|
160
150
|
end
|
161
151
|
|
162
|
-
it "autolinks URLs (markdown specific)" do
|
163
|
-
log.enter_level(Logger::FATAL) do
|
164
|
-
unless markup_class(:markdown).to_s == "RedcarpetCompat"
|
165
|
-
pending 'This test depends on a markdown engine that supports autolinking'
|
166
|
-
end
|
167
|
-
end
|
168
|
-
expect(htmlify('http://example.com', :markdown).chomp.gsub('/', '/')).to eq(
|
169
|
-
'<p><a href="http://example.com">http://example.com</a></p>'
|
170
|
-
)
|
171
|
-
end
|
172
|
-
|
173
152
|
it "does not autolink URLs inside of {} (markdown specific)" do
|
174
153
|
log.enter_level(Logger::FATAL) do
|
175
154
|
pending 'This test depends on markdown' unless markup_class(:markdown)
|
@@ -1,6 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
RSpec.shared_context 'shared helpers for markup processor integration specs' do
|
4
|
+
after do
|
5
|
+
YARD::Templates::Helpers::MarkupHelper.clear_markup_cache
|
6
|
+
end
|
7
|
+
|
4
8
|
let(:rendered_document) { html_renderer.htmlify document }
|
5
9
|
|
6
10
|
let(:template_options) do
|
@@ -27,12 +27,6 @@ Fenced and annotated block of Ruby code:
|
|
27
27
|
x = 3
|
28
28
|
```
|
29
29
|
|
30
|
-
Fenced and annotated block of non-Ruby code:
|
31
|
-
|
32
|
-
```plain
|
33
|
-
x = 4
|
34
|
-
```
|
35
|
-
|
36
30
|
MARKDOWN
|
37
31
|
end
|
38
32
|
|
@@ -51,9 +45,4 @@ MARKDOWN
|
|
51
45
|
it 'renders fenced and annotated block of Ruby code, and applies syntax highlight' do
|
52
46
|
expect(rendered_document).to match(highlighted_ruby_regexp('x', '=', '3'))
|
53
47
|
end
|
54
|
-
|
55
|
-
it 'renders fenced and annotated block of non-Ruby code, and does not apply syntax highlight' do
|
56
|
-
pending 'This is actually highlighted, but it is not a big deal'
|
57
|
-
expect(rendered_document).to match('x = 4')
|
58
|
-
end
|
59
48
|
end
|
@@ -53,7 +53,12 @@ MARKDOWN
|
|
53
53
|
end
|
54
54
|
|
55
55
|
it 'renders fenced and annotated block of non-Ruby code, and does not apply syntax highlight' do
|
56
|
-
pending 'This is actually highlighted, but it is not a big deal'
|
57
56
|
expect(rendered_document).to match('x = 4')
|
58
57
|
end
|
58
|
+
|
59
|
+
it "autolinks URLs" do
|
60
|
+
expect(html_renderer.htmlify('http://example.com', :markdown).chomp.gsub('/', '/')).to eq(
|
61
|
+
'<p><a href="http://example.com">http://example.com</a></p>'
|
62
|
+
)
|
63
|
+
end
|
59
64
|
end
|
@@ -2,6 +2,14 @@
|
|
2
2
|
|
3
3
|
require File.dirname(__FILE__) + '/integration_spec_helper'
|
4
4
|
|
5
|
+
# Hack to fix RedCloth compat issues with MinGW compilation hosts
|
6
|
+
begin
|
7
|
+
require 'redcloth'
|
8
|
+
rescue LoadError
|
9
|
+
require 'rbconfig'
|
10
|
+
RbConfig::CONFIG['arch'] = 'not_windows_dont_worry'
|
11
|
+
end
|
12
|
+
|
5
13
|
RSpec.describe 'RedCloth integration' do
|
6
14
|
include_context 'shared helpers for markup processor integration specs'
|
7
15
|
let(:markup) { :textile }
|
@@ -45,4 +53,12 @@ TEXTILE
|
|
45
53
|
it 'renders pre. block, and applies Ruby syntax highlight' do
|
46
54
|
expect(rendered_document).to match(highlighted_ruby_regexp('x', '=', '2'))
|
47
55
|
end
|
56
|
+
|
57
|
+
it "does not use hard breaks for newlines" do
|
58
|
+
expect(html_renderer.htmlify("A\nB", :textile)).not_to include("<br")
|
59
|
+
end
|
60
|
+
|
61
|
+
it "uses hard breaks for newlines with textile_strict" do
|
62
|
+
expect(html_renderer.htmlify("A\nB", :textile_strict)).to include("<br")
|
63
|
+
end
|
48
64
|
end
|
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.9.
|
4
|
+
version: 0.9.24
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Loren Segal
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-01-
|
11
|
+
date: 2020-01-08 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.
|
@@ -26,6 +26,7 @@ files:
|
|
26
26
|
- ".dockerignore"
|
27
27
|
- ".github/ISSUE_TEMPLATE.md"
|
28
28
|
- ".github/PULL_REQUEST_TEMPLATE.md"
|
29
|
+
- ".github/workflows/ci.yml"
|
29
30
|
- ".gitignore"
|
30
31
|
- ".rspec"
|
31
32
|
- ".rubocop.yml"
|
@@ -319,6 +320,7 @@ files:
|
|
319
320
|
- spec/code_objects/macro_object_spec.rb
|
320
321
|
- spec/code_objects/method_object_spec.rb
|
321
322
|
- spec/code_objects/module_object_spec.rb
|
323
|
+
- spec/code_objects/namespace_mapper_spec.rb
|
322
324
|
- spec/code_objects/namespace_object_spec.rb
|
323
325
|
- spec/code_objects/proxy_spec.rb
|
324
326
|
- spec/code_objects/spec_helper.rb
|
@@ -415,6 +417,7 @@ files:
|
|
415
417
|
- spec/parser/source_parser_spec.rb
|
416
418
|
- spec/parser/tag_parsing_spec.rb
|
417
419
|
- spec/rake/yardoc_task_spec.rb
|
420
|
+
- spec/registry_resolver_spec.rb
|
418
421
|
- spec/registry_spec.rb
|
419
422
|
- spec/registry_store_spec.rb
|
420
423
|
- spec/rubygems/doc_manager_spec.rb
|