class IsoDoc::Generic::Metadata

def self.inherited(klass) # rubocop:disable Lint/MissingSuper

rubocop:disable Lint/MissingSuper
def self.inherited(klass) # rubocop:disable Lint/MissingSuper
  klass._file = caller_locations(1..1).first.absolute_path
end

def author(isoxml, _out)

def author(isoxml, _out)
  super
  tc = isoxml.at(ns("//bibdata/ext/editorialgroup/committee"))
  set(:tc, tc.text) if tc
end

def doctype(isoxml, _out)

def doctype(isoxml, _out)
  super
  b = isoxml&.at(ns("//bibdata/ext/doctype#{currlang}")) ||
    isoxml&.at(ns("//bibdata/ext/doctype#{NOLANG}")) || return
  a = b["abbreviation"] and set(:doctype_abbr, a)
end

def ext(isoxml, _out)

def ext(isoxml, _out)
  b = isoxml&.at(ns("//bibdata/ext")) or return
  set(:metadata_extensions, xmlhash2hash(b.to_hash)["ext"])
end

def initialize(lang, script, locale, labels)

def initialize(lang, script, locale, labels)
  super
  here = File.dirname(__FILE__)
  default_logo_path =
    File.expand_path(File.join(here, "html", "logo.jpg"))
  set(:logo, baselocation(configuration.logo_path) || default_logo_path)
  unless configuration.logo_paths.nil?
    set(:logo_paths,
        Array(configuration.logo_paths).map { |p| baselocation(p) })
  end
end

def stage_abbr(status)

def stage_abbr(status)
  return super unless configuration.stage_abbreviations
  Hash(configuration.stage_abbreviations).dig(status)
end

def unpublished(status)

def unpublished(status)
  stages = configuration&.published_stages || ["published"]
  !(Array(stages).map { |m| m.downcase }.include? status.downcase)
end

def xmlhash2hash(hash)

def xmlhash2hash(hash)
  ret = {}
  return ret if hash.nil? || hash[:kind] != "element"
  hash[:attr].nil? or
    hash[:attr].each { |k, v| ret["#{hash[:name]}_#{k}"] = v }
  ret[hash[:name]] = hash[:kids] ? xmlhash2hash_kids(hash) : hash[:text]
  ret
end

def xmlhash2hash_kids(hash)

def xmlhash2hash_kids(hash)
  c = {}
  hash[:kids].each do |n|
    xmlhash2hash(n).each do |k1, v1|
      c[k1] = if c[k1].nil? then v1
              elsif c[k1].is_a?(Array) then c[k1] << v1
              else [c[k1], v1]
              end
    end
  end
  c
end