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

sile-typesetter / sile / 15507594683

07 Jun 2025 11:54AM UTC coverage: 30.951% (-30.4%) from 61.309%
15507594683

push

github

alerque
chore(tooling): Add post-checkout hook to clear makedeps on branch switch

6363 of 20558 relevant lines covered (30.95%)

3445.44 hits per line

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

92.86
/types/module.lua
1
local module = pl.class()
20✔
2

3
module._name = "base"
20✔
4

5
module._initialized = false
20✔
6

7
-- A list (ordered) of methods to run on initialization, but we also track which function signatures have been run
8
-- already in this table per module type so we don't duplicate or clobber things that have been done. Since we're
9
-- tracknig the Lua function hash not the method name this shouldn't catch overridden methods.
10
local run_once = {
20✔
11
   "_declareOptions",
12
   "declareOptions",
13
   "_declareSettings",
14
   "declareSettings",
15
   "_registerRawHandlers",
16
   "registerRawHandlers",
17
   "_registerCommands",
18
   "registerCommands",
19
   "_setOptions",
20
   "setOptions",
21
}
22

23
local function script_path ()
24
   local src = debug.getinfo(3, "S").source:sub(2)
299✔
25
   local base = src:match("(.*[/\\])")
299✔
26
   return base
299✔
27
end
28

29
function module:_init (options)
20✔
30
   self.commands = SILE.commands:forModule(self)
897✔
31
   self.settings = SILE.settings:forModule(self)
897✔
32
   if not self.type then
299✔
33
      SU.error("Attempted it initialize module with no type")
×
34
   end
35
   -- Avoid direct use of base modules intended as prototypes
36
   if self._name == "base" then
299✔
37
      local type_group = "SILE." .. self.type .. "s"
×
38
      SU.deprecated(type_group .. ".base", type_group .. ".default", "0.15.11", "0.16.0")
×
39
   end
40
   -- Ease access to assets relative to module
41
   self.basedir = script_path()
598✔
42
   for _, method in ipairs(run_once) do
3,289✔
43
      -- Note string.format(%p) would be nicer than tostring() but only LuaJIT and Lua 5.4 support it
44
      local method_hash = tostring(self[method]) .. self.type
2,990✔
45
      SU.debug("modules", self.type, self._name, method, run_once[method_hash] and "(skip)")
2,990✔
46
      if not run_once[method_hash] then
2,990✔
47
         run_once[method_hash] = true
1,275✔
48
         if method:match("Options$") then
1,275✔
49
            self[method](self, options)
968✔
50
         else
51
            self[method](self)
791✔
52
         end
53
      end
54
   end
55
end
56

57
function module:_post_init ()
20✔
58
   self._initialized = true
299✔
59
end
60

61
function module:_declareOptions () end
130✔
62
function module:declareOptions () end
130✔
63

64
function module:_declareSettings () end
75✔
65
function module:declareSettings () end
119✔
66

67
function module:_registerRawHandlers () end
130✔
68
function module:registerRawHandlers () end
141✔
69

70
function module:registerRawHandler (format, callback)
20✔
71
   SILE.rawHandlers[format] = callback
14✔
72
end
73

74
function module:_registerCommands () end
97✔
75
function module:registerCommands () end
122✔
76

77
--- Register a function as a SILE command.
78
-- Takes any Lua function and registers it for use as a SILE command (which will in turn be used to process any content
79
-- nodes identified with the command name.
80
--
81
-- @tparam string name Name of cammand to register.
82
-- @tparam function func Callback function to use as command handler.
83
-- @tparam[opt] nil|string help User friendly short usage string for use in error messages, documentation, etc.
84
-- @tparam[opt] nil|string pack Information identifying the module registering the command for use in error and usage
85
-- messages. Usually auto-detected.
86
function module:registerCommand (name, func, help, pack, defaults)
20✔
87
   SU.deprecated("module:registerCommand", "module.commands:register", "0.16.0", "0.17.0")
568✔
88
   return self.commands:register(name, func, help, pack, defaults)
1,136✔
89
end
90

91
function module:_setOptions () end
130✔
92
function module:setOptions () end
141✔
93

94
return module
20✔
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