Skip to content

Commit

Permalink
change from Html to string
Browse files Browse the repository at this point in the history
  • Loading branch information
Rathoz committed Sep 11, 2024
1 parent 5190d26 commit f1d44a8
Show file tree
Hide file tree
Showing 16 changed files with 33 additions and 33 deletions.
4 changes: 2 additions & 2 deletions components/widget/widget.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ function Widget:assertExistsAndCopy(value)
end

---@param injector WidgetInjector?
---@return Widget[]|Html|nil
---@return Widget[]|string|nil
function Widget:make(injector)
error('A Widget must override the make() function!')
end

---@param injector WidgetInjector?
---@return Widget[]|Html|nil
---@return Widget[]|string|nil
function Widget:tryMake(injector)
return Logic.tryOrElseLog(
function() return self:make(injector) end,
Expand Down
4 changes: 2 additions & 2 deletions components/widget/widget_breakdown.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ local Breakdown = Class.new(
)

---@param injector WidgetInjector?
---@return Html?
---@return string?
function Breakdown:make(injector)
return Breakdown:_breakdown(self.contents, self.classes, self.contentClasses)
return tostring(Breakdown:_breakdown(self.contents, self.classes, self.contentClasses))
end

---@param contents (string|number)[]
Expand Down
4 changes: 2 additions & 2 deletions components/widget/widget_builder.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ local Builder = Class.new(
)

---@param injector WidgetInjector?
---@return Html
---@return string
function Builder:make(injector)
local children = self.builder()
local builtChildren = mw.html.create()
for _, child in ipairs(children or {}) do
builtChildren:node(WidgetFactory.work(child, injector))
end
return builtChildren
return tostring(builtChildren)
end

return Builder
6 changes: 3 additions & 3 deletions components/widget/widget_cell.lua
Original file line number Diff line number Diff line change
Expand Up @@ -90,19 +90,19 @@ function Cell:_content(...)
end

---@param injector WidgetInjector?
---@return Html?
---@return string?
function Cell:make(injector)
self:_new(self.name)
self:_class(unpack(self.classes or {}))
self:_content(unpack(self.content))

if self.contentDiv == nil then
return {}
return
end

self.root :node(self.description)
:node(self.contentDiv)
return self.root
return tostring(self.root)
end

return Cell
4 changes: 2 additions & 2 deletions components/widget/widget_center.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ local Center = Class.new(
)

---@param injector WidgetInjector?
---@return Html?
---@return string?
function Center:make(injector)
return Center:_create(self.content, self.classes)
return tostring(Center:_create(self.content, self.classes))
end

---@param content (string|number)[]
Expand Down
4 changes: 2 additions & 2 deletions components/widget/widget_chronology.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ local Chronology = Class.new(
)

---@param injector WidgetInjector?
---@return Html?
---@return string?
function Chronology:make(injector)
return Chronology:_chronology(self.links)
return tostring(Chronology:_chronology(self.links))
end

---@param links table<string, string|number|nil>
Expand Down
4 changes: 2 additions & 2 deletions components/widget/widget_header.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ local Header = Class.new(
)

---@param injector WidgetInjector?
---@return Html[]
---@return string
function Header:make(injector)
local header = {
Header:_name(self.name),
Expand All @@ -63,7 +63,7 @@ function Header:make(injector)
for _, element in ipairs(header) do
wrapper:node(element)
end
return wrapper
return tostring(wrapper)
end

---@param name string?
Expand Down
4 changes: 2 additions & 2 deletions components/widget/widget_highlights.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ local Highlights = Class.new(
)

---@param injector WidgetInjector?
---@return Html?
---@return string?
function Highlights:make(injector)
return Highlights:_highlights(self.list)
return tostring(Highlights:_highlights(self.list))
end

---@param list (string|number)[]?
Expand Down
4 changes: 2 additions & 2 deletions components/widget/widget_links.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ local Links = Class.new(
local PRIORITY_GROUPS = Lua.import('Module:Links/PriorityGroups', {loadData = true})

---@param injector WidgetInjector?
---@return Html?
---@return string?
function Links:make(injector)
local infoboxLinks = mw.html.create('div')
infoboxLinks :addClass('infobox-center')
Expand Down Expand Up @@ -56,7 +56,7 @@ function Links:make(injector)
infoboxLinks:wikitext(' ' .. self:_makeLink(key, value))
end

return mw.html.create('div'):node(infoboxLinks)
return tostring(mw.html.create('div'):node(infoboxLinks))
end

---@param key string
Expand Down
4 changes: 2 additions & 2 deletions components/widget/widget_table.lua
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function Table:addClass(class)
end

---@param injector WidgetInjector?
---@return Html?
---@return string?
function Table:make(injector)
local displayTable = mw.html.create('div'):addClass('csstable-widget')
displayTable:css{
Expand All @@ -67,7 +67,7 @@ function Table:make(injector)
displayTable:node(WidgetFactory.work(row, injector))
end

return displayTable
return tostring(displayTable)
end

---@return integer?
Expand Down
4 changes: 2 additions & 2 deletions components/widget/widget_table_cell.lua
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function TableCell:addCss(key, value)
end

---@param injector WidgetInjector?
---@return Html?
---@return string?
function TableCell:make(injector)
local cell = mw.html.create('div'):addClass('csstable-widget-cell')
cell:css{
Expand All @@ -73,7 +73,7 @@ function TableCell:make(injector)

cell:node(self:_concatContent())

return cell
return tostring(cell)
end

---@return string
Expand Down
4 changes: 2 additions & 2 deletions components/widget/widget_table_cell_new.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ local TableCell = Class.new(
)

---@param injector WidgetInjector?
---@return Html?
---@return string?
function TableCell:make(injector)
local cell = mw.html.create(self.isHeader and 'th' or 'td')
cell:attr('colspan', self.colSpan)
Expand All @@ -55,7 +55,7 @@ function TableCell:make(injector)

cell:node(self:_content())

return cell
return tostring(cell)
end

---@return string
Expand Down
4 changes: 2 additions & 2 deletions components/widget/widget_table_new.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ local Table = Class.new(
)

---@param injector WidgetInjector?
---@return Html?
---@return string?
function Table:make(injector)
local wrapper = mw.html.create('div'):addClass('table-responsive')
local output = mw.html.create('table'):addClass('wikitable')
Expand All @@ -48,7 +48,7 @@ function Table:make(injector)
end)

wrapper:node(output)
return wrapper
return tostring(wrapper)
end

return Table
4 changes: 2 additions & 2 deletions components/widget/widget_table_row.lua
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function TableRow:getCellCount()
end

---@param injector WidgetInjector?
---@return Html?
---@return string?
function TableRow:make(injector)
local row = mw.html.create('div'):addClass('csstable-widget-row')

Expand All @@ -73,7 +73,7 @@ function TableRow:make(injector)
row:node(WidgetFactory.work(cell, injector))
end

return row
return tostring(row)
end

return TableRow
4 changes: 2 additions & 2 deletions components/widget/widget_table_row_new.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ local TableRow = Class.new(
)

---@param injector WidgetInjector?
---@return Html?
---@return string?
function TableRow:make(injector)
local row = mw.html.create('tr')

Expand All @@ -46,7 +46,7 @@ function TableRow:make(injector)
row:node(WidgetFactory.work(child, injector))
end)

return row
return tostring(row)
end

return TableRow
4 changes: 2 additions & 2 deletions components/widget/widget_title.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ local Title = Class.new(
)

---@param injector WidgetInjector?
---@return Html?
---@return string?
function Title:make(injector)
return Title:_create(self.content)
return tostring(Title:_create(self.content))
end

---@param infoDescription string|number|nil
Expand Down

0 comments on commit f1d44a8

Please sign in to comment.