Method: Jazzy::SourceKitten.group_custom_categories

Defined in:
lib/jazzy/sourcekitten.rb

.group_custom_categories(docs) ⇒ Object



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/jazzy/sourcekitten.rb', line 71

def self.group_custom_categories(docs)
  group = Config.instance.custom_categories.map do |category|
    children = category['children'].flat_map do |name|
      docs_with_name, docs = docs.partition { |doc| doc.name == name }
      if docs_with_name.empty?
        STDERR.puts 'WARNING: No documented top-level declarations match ' \
                    "name \"#{name}\" specified in categories file"
      end
      docs_with_name
    end
    # Category config overrides alphabetization
    children.each.with_index { |child, i| child.nav_order = i }
    make_group(children, category['name'], '')
  end
  [group.compact, docs]
end