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

sile-typesetter / sile / 6932773445

20 Nov 2023 04:11PM UTC coverage: 60.703% (-1.6%) from 62.266%
6932773445

Pull #1904

github

alerque
feat(utilities): Add Greek alphabetical (non-arithmetic) numbering

Useful in some context such as biblical annotations etc. where greek
characters are used orderly for numbering.
Pull Request #1904: Merge develop into master (commit to next release being breaking)

66 of 193 new or added lines in 19 files covered. (34.2%)

321 existing lines in 26 files now uncovered.

9452 of 15571 relevant lines covered (60.7%)

2104.43 hits per line

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

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

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

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

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

17
local settingDeclarations = { }
28✔
18
local rawhandlerRegistrations = {}
28✔
19
local commandRegistrations = { }
28✔
20

21
function package:_init (_, reload)
28✔
22
  self.class = SILE.scratch.half_initialized_class or SILE.documentState.documentClass
150✔
23
  if not self.class then
150✔
24
    SU.error("Attempted to initialize package before class, should have been queued in the preamble", true)
×
25
  end
26
  self.basedir = script_path()
300✔
27
  -- Note string.format(%p) would be nicer than tostring() but only LuaJIT and Lua 5.4 support it
28
  local settingsDeclarator = tostring(self.declareSettings)
150✔
29
  if reload or not settingDeclarations[settingsDeclarator] then
150✔
30
    settingDeclarations[settingsDeclarator] = true
41✔
31
    self:declareSettings()
41✔
32
  end
33
  local rawhandlerRegistrator = tostring(self.registerRawHandlers)
150✔
34
  if reload or not rawhandlerRegistrations[rawhandlerRegistrator] then
150✔
35
    rawhandlerRegistrations[rawhandlerRegistrator] = true
30✔
36
    self:registerRawHandlers()
30✔
37
  end
38
  local commandRegistrator = tostring(self.registerCommands)
150✔
39
  if reload or not commandRegistrations[commandRegistrator] then
150✔
40
    commandRegistrations[commandRegistrator] = true
141✔
41
    self:registerCommands()
141✔
42
  end
43
end
44

45
function package:_post_init ()
28✔
46
  self._initialized = true
150✔
47
end
48

49
function package.declareSettings (_) end
56✔
50

51
function package.registerRawHandlers (_) end
56✔
52

53
function package:loadPackage (packname, options, reload)
28✔
54
  return self.class:loadPackage(packname, options, reload)
52✔
55
end
56

57
function package:reloadPackage (packname, options)
28✔
NEW
58
  return self.class:reloadPackage(packname, options)
×
59
end
60

61
function package.registerCommands (_) end
32✔
62

63
-- This gives us a hook to match commands with the packages that registered
64
-- them as opposed to core commands or class-provided commands
65
function package:registerCommand (name, func, help, pack)
28✔
66
  self.class:registerCommand(name, func, help, pack)
632✔
67
end
68
function package:registerRawHandler (format, callback)
28✔
69
  self.class:registerRawHandler(format, callback)
2✔
70
end
71

72
-- Using this rather than doing the work directly will give us a way to
73
-- un-export them if we ever need to unload modules and revert functions
74
function package:export (name, func)
28✔
75
  self.class[name] = func
145✔
76
end
77

78
-- Shims for two possible kinds of legacy exports: blind direct stuffing into
79
-- the class but not expecting to be called as a method AND the exports table
80
-- to package modules...
81

82
local _deprecate_class_funcs = [[
83
  Please explicitly use functions provided by packages by referencing
84
  them in the document class's list of loaded packages rather than the
85
  legacy solution that added non-method functions to the class.]]
28✔
86

87
local _deprecate_exports_table = [[
88
  Please explicitly use functions provided by packages by referencing
89
  them in the document class's list of loaded packages rather than the
90
  legacy solution of calling them from an exports table.]]
28✔
91

92
function package:deprecatedExport (name, func, noclass, notable)
28✔
93

94
  if not noclass then
168✔
95
    self.class[name] = function (...)
168✔
96
      -- http://lua-users.org/wiki/VarargTheSecondClassCitizen
97
      local inputs = {...}
2✔
98
      -- local inputs = table.unpack({...}, 1, select("#", ...))
99
      if type(inputs[1]) ~= "table" or inputs[1].type ~= "class" then
2✔
100
        table.insert(inputs, 1, self.class)
×
101
      end
102
      SU.deprecated(("class.%s"):format(name),
4✔
103
                    ("class.packages.%s:%s"):format(self._name, name),
2✔
104
                    "0.14.0", "0.16.0", _deprecate_class_funcs)
2✔
105
      return func(table.unpack(inputs, 1, select("#", ...) + 1))
2✔
106
    end
107
  end
108

109
  if not notable then
168✔
110
    self.exports[name] = function (...)
168✔
111
      local inputs = {...}
×
112
      if type(inputs[1]) ~= "table" or inputs[1].type ~= "package" then
×
113
        table.insert(inputs, 1, self)
×
114
      end
115
      SU.deprecated(("require('packages.%s').exports.%s"):format(self._name, name),
×
116
                    ("class.packages.%s:%s"):format(self._name, name),
×
117
                    "0.14.0", "0.16.0", _deprecate_exports_table)
×
118
      return func(table.unpack(inputs, 1, select("#", ...) + 1))
×
119
    end
120
  end
121

122
end
123

124
return package
28✔
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