class RDoc::TagsTask

Creates rake tasks for building, rebuilding and removing TAGS files.

In your Rakefile add:

require 'rdoc/tags_task'

RDoc::TagsTask.new

Then run from the commandline:

$ rake tags         # build
$ rake retag        # rebuild
$ rake clobber_tags # remove

Use the Hoe::RDoc_tags plugin instead if you're using Hoe.

Attributes

ctags_merge[RW]

Merge Exuberant Ctags output with our own. See RDoc::Generator::Tags

ctags_path[RW]

Path to Exuberant Ctags. ctags will be found automatically if this is not set. See RDoc::Generator::Tags

files[RW]

Rake::FileList of files to be used for tag generation.

Your gem's require paths are probably sufficient.

tag_style[RW]

Tag style to output. Defaults to vim, emacs is also supported.

tags_dir[RW]

Directory to generate tags into. Defaults to '.'

tags_file[RW]

Name of the TAGS file. Defaults to 'TAGS'

Public Class Methods

new(names = {}) { |self| ... } click to toggle source

Creates a new RDoc task that will build a TAGS file. Default task names are tags to build, retag to rebuild and clobber_tags to remove. These may be overridden using the names hash with the :tags, :retag and :clobber keys respectively.

# File lib/rdoc/tags_task.rb, line 75
def initialize names = {} # :yield: self
  @clobber_task = names[:clobber] || 'clobber_tags'
  @retag_task   = names[:retag]   || 'retag'
  @tags_task    = names[:tags]    || 'tags'

  @files     = Rake::FileList.new 'lib/**/*.rb'
  @tags_dir  = './.rdoc'
  @tags_file = 'TAGS'
  @tag_style = 'vim'

  @ctags_merge = false
  @ctags_path  = nil

  yield self if block_given?

  define
end

Public Instance Methods

build_tags() click to toggle source

Builds the TAGS file.

# File lib/rdoc/tags_task.rb, line 96
def build_tags
  require 'rdoc/rdoc'
  require 'rdoc/generator/tags'

  options = RDoc::Options.new
  options.setup_generator 'tags'

  options.tag_style = @tag_style

  options.ctags_merge = @ctags_merge
  options.ctags_path  = @ctags_path

  options.files = @files

  options.op_dir = @tags_dir
  options.verbosity = 0

  if Rake.application.options.trace then
    options.verbosity = 1

    # TODO RDoc::Options#to_argv?
    ctags_merge = " --ctags-merge" if @ctags_merge
    ctags_path = " --ctags_path=#{@ctags_path}" if @ctags_path
    ctags = "#{ctags_merge}#{ctags_path}"

    $stderr.puts "rdoc -o #{@tags_dir} -f tags#{ctags} #{@files}"
  end

  RDoc::RDoc.new.document options
end
define() click to toggle source

Defines tasks for building, rebuilding and clobbering the TAGS file

# File lib/rdoc/tags_task.rb, line 130
def define
  desc 'Build TAGS file'
  task @tags_task => @tags_file

  desc 'Rebuild TAGS file'
  task @retag_task => [@clobber_task, @tags_task]

  desc 'Clobber TAGS file'
  task @clobber_task do
    rm_f tags_path, :verbose => Rake.application.options.trace
  end

  directory @tags_dir

  file @tags_file => [@tags_dir, Rake.application.rakefile, *@files] do
    build_tags
  end

  self
end
tags_path() click to toggle source

Path to the tags file

# File lib/rdoc/tags_task.rb, line 154
def tags_path
  File.join @tags_dir, @tags_file
end