Files
LuaCsForBarotraumaEP/docs/templates/ldoc.ltp
2022-08-10 05:36:16 -04:00

139 lines
3.3 KiB
Plaintext

{%
local baseUrl = ldoc.css:gsub("ldoc.css", "")
local repo = "https://github.com/evilfactory/Barotrauma-lua-attempt/"
local pageTitle = mod and (ldoc.display_name(mod) .. " - " .. ldoc.title) or ldoc.title
local oldmarkup = ldoc.markup
function ldoc.markup(text, item)
return oldmarkup(text, item, ldoc.plain)
end
function ldoc.url(path)
return baseUrl .. path
end
function ldoc.realm_icon(realm)
return "<span class=\"realm " .. (realm or "") .. "\"></span>"
end
function ldoc.sidebar_item(item, module)
local text = ""
local deprecated = item.tags.deprecated
if deprecated then
text = text .. "<span class=\"strikethrough\">"
else
text = text .. "<span>"
end
text = text .. ldoc.realm_icon(item.tags.realm[1])
text = text .. "<a href=\""
.. ldoc.ref_to_module(module) .. "#" .. item.name
.. "\">"
if ldoc.is_kind_classmethod(module.kind) then
text = text .. item.name:gsub(".+:", "")
else
text = text .. item.name:gsub(module.name .. ".", "")
end
text = text
.. "</a>"
.. "</span>"
return text
end
function ldoc.item_header(item)
local text = ""
text = text .. "<a class=\"anchor\">"
local deprecated = item.tags.deprecated
if deprecated then
text = text .. "<h1 class=\"strikethrough\">"
else
text = text .. "<h1>"
end
text = text
.. ldoc.realm_icon(item.tags.realm[1])
.. ldoc.display_name(item)
.. "</h1>"
.. "</a>"
return text
end
function ldoc.is_kind_classmethod(kind)
return kind ~= "libraries"
end
function ldoc.repo_reference(item)
return repo .. "tree/master" .. item.file.filename:gsub(item.file.base, "/gamemode") .. "#L" .. item.lineno
end
local function moduleDescription(mod)
if (mod.type == "topic") then
return mod.body:gsub(mod.display_name, ""):gsub("#", ""):sub(1, 256) .. "..."
end
return mod.summary
end
%}
<!DOCTYPE html>
<html lang="en">
<head>
<title>{{pageTitle}}</title>
<meta property="og:type" content="website" />
<meta property="og:title" content="{{pageTitle}}" />
<meta property="og:site_name" content="Lua For Barotrauma Documentation" />
{% if (mod) then %}
<meta property="og:description" content="{{moduleDescription(mod)}}" />
{% else %}
<meta property="og:description" content="A Barotrauma modification that adds Lua modding support." />
{% end %}
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Code+Pro" />
<link rel="stylesheet" href="{* ldoc.css *}" />
<link rel="stylesheet" href="{* ldoc.url('highlight.css') *}" />
</head>
<body>
<main>
{(templates/sidebar.ltp)}
<article>
{% if (ldoc.root) then -- we're rendering the landing page (index.html) %}
{(templates/landing.ltp)}
{% elseif (ldoc.body) then -- we're rendering non-code elements %}
<div class="wrapper">
{* ldoc.body *}
</div>
{% elseif (module) then -- we're rendering libary contents %}
<div class="wrapper">
{(templates/module.ltp)}
</div>
{% end %}
</article>
</main>
<script type="text/javascript" src="{* ldoc.url('app.js') *}"></script>
<script type="text/javascript" src="{* ldoc.url('highlight.min.js') *}"></script>
<script type="text/javascript">
var elements = document.querySelectorAll("pre code")
hljs.configure({
languages: ["lua", ""]
});
for (var i = 0; i < elements.length; i++)
{
hljs.highlightBlock(elements[i]);
}
</script>
</body>
</html>