Module: Solargraph::YardMap::CoreGen

Defined in:
lib/solargraph/yard_map/core_gen.rb

Overview

Tools for generating core documentation.

Class Method Summary collapse

Class Method Details

.generate_docs(ruby_dir, dest_dir) ⇒ void

This method returns an undefined value.

Generate documentation from the specified Ruby source directory.


18
19
20
21
22
23
24
25
26
27
# File 'lib/solargraph/yard_map/core_gen.rb', line 18

def generate_docs ruby_dir, dest_dir
  path_name = Pathname.new(Dir.pwd).join(dest_dir).to_s
  FileUtils.mkdir_p path_name
  Dir.chdir(ruby_dir) do
    `yardoc -b "#{File.join(path_name, 'yardoc')}" -n *.c`
    raise 'An error occurred generating the core yardoc.' unless $?.success?
    `yardoc -b "#{File.join(path_name, 'yardoc-stdlib')}" -n lib ext`
    raise 'An error occurred generating the stdlib yardoc.' unless $?.success?
  end
end

.generate_gzip(ruby_dir, ver_name = nil, dest_dir = Dir.pwd) ⇒ void

This method returns an undefined value.

Generate a gzip of documentation from the specified Ruby source directory.

This method is designed to generate the directory architecture that YardMap core docs expect.


39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/solargraph/yard_map/core_gen.rb', line 39

def generate_gzip ruby_dir, ver_name = nil, dest_dir = Dir.pwd
  Dir.mktmpdir do |tmp|
    base_name = ver_name || begin
      match = ruby_dir.match(/\d+\.\d+\.\d+$/)
      raise "Unable to determine version name from #{ruby_dir}" if match.nil?
      match[0]
    end
    path_name = Pathname.new(tmp).join(base_name).to_s
    generate_docs ruby_dir, path_name
    gzip path_name, Pathname.new(dest_dir).join("#{base_name}.tar.gz").to_s
  end
end