Module: Jazzy::SearchBuilder

Defined in:
lib/jazzy/search_builder.rb

Class Method Summary collapse

Class Method Details

.build(source_module, output_dir) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/jazzy/search_builder.rb', line 5

def self.build(source_module, output_dir)
  decls = source_module.all_declarations.select do |d|
    d.type && d.name && !d.name.empty?
  end
  index = decls.to_h do |d|
    [d.url,
     {
       name: d.name,
       abstract: d.abstract && d.abstract.split("\n").map(&:strip).first,
       parent_name: d.parent_in_code&.name,
     }.reject { |_, v| v.nil? || v.empty? }]
  end
  File.write(File.join(output_dir, 'search.json'), index.to_json)
end