Move hooks docs to their own section

This commit is contained in:
peelz
2022-08-03 21:34:42 -04:00
parent 1bb7843811
commit 897466d295
6 changed files with 88 additions and 30 deletions

2
.gitmodules vendored
View File

@@ -3,4 +3,4 @@
url = https://github.com/evilfactory/moonsharp.git url = https://github.com/evilfactory/moonsharp.git
[submodule "luacs-docs/lua/libs/ldoc"] [submodule "luacs-docs/lua/libs/ldoc"]
path = luacs-docs/lua/libs/ldoc path = luacs-docs/lua/libs/ldoc
url = https://github.com/impulsh/LDoc.git url = https://github.com/evilfactory/LDoc.git

View File

@@ -300,6 +300,35 @@ article header.module a {
text-decoration: underline; text-decoration: underline;
} }
article header.section {
color: rgb(255, 255, 255);
background-color: var(--color-accent);
padding: var(--padding-tiny);
margin-top: var(--padding-small);
margin-bottom: 0;
}
article header.section h1 {
padding: 0;
border: 0;
font-size: var(--font-big);
font-weight: 100;
letter-spacing: 2px;
text-transform: uppercase;
}
article header.section h2 {
padding: 0;
margin: 0;
font-size: var(--font-normal);
font-weight: normal;
}
article header.section .section-separator {
margin: var(--padding-tiny) 0;
border-bottom: 1px solid rgba(255, 255, 255, 0.25);
}
details.category > summary { details.category > summary {
list-style: none; list-style: none;
} }

View File

@@ -1,7 +1,7 @@
-- luacheck: ignore 111 -- luacheck: ignore 111
--[[-- --[[--
Hooks are basically functions that get called when events happen in-game, like chat messages. The Hook API allow you to listen to game events and modify the behavior/logic of the game.
]] ]]
-- @code Hook -- @code Hook
-- @pragma nostrip -- @pragma nostrip
@@ -50,6 +50,13 @@ function Hook.Call(eventName, parameters) end
-- end, Hook.HookMethodType.After) -- end, Hook.HookMethodType.After)
function Hook.HookMethod(className, methodName, callback) end function Hook.HookMethod(className, methodName, callback) end
--- Hooks
-- @summary
-- Hooks are functions that get called when events happen in-game, e.g. chat messages.
--
-- These can be used with `Hook.Add` and `Hook.Call`.
-- @section hook
--- Game's fixed update rate, gets called normally 60 times a second. --- Game's fixed update rate, gets called normally 60 times a second.
-- @realm shared -- @realm shared
function think() end function think() end
@@ -248,4 +255,4 @@ function human.CPRSuccess(animController) end
--- Called after the CPR skill check fails. --- Called after the CPR skill check fails.
-- @realm shared -- @realm shared
function human.CPRFailed(animController) end function human.CPRFailed(animController) end

View File

@@ -9,7 +9,7 @@
{% {%
local kinds = {} local kinds = {}
local kindsIpairs = {} local kindsIpairs = {}
for kind, items in mod.kinds() do for kind, items, _, summary in mod.kinds() do
local name = kind local name = kind
if kind == "Tables" then if kind == "Tables" then
name = "Fields" name = "Fields"
@@ -21,6 +21,7 @@
local value = {} local value = {}
value.kind = name value.kind = name
value.summary = summary
value.items = kinds[name] value.items = kinds[name]
table.insert(kindsIpairs, value) table.insert(kindsIpairs, value)
end end
@@ -33,9 +34,16 @@
{% for i, value in ipairs(kindsIpairs) do {% for i, value in ipairs(kindsIpairs) do
local kind = value.kind local kind = value.kind
local summary = value.summary
local items = value.items local items = value.items
%} %}
<h1 class="title">{{kind}}</h1> <header class="section">
<h1>{{kind}}</h1>
{% if summary ~= nil then %}
<div class="section-separator"></div>
<h2>{* ldoc.markup(summary) *}</h2>
{% end %}
</header>
{% for item, _ in pairs(items) do %} {% for item, _ in pairs(items) do %}
<section class="method" id="{{item.name}}"> <section class="method" id="{{item.name}}">

View File

@@ -3,6 +3,26 @@
local function isKindExpandable(kind) local function isKindExpandable(kind)
return kind ~= "Manual" return kind ~= "Manual"
end end
local function isSectionEmpty(mod, sections)
if type(sections) == "table" then
for _, v in pairs(mod.items) do
for _, section in pairs(sections) do
if v.section_id == section then
return false
end
end
end
else
local section = sections
for _, v in pairs(mod.items) do
if v.section_id == section then
return false
end
end
end
return true
end
%} %}
<nav> <nav>
@@ -40,48 +60,42 @@ end
end) end)
end %} end %}
{% {% if not isSectionEmpty(currentMod, "function") then %}
local isThereFunctions = false
for k, v in pairs(currentMod.items) do
if (v.kind == "functions") then
isThereFunctions = true
break
end
end
%}
{% if isThereFunctions then %}
<li> <li>
<label class="colorful-label">FUNCTIONS</label> <label class="colorful-label">FUNCTIONS</label>
</li> </li>
{% end %} {% end %}
{% for k, v in pairs(currentMod.items) do %} {% for k, v in pairs(currentMod.items) do %}
{% if (v.kind == "functions") then %} {% if (v.section_id == "function") then %}
<li> <li>
{* ldoc.sidebar_item(v, currentMod) *} {* ldoc.sidebar_item(v, currentMod) *}
</li> </li>
{% end %} {% end %}
{% end %} {% end %}
{% {% if not isSectionEmpty(currentMod, {"field", "table"}) then %}
local isThereFields = false
for k, v in pairs(currentMod.items) do
if (v.kind == "fields" or v.kind == "tables") then
isThereFields = true
break
end
end
%}
{% if isThereFields then %}
<li> <li>
<label class="colorful-label">FIELDS</label> <label class="colorful-label">FIELDS</label>
</li> </li>
{% end %} {% end %}
{% for k, v in pairs(currentMod.items) do %} {% for k, v in pairs(currentMod.items) do %}
{% if (v.kind == "fields" or v.kind == "tables") then %} {% if (v.section_id == "field" or v.section_id == "table") then %}
<li>
{* ldoc.sidebar_item(v, currentMod) *}
</li>
{% end %}
{% end %}
{% if not isSectionEmpty(currentMod, "hook") then %}
<li>
<label class="colorful-label">HOOKS</label>
</li>
{% end %}
{% for k, v in pairs(currentMod.items) do %}
{% if (v.section_id == "hook") then %}
<li> <li>
{* ldoc.sidebar_item(v, currentMod) *} {* ldoc.sidebar_item(v, currentMod) *}
</li> </li>