summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/data-lst.lua
blob: f349409e41a2a542fb8579019be38a205b05d6e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
if not modules then modules = { } end modules ['data-lst'] = {
    version   = 1.001,
    comment   = "companion to luat-lib.mkiv",
    author    = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
    copyright = "PRAGMA ADE / ConTeXt Development Team",
    license   = "see context related readme files"
}

-- used in mtxrun, can be loaded later .. todo

local type = type
local sortedhash = table.sortedhash
local isdir = lfs.isdir

local resolvers            = resolvers
local listers              = resolvers.listers or { }
resolvers.listers          = listers

local resolveprefix        = resolvers.resolve
local configurationfiles   = resolvers.configurationfiles
local expandedpathfromlist = resolvers.expandedpathfromlist
local splitpath            = resolvers.splitpath
local knownvariables       = resolvers.knownvariables

local report_lists         = logs.reporter("resolvers","lists")
local report_resolved      = logs.reporter("system","resolved")

local function tabstr(str)
    if not str then
        return "unset"
    elseif type(str) == 'table' then
        return concat(str," | ")
    else
        return str
    end
end

function listers.variables(pattern)
    local result = resolvers.knownvariables(pattern)
    for key, value in sortedhash(result) do
        report_lists(key)
        report_lists("  env: %s",tabstr(value.environment))
        report_lists("  var: %s",tabstr(value.variable))
        report_lists("  exp: %s",tabstr(value.expansion))
        report_lists("  res: %s",tabstr(value.resolved))
    end
end

function listers.configurations()
    local configurations = configurationfiles()
    for i=1,#configurations do
        report_resolved("file : %s",resolveprefix(configurations[i]))
    end
    report_resolved("")
    local list = expandedpathfromlist(splitpath(resolvers.luacnfspec))
    for i=1,#list do
        local li = resolveprefix(list[i])
        if isdir(li) then
            report_resolved("path - %s",li)
        else
            report_resolved("path + %s",li)
        end
    end
end