rdoc-tags 1.1 → 1.2
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/History.txt +12 -0
- data/Rakefile +6 -1
- data/lib/hoe/rdoc_tags.rb +11 -3
- data/lib/rdoc/discover.rb +3 -2
- data/lib/rdoc/generator/tags.rb +88 -12
- data/lib/rdoc/tags_task.rb +47 -17
- data/test/test_rdoc_generator_tags.rb +37 -6
- metadata +23 -9
- metadata.gz.sig +0 -0
data.tar.gz.sig
CHANGED
Binary file
|
data/History.txt
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
=== 1.2
|
2
|
+
|
3
|
+
* Minor enhancements
|
4
|
+
* rdoc-tags can now merge with Exuberant Ctags for projects with extensions
|
5
|
+
or other languages. Use <tt>--ctags-merge</tt> to enable merging.
|
6
|
+
rdoc-tags will discover Exuberant Ctags in your PATH by checking the
|
7
|
+
output of <tt>ctags --version</tt>.
|
8
|
+
* Bug Fixes
|
9
|
+
* Fixed Hoe plugin to match RDoc::TagsTask arguments.
|
10
|
+
* Require rdoc/generator/tags first for RDoc::TagsTask.
|
11
|
+
* The tags generator no longer creates a create.rid file.
|
12
|
+
|
1
13
|
=== 1.1 / 2010-12-29
|
2
14
|
|
3
15
|
* Minor enhancements
|
data/Rakefile
CHANGED
@@ -3,6 +3,8 @@
|
|
3
3
|
require 'rubygems'
|
4
4
|
require 'hoe'
|
5
5
|
|
6
|
+
$:.unshift 'lib' # allow rdoc-tags to tag itself
|
7
|
+
|
6
8
|
Hoe.plugin :git
|
7
9
|
Hoe.plugin :isolate
|
8
10
|
Hoe.plugin :minitest
|
@@ -12,10 +14,13 @@ Hoe.plugins.delete :rubyforge
|
|
12
14
|
Hoe.spec 'rdoc-tags' do
|
13
15
|
developer 'Eric Hodel', 'drbrain@segment7.net'
|
14
16
|
|
15
|
-
extra_deps << ['rdoc', '~> 3.
|
17
|
+
extra_deps << ['rdoc', '~> 3.4'] # don't forget to update rdoc/discover.rb
|
16
18
|
extra_dev_deps << ['isolate', '~> 3']
|
19
|
+
extra_dev_deps << ['ZenTest']
|
17
20
|
|
18
21
|
self.isolate_dir = 'tmp/isolate'
|
22
|
+
self.rdoc_locations =
|
23
|
+
'drbrain@rubyforge.org:/var/www/gforge-projects/rdoc/rdoc-tags'
|
19
24
|
end
|
20
25
|
|
21
26
|
# vim: syntax=Ruby
|
data/lib/hoe/rdoc_tags.rb
CHANGED
@@ -24,15 +24,23 @@ module Hoe::RDoc_tags
|
|
24
24
|
# Hoe.
|
25
25
|
|
26
26
|
def define_rdoc_tags_tasks
|
27
|
-
|
27
|
+
ctags_merge = false
|
28
|
+
ctags_path = nil
|
28
29
|
|
29
30
|
with_config do |config, _|
|
30
|
-
|
31
|
+
tag_style = config['tag_style']
|
32
|
+
ctags_merge = config['ctags_merge'] if config.key? 'ctags_merge'
|
33
|
+
ctags_path = config['ctags_path']
|
31
34
|
end
|
32
35
|
|
36
|
+
tag_style ||= 'vim'
|
37
|
+
|
33
38
|
RDoc::TagsTask.new do |rd|
|
34
39
|
rd.files += spec.require_paths
|
35
|
-
|
40
|
+
|
41
|
+
rd.tag_style = tag_style
|
42
|
+
rd.ctags_merge = ctags_merge
|
43
|
+
rd.ctags_path = ctags_path
|
36
44
|
end
|
37
45
|
|
38
46
|
task :clean => :clobber_tags
|
data/lib/rdoc/discover.rb
CHANGED
data/lib/rdoc/generator/tags.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
|
-
require 'rdoc/rdoc'
|
2
|
-
require 'rdoc/generator'
|
3
|
-
|
4
1
|
##
|
5
2
|
# A TAGS file generator based on http://ctags.sourceforge.net/FORMAT
|
3
|
+
#
|
4
|
+
# This file will be automatically loaded via rdoc/discover.rb. If you wish to
|
5
|
+
# load this standalone, require 'rdoc/rdoc' first.
|
6
6
|
|
7
7
|
class RDoc::Generator::Tags
|
8
8
|
|
9
9
|
##
|
10
10
|
# The version of the tags generator you are using
|
11
11
|
|
12
|
-
VERSION = '1.
|
12
|
+
VERSION = '1.2'
|
13
13
|
|
14
14
|
RDoc::RDoc.add_generator self
|
15
15
|
|
@@ -23,6 +23,16 @@ class RDoc::Generator::Tags
|
|
23
23
|
|
24
24
|
TAG_STYLES = [:vim]
|
25
25
|
|
26
|
+
##
|
27
|
+
# Merge ctags-generated tags onto our own?
|
28
|
+
|
29
|
+
attr_accessor :ctags_merge
|
30
|
+
|
31
|
+
##
|
32
|
+
# Path to Exuberant Ctags
|
33
|
+
|
34
|
+
attr_accessor :ctags_path
|
35
|
+
|
26
36
|
##
|
27
37
|
# Which tag style shall we output?
|
28
38
|
|
@@ -30,12 +40,23 @@ class RDoc::Generator::Tags
|
|
30
40
|
|
31
41
|
end
|
32
42
|
|
43
|
+
##
|
44
|
+
# Merge with Exuberant Ctags if true
|
45
|
+
|
46
|
+
attr_accessor :ctags_merge
|
47
|
+
|
48
|
+
##
|
49
|
+
# Path to Exuberant Ctags
|
50
|
+
|
51
|
+
attr_accessor :ctags_path
|
52
|
+
|
33
53
|
##
|
34
54
|
# Adds tags-generator options to the RDoc::Options instance +options+
|
35
55
|
|
36
56
|
def self.setup_options options
|
37
57
|
options.force_output = true
|
38
58
|
options.op_dir = '.'
|
59
|
+
options.update_output_dir = false
|
39
60
|
|
40
61
|
options.extend Options
|
41
62
|
|
@@ -47,6 +68,22 @@ class RDoc::Generator::Tags
|
|
47
68
|
op.separator 'tags generator options:'
|
48
69
|
op.separator nil
|
49
70
|
|
71
|
+
op.on('--[no-]ctags-merge',
|
72
|
+
'Merge exuberant ctags with our own?',
|
73
|
+
'Use this for projects with C extensions') do |value|
|
74
|
+
options.ctags_path = value
|
75
|
+
end
|
76
|
+
|
77
|
+
op.separator nil
|
78
|
+
|
79
|
+
op.on('--ctags-path=PATH',
|
80
|
+
'Path to Exuberant Ctags',
|
81
|
+
'This will be auto-discovered from PATH') do |value|
|
82
|
+
options.ctags_path = value
|
83
|
+
end
|
84
|
+
|
85
|
+
op.separator nil
|
86
|
+
|
50
87
|
op.on('--tag-style=TAG_STYLE', Options::TAG_STYLES,
|
51
88
|
'Which type of TAGS file to output') do |value|
|
52
89
|
options.tag_style = value
|
@@ -60,10 +97,34 @@ class RDoc::Generator::Tags
|
|
60
97
|
|
61
98
|
def initialize options
|
62
99
|
@options = options
|
63
|
-
|
100
|
+
|
101
|
+
@ctags_merge = options.ctags_merge
|
102
|
+
@ctags_path = options.ctags_path
|
103
|
+
@dry_run = options.dry_run
|
104
|
+
|
64
105
|
@tags = Hash.new { |h, name| h[name] = [] }
|
65
106
|
end
|
66
107
|
|
108
|
+
##
|
109
|
+
# Finds the first Exuberant Ctags in ENV['PATH'] by checking <tt>ctags
|
110
|
+
# --version</tt>. Other implementations are ignored.
|
111
|
+
|
112
|
+
def find_ctags
|
113
|
+
require 'open3'
|
114
|
+
|
115
|
+
ENV['PATH'].split(File::PATH_SEPARATOR).each do |dir|
|
116
|
+
ctags = File.join dir, 'ctags'
|
117
|
+
next unless File.exist? ctags
|
118
|
+
|
119
|
+
# other ctags implementations write to stderr, silence them
|
120
|
+
return ctags if Open3.popen3 ctags, '--version' do |_, out, _|
|
121
|
+
out.gets =~ /^Exuberant Ctags/
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
nil
|
126
|
+
end
|
127
|
+
|
67
128
|
##
|
68
129
|
# Generates a TAGS file from +top_levels+
|
69
130
|
|
@@ -94,7 +155,7 @@ class RDoc::Generator::Tags
|
|
94
155
|
'f',
|
95
156
|
kind
|
96
157
|
]
|
97
|
-
|
158
|
+
|
98
159
|
@tags[attr.name] << where
|
99
160
|
@tags["#{attr.name}="] << where
|
100
161
|
end
|
@@ -117,7 +178,22 @@ class RDoc::Generator::Tags
|
|
117
178
|
end
|
118
179
|
end
|
119
180
|
|
120
|
-
|
181
|
+
unless @dry_run then
|
182
|
+
write_tags
|
183
|
+
merge_ctags
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
##
|
188
|
+
# Merges our tags with Exuberant Ctags' tags
|
189
|
+
|
190
|
+
def merge_ctags
|
191
|
+
return unless @ctags_merge
|
192
|
+
|
193
|
+
ctags_path = @ctags_path || find_ctags
|
194
|
+
|
195
|
+
system(ctags_path, '--append=yes', '--format=2', '--languages=-Ruby',
|
196
|
+
'--recurse=yes', *@options.files)
|
121
197
|
end
|
122
198
|
|
123
199
|
##
|
@@ -126,12 +202,12 @@ class RDoc::Generator::Tags
|
|
126
202
|
def write_tags
|
127
203
|
open 'TAGS', 'w' do |io|
|
128
204
|
io.write <<-INFO
|
129
|
-
!_TAG_FILE_FORMAT\t2
|
130
|
-
!_TAG_FILE_SORTED\t1
|
205
|
+
!_TAG_FILE_FORMAT\t2\t/extended format/
|
206
|
+
!_TAG_FILE_SORTED\t1\t/sorted/
|
131
207
|
!_TAG_PROGRAM_AUTHOR\tEric Hodel\t/drbrain@segment7.net/
|
132
|
-
!_TAG_PROGRAM_NAME\trdoc-tags
|
133
|
-
!_TAG_PROGRAM_URL\thttps://github.com/rdoc/rdoc-tags
|
134
|
-
!_TAG_PROGRAM_VERSION\t#{VERSION}
|
208
|
+
!_TAG_PROGRAM_NAME\trdoc-tags\t//
|
209
|
+
!_TAG_PROGRAM_URL\thttps://github.com/rdoc/rdoc-tags\t//
|
210
|
+
!_TAG_PROGRAM_VERSION\t#{VERSION}\t//
|
135
211
|
INFO
|
136
212
|
|
137
213
|
@tags.sort.each do |name, definitions|
|
data/lib/rdoc/tags_task.rb
CHANGED
@@ -8,6 +8,12 @@ end
|
|
8
8
|
require 'rake'
|
9
9
|
require 'rake/tasklib'
|
10
10
|
|
11
|
+
begin
|
12
|
+
gem 'rdoc'
|
13
|
+
rescue LoadError
|
14
|
+
end
|
15
|
+
require 'rdoc'
|
16
|
+
|
11
17
|
##
|
12
18
|
# Creates rake tasks for building, rebuilding and removing TAGS files.
|
13
19
|
#
|
@@ -27,6 +33,17 @@ require 'rake/tasklib'
|
|
27
33
|
|
28
34
|
class RDoc::TagsTask < Rake::TaskLib
|
29
35
|
|
36
|
+
##
|
37
|
+
# Merge Exuberant Ctags output with our own. See RDoc::Generator::Tags
|
38
|
+
|
39
|
+
attr_accessor :ctags_merge
|
40
|
+
|
41
|
+
##
|
42
|
+
# Path to Exuberant Ctags. ctags will be found automatically if this is not
|
43
|
+
# set. See RDoc::Generator::Tags
|
44
|
+
|
45
|
+
attr_accessor :ctags_path
|
46
|
+
|
30
47
|
##
|
31
48
|
# Rake::FileList of files to be used for tag generation.
|
32
49
|
#
|
@@ -65,6 +82,9 @@ class RDoc::TagsTask < Rake::TaskLib
|
|
65
82
|
@tags_file = 'TAGS'
|
66
83
|
@tag_style = 'vim'
|
67
84
|
|
85
|
+
@ctags_merge = false
|
86
|
+
@ctags_path = nil
|
87
|
+
|
68
88
|
yield self if block_given?
|
69
89
|
|
70
90
|
define
|
@@ -74,24 +94,34 @@ class RDoc::TagsTask < Rake::TaskLib
|
|
74
94
|
# Builds the TAGS file.
|
75
95
|
|
76
96
|
def build_tags
|
77
|
-
args = [
|
78
|
-
'-f', 'tags',
|
79
|
-
'-q',
|
80
|
-
'--tag-style', @tag_style,
|
81
|
-
'-o', @tags_dir,
|
82
|
-
]
|
83
|
-
|
84
|
-
args += @files
|
85
|
-
|
86
|
-
begin
|
87
|
-
gem 'rdoc'
|
88
|
-
rescue Gem::LoadError
|
89
|
-
end
|
90
|
-
|
91
97
|
require 'rdoc/rdoc'
|
92
|
-
|
98
|
+
require 'rdoc/generator/tags'
|
99
|
+
|
100
|
+
options = RDoc::Options.new
|
101
|
+
options.setup_generator 'tags'
|
102
|
+
|
103
|
+
options.tag_style = @tag_style
|
104
|
+
|
105
|
+
options.ctags_merge = @ctags_merge
|
106
|
+
options.ctags_path = @ctags_path
|
107
|
+
|
108
|
+
options.files = @files
|
109
|
+
|
110
|
+
options.op_dir = @tags_dir
|
111
|
+
options.verbosity = 0
|
112
|
+
|
113
|
+
if Rake.application.options.trace then
|
114
|
+
options.verbosity = 1
|
115
|
+
|
116
|
+
# TODO RDoc::Options#to_argv?
|
117
|
+
ctags_merge = " --ctags-merge" if @ctags_merge
|
118
|
+
ctags_path = " --ctags_path=#{@ctags_path}" if @ctags_path
|
119
|
+
ctags = "#{ctags_merge}#{ctags_path}"
|
120
|
+
|
121
|
+
$stderr.puts "rdoc -o #{@tags_dir} -f tags#{ctags} #{@files}"
|
122
|
+
end
|
93
123
|
|
94
|
-
RDoc::RDoc.new.document
|
124
|
+
RDoc::RDoc.new.document options
|
95
125
|
end
|
96
126
|
|
97
127
|
##
|
@@ -106,7 +136,7 @@ class RDoc::TagsTask < Rake::TaskLib
|
|
106
136
|
|
107
137
|
desc 'Clobber TAGS file'
|
108
138
|
task @clobber_task do
|
109
|
-
rm_f tags_path
|
139
|
+
rm_f tags_path, :verbose => Rake.application.options.trace
|
110
140
|
end
|
111
141
|
|
112
142
|
directory @tags_dir
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'rubygems'
|
2
|
-
gem 'rdoc', '~> 3'
|
2
|
+
gem 'rdoc', '~> 3.4'
|
3
3
|
|
4
4
|
require 'minitest/autorun'
|
5
5
|
require 'rdoc/rdoc'
|
@@ -76,7 +76,14 @@ class TestRDocGeneratorTags < MiniTest::Unit::TestCase
|
|
76
76
|
|
77
77
|
assert_equal :vim, options.tag_style
|
78
78
|
|
79
|
+
assert_includes op.top.long, 'ctags-path'
|
80
|
+
assert_includes op.top.long, 'ctags-merge'
|
79
81
|
assert_includes op.top.long, 'tag-style'
|
82
|
+
refute options.update_output_dir
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_find_ctags
|
86
|
+
assert_equal '/usr/local/bin/ctags', @g.find_ctags
|
80
87
|
end
|
81
88
|
|
82
89
|
def test_generate_emacs
|
@@ -139,14 +146,14 @@ class TestRDocGeneratorTags < MiniTest::Unit::TestCase
|
|
139
146
|
|
140
147
|
tags = File.read(tags_file).lines
|
141
148
|
|
142
|
-
assert_equal "!_TAG_FILE_FORMAT\t2\n", tags.next
|
143
|
-
assert_equal "!_TAG_FILE_SORTED\t1\n", tags.next
|
149
|
+
assert_equal "!_TAG_FILE_FORMAT\t2\t/extended format/\n", tags.next
|
150
|
+
assert_equal "!_TAG_FILE_SORTED\t1\t/sorted/\n", tags.next
|
144
151
|
assert_equal "!_TAG_PROGRAM_AUTHOR\tEric Hodel\t/drbrain@segment7.net/\n",
|
145
152
|
tags.next
|
146
|
-
assert_equal "!_TAG_PROGRAM_NAME\trdoc-tags\n", tags.next
|
147
|
-
assert_equal "!_TAG_PROGRAM_URL\thttps://github.com/rdoc/rdoc-tags\n",
|
153
|
+
assert_equal "!_TAG_PROGRAM_NAME\trdoc-tags\t//\n", tags.next
|
154
|
+
assert_equal "!_TAG_PROGRAM_URL\thttps://github.com/rdoc/rdoc-tags\t//\n",
|
148
155
|
tags.next
|
149
|
-
assert_equal "!_TAG_PROGRAM_VERSION\t#{RDoc::Generator::Tags::VERSION}\n",
|
156
|
+
assert_equal "!_TAG_PROGRAM_VERSION\t#{RDoc::Generator::Tags::VERSION}\t//\n",
|
150
157
|
tags.next
|
151
158
|
|
152
159
|
assert_equal "A\tfile.rb\t/class A/;\"\tc\n", tags.next
|
@@ -188,5 +195,29 @@ class TestRDocGeneratorTags < MiniTest::Unit::TestCase
|
|
188
195
|
refute File.exist? File.join(@tmpdir, 'TAGS')
|
189
196
|
end
|
190
197
|
|
198
|
+
def test_merge_ctags
|
199
|
+
def @g.system(*args)
|
200
|
+
@system = args
|
201
|
+
end
|
202
|
+
|
203
|
+
@g.instance_variable_set :@system, nil
|
204
|
+
|
205
|
+
@g.merge_ctags
|
206
|
+
|
207
|
+
assert_nil @g.instance_variable_get :@system
|
208
|
+
|
209
|
+
@g.ctags_merge = true
|
210
|
+
@g.ctags_path = 'ctags'
|
211
|
+
@options.files = '.'
|
212
|
+
|
213
|
+
@g.merge_ctags
|
214
|
+
|
215
|
+
args = @g.instance_variable_get :@system
|
216
|
+
|
217
|
+
assert_equal %w[ctags
|
218
|
+
--append=yes --format=2 --languages=-Ruby --recurse=yes
|
219
|
+
.], args
|
220
|
+
end
|
221
|
+
|
191
222
|
end
|
192
223
|
|
metadata
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rdoc-tags
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: "1.
|
8
|
+
- 2
|
9
|
+
version: "1.2"
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Eric Hodel
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
35
35
|
x52qPcexcYZR7w==
|
36
36
|
-----END CERTIFICATE-----
|
37
37
|
|
38
|
-
date:
|
38
|
+
date: 2011-01-06 00:00:00 -08:00
|
39
39
|
default_executable:
|
40
40
|
dependencies:
|
41
41
|
- !ruby/object:Gem::Dependency
|
@@ -46,11 +46,11 @@ dependencies:
|
|
46
46
|
requirements:
|
47
47
|
- - ~>
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
hash:
|
49
|
+
hash: 15
|
50
50
|
segments:
|
51
51
|
- 3
|
52
|
-
-
|
53
|
-
version: "3.
|
52
|
+
- 4
|
53
|
+
version: "3.4"
|
54
54
|
type: :runtime
|
55
55
|
version_requirements: *id001
|
56
56
|
- !ruby/object:Gem::Dependency
|
@@ -84,9 +84,23 @@ dependencies:
|
|
84
84
|
type: :development
|
85
85
|
version_requirements: *id003
|
86
86
|
- !ruby/object:Gem::Dependency
|
87
|
-
name:
|
87
|
+
name: ZenTest
|
88
88
|
prerelease: false
|
89
89
|
requirement: &id004 !ruby/object:Gem::Requirement
|
90
|
+
none: false
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
hash: 3
|
95
|
+
segments:
|
96
|
+
- 0
|
97
|
+
version: "0"
|
98
|
+
type: :development
|
99
|
+
version_requirements: *id004
|
100
|
+
- !ruby/object:Gem::Dependency
|
101
|
+
name: hoe
|
102
|
+
prerelease: false
|
103
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
90
104
|
none: false
|
91
105
|
requirements:
|
92
106
|
- - ">="
|
@@ -98,7 +112,7 @@ dependencies:
|
|
98
112
|
- 0
|
99
113
|
version: 2.7.0
|
100
114
|
type: :development
|
101
|
-
version_requirements: *
|
115
|
+
version_requirements: *id005
|
102
116
|
description: |-
|
103
117
|
A TAGS file generator based on http://ctags.sourceforge.net/FORMAT. rdoc-tags
|
104
118
|
handles namespaced classes and modules, ! and ? methods, constants and
|
metadata.gz.sig
CHANGED
Binary file
|