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

sile-typesetter / sile / 9304060604

30 May 2024 02:07PM UTC coverage: 74.124% (-0.6%) from 74.707%
9304060604

push

github

alerque
style: Reformat Lua with stylua

8104 of 11995 new or added lines in 184 files covered. (67.56%)

15 existing lines in 11 files now uncovered.

12444 of 16788 relevant lines covered (74.12%)

7175.1 hits per line

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

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

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

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

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

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

28
function package:_post_init ()
181✔
29
   self._initialized = true
1,120✔
30
end
31

32
function package.declareSettings (_) end
1,234✔
33

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

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

40
function package.registerCommands (_) end
237✔
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)
181✔
45
   self.class:registerCommand(name, func, help, pack)
5,034✔
46
end
47
function package:registerRawHandler (format, callback)
181✔
48
   self.class:registerRawHandler(format, callback)
4✔
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)
181✔
54
   self.class[name] = func
1,132✔
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.]]
181✔
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.]]
181✔
70

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

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

109
return package
181✔
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