<commit_before>--[[------------------------------------------------------

  dub.Inspector
  -------------

  The Inspector 'knows' about the functions and classes
  and can answer queries. It first the main entry point to
  parse and create bindings.

--]]------------------------------------------------------
local lib     = {
  type = 'dub.Inspector',
  DOXYGEN_CMD = 'doxygen',
  DOXYGEN_CMD = {
    macosx = '/Applications/Doxygen.app/Contents/Resources/doxygen',
    linux  = 'doxygen',
  }
}
local private = {}
lib.__index   = lib
dub.Inspector = lib

--=============================================== dub.Inspector()
setmetatable(lib, {
  __call = function(lib, opts)
    local self = {db = dub.MemoryStorage()}
    setmetatable(self, lib)
    if opts then
      self:parse(opts)
    end
    return self
  end
})

--=============================================== PUBLIC METHODS
-- Add xml headers to the database. If not_lazy is set, parse everything
-- directly (not when needed). Only set this option if the xml files
-- will be removed before queries.
function lib:parseXml(xml_dir, not_lazy, ignore_list)
  self.db:parse(xml_dir, not_lazy, ignore_list)
end

function lib:parse(opts)
  if type(opts) == 'string' then
    opts = {INPUT = opts}
  end
  assert(opts.INPUT, "Missing 'INPUT' field")
  local doc_dir = opts.doc_dir
  if not doc_dir then
    doc_dir = 'dub-tmp'
    local i = 0
    while true do
      if lk.exist(doc_dir) then
        i = i + 1
        doc_dir = string.format('dub-tmp-%i', i)
      else
        break
      end
    end
  end

  private.execute('mkdir -p ' .. doc_dir)

  if opts.html then
    opts.GENERATE_HTML = 'YES'
  end


  local doxypath = opts.Doxyfile
  if not doxypath then
    doxypath = doc_dir .. '/Doxyfile'
    local doxyfile = io.open(doxypath, 'w')

    local doxytemplate = dub.Template {path = lk.scriptDir() .. '/Doxyfile'}
    if type(opts.INPUT) == 'table' then
      opts.INPUT = lk.join(opts.INPUT, ' ')
    end
    if type(opts.PREDEFINED) == 'table' then<commit_msg>When keeping xml, should use dub-doc folder<commit_after>--[[------------------------------------------------------

  dub.Inspector
  -------------

  The Inspector 'knows' about the functions and classes
  and can answer queries. It first the main entry point to
  parse and create bindings.

--]]------------------------------------------------------
local lib     = {
  type = 'dub.Inspector',
  DOXYGEN_CMD = 'doxygen',
  DOXYGEN_CMD = {
    macosx = '/Applications/Doxygen.app/Contents/Resources/doxygen',
    linux  = 'doxygen',
  }
}
local private = {}
lib.__index   = lib
dub.Inspector = lib

--=============================================== dub.Inspector()
setmetatable(lib, {
  __call = function(lib, opts)
    local self = {db = dub.MemoryStorage()}
    setmetatable(self, lib)
    if opts then
      self:parse(opts)
    end
    return self
  end
})

--=============================================== PUBLIC METHODS
-- Add xml headers to the database. If not_lazy is set, parse everything
-- directly (not when needed). Only set this option if the xml files
-- will be removed before queries.
function lib:parseXml(xml_dir, not_lazy, ignore_list)
  self.db:parse(xml_dir, not_lazy, ignore_list)
end

function lib:parse(opts)
  if type(opts) == 'string' then
    opts = {INPUT = opts}
  end
  assert(opts.INPUT, "Missing 'INPUT' field")

  if opts.html then
    opts.GENERATE_HTML = 'YES'
    opts.keep_xml = true
  end

  local doc_dir = opts.doc_dir
  if opts.keep_xml and not doc_dir then
    doc_dir = 'dub-doc'
  elseif not doc_dir then
    doc_dir = 'dub-tmp'
    local i = 0
    while true do
      if lk.exist(doc_dir) then
        i = i + 1
        doc_dir = string.format('dub-tmp-%i', i)
      else
        break
      end
    end
  end

  private.execute('mkdir -p ' .. doc_dir)

  local doxypath = opts.Doxyfile
  if not doxypath then
    doxypath = doc_dir .. '/Doxyfile'
    local doxyfile = io.open(doxypath, 'w')

    local doxytemplate = dub.Template {path = lk.scriptDir() .. '/Doxyfile'}
    if type(opts.INPUT) == 'table' then
      opts.INPUT = lk.join(opts.INPUT, ' ')
    end
    if type(opts.PREDEFINED) == 'table' then
{'fraction_non_alphanumeric': 0.2054402290622763, 'fraction_numerical': 0.000954426151276545, 'mean_word_length': 2.3616680032076984, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 11}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6775705', 'n_tokens_mistral': 1375, 'n_tokens_neox': 1329, 'n_words': 381}