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

sile-typesetter / sile / 14860011647

06 May 2025 12:44PM UTC coverage: 67.057% (+32.5%) from 34.559%
14860011647

push

github

alerque
chore(typesetters): Fixup access to class from typesetter functions

7 of 7 new or added lines in 2 files covered. (100.0%)

1344 existing lines in 103 files now uncovered.

14880 of 22190 relevant lines covered (67.06%)

11549.16 hits per line

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

60.0
/packages/base.lua
1
--- SILE package class.
2
-- @interfaces packages
3

4
local module = require("types.module")
153✔
5

6
local package = pl.class(module)
153✔
7
package.type = "package"
153✔
8

9
package.class = nil
153✔
10

11
-- For shimming packages that used to have legacy exports
12
package.exports = {}
153✔
13

14
function package:_init (_options)
153✔
15
   self.class = SILE.scratch.half_initialized_class or SILE.documentState.documentClass
1,106✔
16
   module._init(self)
1,106✔
17
   if not self.class then
1,106✔
UNCOV
18
      SU.error("Attempted to initialize package before class, should have been queued in the preamble", true)
×
19
   end
20
end
21

22
function package:loadPackage (packname, options, reload)
153✔
23
   return self.class:loadPackage(packname, options, reload)
403✔
24
end
25

26
function package:reloadPackage (packname, options)
153✔
UNCOV
27
   return self.class:reloadPackage(packname, options)
×
28
end
29

30
-- Using this rather than doing the work directly will give us a way to
31
-- un-export them if we ever need to unload modules and revert functions
32
function package:export (name, func)
153✔
33
   self.class[name] = func
1,056✔
34
end
35

36
-- Shims for two possible kinds of legacy exports: blind direct stuffing into
37
-- the class but not expecting to be called as a method AND the exports table
38
-- to package modules...
39

40
local _deprecate_class_funcs = [[
41
  Please explicitly use functions provided by packages by referencing
42
  them in the document class's list of loaded packages rather than the
43
  legacy solution that added non-method functions to the class.]]
153✔
44

45
local _deprecate_exports_table = [[
46
  Please explicitly use functions provided by packages by referencing
47
  them in the document class's list of loaded packages rather than the
48
  legacy solution of calling them from an exports table.]]
153✔
49

50
function package:deprecatedExport (name, _, noclass, notable)
153✔
UNCOV
51
   if not noclass then
×
UNCOV
52
      self.class[name] = function ()
×
UNCOV
53
         SU.deprecated(
×
UNCOV
54
            ("class.%s"):format(name),
×
UNCOV
55
            ("class.packages.%s:%s"):format(self._name, name),
×
56
            "0.14.0",
57
            "0.16.0",
58
            _deprecate_class_funcs
59
         )
60
      end
61
   end
62

UNCOV
63
   if not notable then
×
UNCOV
64
      self.exports[name] = function ()
×
UNCOV
65
         SU.deprecated(
×
UNCOV
66
            ("require('packages.%s').exports.%s"):format(self._name, name),
×
UNCOV
67
            ("class.packages.%s:%s"):format(self._name, name),
×
68
            "0.14.0",
69
            "0.16.0",
70
            _deprecate_exports_table
71
         )
72
      end
73
   end
74
end
75

76
return package
153✔
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

© 2025 Coveralls, Inc