• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

sile-typesetter / sile / 7141747182

08 Dec 2023 01:08PM UTC coverage: 72.188% (-2.4%) from 74.636%
7141747182

push

github

web-flow
Merge pull request #1924 from alerque/lint-fixes

4 of 10 new or added lines in 8 files covered. (40.0%)

376 existing lines in 13 files now uncovered.

11384 of 15770 relevant lines covered (72.19%)

6898.07 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

82.69
/packages/base.lua
1
local package = pl.class()
131✔
2
package.type = "package"
131✔
3
package._name = "base"
131✔
4

5
package._initialized = false
131✔
6
package.class = nil
131✔
7

8
-- For shimming packages that used to have legacy exports
9
package.exports = {}
131✔
10

11
local function script_path ()
12
  local src = debug.getinfo(3, "S").source:sub(2)
886✔
13
  local base = src:match("(.*[/\\])")
886✔
14
  return base
886✔
15
end
16

17
function package:_init (_)
131✔
18
  self.class = SILE.scratch.half_initialized_class or SILE.documentState.documentClass
886✔
19
  if not self.class then
886✔
20
    SU.error("Attempted to initialize package before class, should have been queued in the preamble", true)
×
21
  end
22
  self.basedir = script_path()
1,772✔
23
  self:declareSettings()
886✔
24
  self:registerRawHandlers()
886✔
25
  self:registerCommands()
886✔
26
end
27

28
function package:_post_init ()
131✔
29
  self._initialized = true
887✔
30
end
31

32
function package.declareSettings (_) end
959✔
33

34
function package.registerRawHandlers (_) end
1,014✔
35

36
function package:loadPackage (packname)
131✔
37
  return self.class:loadPackage(packname)
348✔
38
end
39

40
function package.registerCommands (_) end
168✔
41

42
-- This gives us a hook to match commands with the packages that registered
43
-- them as opposed to core commands or class-provided commands
44
function package:registerCommand (name, func, help, pack)
131✔
45
  self.class:registerCommand(name, func, help, pack)
4,022✔
46
end
47
function package:registerRawHandler (format, callback)
131✔
48
  self.class:registerRawHandler(format, callback)
3✔
49
end
50

51
-- Using this rather than doing the work directly will give us a way to
52
-- un-export them if we ever need to unload modules and revert functions
53
function package:export (name, func)
131✔
54
  self.class[name] = func
938✔
55
end
56

57
-- Shims for two possible kinds of legacy exports: blind direct stuffing into
58
-- the class but not expecting to be called as a method AND the exports table
59
-- to package modules...
60

61
local _deprecate_class_funcs = [[
62
  Please explicitly use functions provided by packages by referencing
63
  them in the document class's list of loaded packages rather than the
64
  legacy solution that added non-method functions to the class.]]
131✔
65

66
local _deprecate_exports_table = [[
67
  Please explicitly use functions provided by packages by referencing
68
  them in the document class's list of loaded packages rather than the
69
  legacy solution of calling them from an exports table.]]
131✔
70

71
function package:deprecatedExport (name, func, noclass, notable)
131✔
72

73
  if not noclass then
910✔
74
    self.class[name] = function (...)
910✔
75
      -- http://lua-users.org/wiki/VarargTheSecondClassCitizen
76
      local inputs = {...}
12✔
77
      -- local inputs = table.unpack({...}, 1, select("#", ...))
78
      if type(inputs[1]) ~= "table" or inputs[1].type ~= "class" then
12✔
79
        table.insert(inputs, 1, self.class)
×
80
      end
81
      SU.deprecated(("class.%s"):format(name),
24✔
82
                    ("class.packages.%s:%s"):format(self._name, name),
12✔
83
                    "0.14.0", "0.16.0", _deprecate_class_funcs)
12✔
84
      return func(pl.utils.unpack(inputs, 1, select("#", ...) + 1))
24✔
85
    end
86
  end
87

88
  if not notable then
910✔
89
    self.exports[name] = function (...)
910✔
90
      local inputs = {...}
×
91
      if type(inputs[1]) ~= "table" or inputs[1].type ~= "package" then
×
92
        table.insert(inputs, 1, self)
×
93
      end
94
      SU.deprecated(("require('packages.%s').exports.%s"):format(self._name, name),
×
95
                    ("class.packages.%s:%s"):format(self._name, name),
×
96
                    "0.14.0", "0.16.0", _deprecate_exports_table)
×
NEW
97
      return func(pl.utils.unpack(inputs, 1, select("#", ...) + 1))
×
98
    end
99
  end
100

101
end
102

103
return package
131✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc