From f1d44a850e06773ac3ab4306b8fd1280499690ef Mon Sep 17 00:00:00 2001 From: Rikard Blixt Date: Wed, 11 Sep 2024 17:34:57 +0200 Subject: [PATCH] change from `Html` to `string` --- components/widget/widget.lua | 4 ++-- components/widget/widget_breakdown.lua | 4 ++-- components/widget/widget_builder.lua | 4 ++-- components/widget/widget_cell.lua | 6 +++--- components/widget/widget_center.lua | 4 ++-- components/widget/widget_chronology.lua | 4 ++-- components/widget/widget_header.lua | 4 ++-- components/widget/widget_highlights.lua | 4 ++-- components/widget/widget_links.lua | 4 ++-- components/widget/widget_table.lua | 4 ++-- components/widget/widget_table_cell.lua | 4 ++-- components/widget/widget_table_cell_new.lua | 4 ++-- components/widget/widget_table_new.lua | 4 ++-- components/widget/widget_table_row.lua | 4 ++-- components/widget/widget_table_row_new.lua | 4 ++-- components/widget/widget_title.lua | 4 ++-- 16 files changed, 33 insertions(+), 33 deletions(-) diff --git a/components/widget/widget.lua b/components/widget/widget.lua index 9d8be39fe26..146f41315dc 100644 --- a/components/widget/widget.lua +++ b/components/widget/widget.lua @@ -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, diff --git a/components/widget/widget_breakdown.lua b/components/widget/widget_breakdown.lua index 07178309d76..4d4b8874666 100644 --- a/components/widget/widget_breakdown.lua +++ b/components/widget/widget_breakdown.lua @@ -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)[] diff --git a/components/widget/widget_builder.lua b/components/widget/widget_builder.lua index 6ea20ddb472..0fb0f8d8fa2 100644 --- a/components/widget/widget_builder.lua +++ b/components/widget/widget_builder.lua @@ -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 diff --git a/components/widget/widget_cell.lua b/components/widget/widget_cell.lua index 83e15578ba3..f598100bf79 100644 --- a/components/widget/widget_cell.lua +++ b/components/widget/widget_cell.lua @@ -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 diff --git a/components/widget/widget_center.lua b/components/widget/widget_center.lua index 7b81449d8c0..6247b1d5af0 100644 --- a/components/widget/widget_center.lua +++ b/components/widget/widget_center.lua @@ -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)[] diff --git a/components/widget/widget_chronology.lua b/components/widget/widget_chronology.lua index 3f99dc57939..0fd0e436def 100644 --- a/components/widget/widget_chronology.lua +++ b/components/widget/widget_chronology.lua @@ -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 diff --git a/components/widget/widget_header.lua b/components/widget/widget_header.lua index bd3959fc269..4a0dfb73432 100644 --- a/components/widget/widget_header.lua +++ b/components/widget/widget_header.lua @@ -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), @@ -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? diff --git a/components/widget/widget_highlights.lua b/components/widget/widget_highlights.lua index ce50100e0fa..89dc7a51e68 100644 --- a/components/widget/widget_highlights.lua +++ b/components/widget/widget_highlights.lua @@ -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)[]? diff --git a/components/widget/widget_links.lua b/components/widget/widget_links.lua index 7541947e4bf..80cb8f14a93 100644 --- a/components/widget/widget_links.lua +++ b/components/widget/widget_links.lua @@ -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') @@ -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 diff --git a/components/widget/widget_table.lua b/components/widget/widget_table.lua index ca982ae542e..832d2b50b2a 100644 --- a/components/widget/widget_table.lua +++ b/components/widget/widget_table.lua @@ -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{ @@ -67,7 +67,7 @@ function Table:make(injector) displayTable:node(WidgetFactory.work(row, injector)) end - return displayTable + return tostring(displayTable) end ---@return integer? diff --git a/components/widget/widget_table_cell.lua b/components/widget/widget_table_cell.lua index d3b410349d4..dcec7ccbc9a 100644 --- a/components/widget/widget_table_cell.lua +++ b/components/widget/widget_table_cell.lua @@ -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{ @@ -73,7 +73,7 @@ function TableCell:make(injector) cell:node(self:_concatContent()) - return cell + return tostring(cell) end ---@return string diff --git a/components/widget/widget_table_cell_new.lua b/components/widget/widget_table_cell_new.lua index 16206fd3517..809dbac43e1 100644 --- a/components/widget/widget_table_cell_new.lua +++ b/components/widget/widget_table_cell_new.lua @@ -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) @@ -55,7 +55,7 @@ function TableCell:make(injector) cell:node(self:_content()) - return cell + return tostring(cell) end ---@return string diff --git a/components/widget/widget_table_new.lua b/components/widget/widget_table_new.lua index 23dbcb3ec6a..3e8bca8e6c8 100644 --- a/components/widget/widget_table_new.lua +++ b/components/widget/widget_table_new.lua @@ -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') @@ -48,7 +48,7 @@ function Table:make(injector) end) wrapper:node(output) - return wrapper + return tostring(wrapper) end return Table diff --git a/components/widget/widget_table_row.lua b/components/widget/widget_table_row.lua index dbafaddb562..fc194699d53 100644 --- a/components/widget/widget_table_row.lua +++ b/components/widget/widget_table_row.lua @@ -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') @@ -73,7 +73,7 @@ function TableRow:make(injector) row:node(WidgetFactory.work(cell, injector)) end - return row + return tostring(row) end return TableRow diff --git a/components/widget/widget_table_row_new.lua b/components/widget/widget_table_row_new.lua index 1c5ea278187..e8f015d9e38 100644 --- a/components/widget/widget_table_row_new.lua +++ b/components/widget/widget_table_row_new.lua @@ -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') @@ -46,7 +46,7 @@ function TableRow:make(injector) row:node(WidgetFactory.work(child, injector)) end) - return row + return tostring(row) end return TableRow diff --git a/components/widget/widget_title.lua b/components/widget/widget_title.lua index 3454a083fd6..048368d0acd 100644 --- a/components/widget/widget_title.lua +++ b/components/widget/widget_title.lua @@ -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