Модуль:Сущность: различия между версиями

мНет описания правки
Нет описания правки
Строка 124: Строка 124:
                     srcStr = " " .. table.concat(srcParts, " ")
                     srcStr = " " .. table.concat(srcParts, " ")
                 end
                 end
                 return "{{card|" .. mw.text.encode(key) .. "|" .. calls .. srcStr .. "}}"
                 return "{{карточка/Сущность|" .. mw.text.encode(key) .. "|" .. calls .. srcStr .. "}}"
             end
             end
         },
         },
Строка 145: Строка 145:


     local errors = {}
     local errors = {}
     local function processItem(kind, name)
     local function processEntity(kind, name)
         local pathName = lcfirst(name)
         local pathName = lcfirst(name)
         local tplPath = kind .. "/" .. pathName
         local tplPath = kind .. "/" .. pathName
         local content = load_template_content(tplPath)
         local content = load_template_content(tplPath)
         if not content then
         if not content then
             local className = name .. (kind == "component" and "Component" or "Prototype")
             local classType = (kind == "component" and "Component" or "Prototype")
            local className = name .. classType
             local tplLabel = "Template:" .. tplPath
             local tplLabel = "Template:" .. tplPath
             if kind == "component" then
             table.insert(errors,
                table.insert(errors,
                "{{сущность/infobox|тип=" .. classType .. "|название=" .. className .. "|ссылка=" .. tplLabel .. "}}")
                    "Ошибка: сущность имеется не описаный компонент [[" .. tplLabel .. "|" .. className .. "]]")
            else
                table.insert(errors,
                    "Ошибка: сущность содержится в не описанном прототипе [[" .. tplLabel .. "|" .. className .. "]]")
            end
             return
             return
         end
         end
Строка 187: Строка 183:
     for compName, _ in pairs(foundComponents) do table.insert(items, { kind = "component", name = compName }) end
     for compName, _ in pairs(foundComponents) do table.insert(items, { kind = "component", name = compName }) end
     for protoName, _ in pairs(foundPrototypes) do table.insert(items, { kind = "prototype", name = protoName }) end
     for protoName, _ in pairs(foundPrototypes) do table.insert(items, { kind = "prototype", name = protoName }) end
     for _, it in ipairs(items) do processItem(it.kind, it.name) end
     for _, it in ipairs(items) do processEntity(it.kind, it.name) end


     local out = {}
     local out = {}
     for _, e in ipairs(errors) do table.insert(out, "<div class=\"error\">" .. e .. "</div>") end
     for _, e in ipairs(errors) do table.insert(out, e) end
     for _, sw in ipairs(switches) do
     for _, sw in ipairs(switches) do
         local cfg = switchConfigs[sw] or {}
         local cfg = switchConfigs[sw] or {}