Sha256: b6cad7cafa1a34f3be1a71d34c532b60c001b68d82f26f1b3347eb11cc505d46

Contents?: true

Size: 582 Bytes

Versions: 2

Compression:

Stored size: 582 Bytes

Contents

# frozen_string_literal: true

module Jazzy
  module SearchBuilder
    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
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
jazzy-0.14.3 lib/jazzy/search_builder.rb
jazzy-0.14.2 lib/jazzy/search_builder.rb