Clean up lua docs scripts

- ldoc is now a git submodule
- ldoc can be installed using scripts/install.{sh,ps1}
- lua docs can be build using scripts/build.{sh,ps1}
- all lua docs-related files now reside inside of the docs folder
This commit is contained in:
peelz
2022-08-03 21:34:41 -04:00
parent 9a621237f0
commit 5d11c28db6
15 changed files with 178 additions and 46 deletions
+2
View File
@@ -0,0 +1,2 @@
html
lua_modules
-5
View File
@@ -1,5 +0,0 @@
xcopy css html /Y
xcopy js html /Y
cd ..
lua B:\programming\lua\LDoc\ldoc.lua .
cd docs
+79
View File
@@ -0,0 +1,79 @@
-- vim:ft=lua
file = {
"lua"
}
module_file = {}
dir = "html"
project = "LuaForBarotrauma"
title = "LuaForBarotrauma Documentation"
no_space_before_args = true
style = "css"
template = "templates"
format = "markdown"
ignore = true
topics = "manual"
use_markdown_titles = true
kind_names = {
topic = "Manual",
module = "Classes"
}
merge = true
sort = true
sort_modules = true
simple_args_string = true -- we show optionals/defaults outside of the display name
strip_metamethod_prefix = true -- remove the name of the table when displaying metamethod names
no_viewed_topic_at_top = true -- don't put the currently viewed topic at the top
use_new_templates = true -- new templating system
pretty_urls = true -- avoid showing .html in urls
pretty_topic_names = true -- strips extension from manual filenames, this does not check filename collisions
custom_tags = {
{"realm", hidden = true},
{"internal", hidden = true}
}
custom_display_name_handler = function(item, default_handler)
if (item.type == "function" and item.module) then
if (item.module.type == "classmod" or item.module.type == "panel") then
return item.module.mod_name .. ":" .. default_handler(item)
elseif (item.module.type == "hooks") then
return item.module.mod_name:upper() .. ":" .. default_handler(item)
end
end
return default_handler(item)
end
new_type("code", "Code", true)
new_type("enum", "Enum", true)
tparam_alias("Client", "client")
tparam_alias("Character", "character")
tparam_alias("Submarine", "submarine")
tparam_alias("Item", "item")
tparam_alias("ItemPrefab", "ItemPrefab")
tparam_alias("Vector2", "Vector2")
tparam_alias("Vector3", "Vector3")
tparam_alias("Vector4", "Vector4")
tparam_alias("CauseOfDeath", "CauseOfDeath")
tparam_alias("PhysicsBody", "PhysicsBody")
tparam_alias("JobPrefab", "JobPrefab")
tparam_alias("Job", "Job")
tparam_alias("Inventory", "Inventory")
tparam_alias("CharacterInventory", "CharacterInventory")
tparam_alias("ItemInventory", "ItemInventory")
tparam_alias("Camera", "Camera")
tparam_alias("Enumerable", "Enumerable")
tparam_alias("Identifier", "Identifier")
tparam_alias("CharacterHealth", "CharacterHealth")
tparam_alias("string", "string")
tparam_alias("bool", "boolean")
tparam_alias("function", "function")
tparam_alias("tab", "table")
-1
View File
@@ -1 +0,0 @@
py -m http.server -d html
+1
Submodule docs/libs/ldoc added at 69ef8c976e
+17
View File
@@ -0,0 +1,17 @@
try {
cd $PSScriptRoot/..
Remove-Item -Force -Recurse ./html | Out-Null
New-Item -ItemType Directory ./html | Out-Null
Copy-Item -Path ./css/. -Destination ./html -Recurse -Force | Out-Null
Copy-Item -Path ./js/. -Destination ./html -Recurse -Force | Out-Null
if ((Get-Command "lua_modules/bin/ldoc" -ErrorAction SilentlyContinue) -eq $null) {
echo "ldoc not found; please run docs/scripts/install.ps1"
exit 1
}
lua_modules/bin/ldoc .
} finally {
popd
}
+19
View File
@@ -0,0 +1,19 @@
#!/usr/bin/env bash
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
cd "$DIR/.."
ldoc_path=./lua_modules/bin/ldoc
if [[ ! -x "$ldoc_path" ]]; then
echo "ldoc not found; please run docs/scripts/install.sh"
exit 1
fi
rm -rf ./html
mkdir ./html
cp -r ./js/. ./html
cp -r ./css/. ./html
"$ldoc_path" .
+41
View File
@@ -0,0 +1,41 @@
try {
cd $PSScriptRoot/..
$lua_binary = $env:LUA_BINARY
if ($lua_binary -eq $null) {
$lua_binary = "lua"
}
if ((Get-Command "$lua_binary" -ErrorAction SilentlyContinue) -eq $null) {
if ($env:LUA_BINARY -eq $null) {
echo "lua binary not found; please set `$LUA_BINARY manually."
} else {
echo "lua binary not found: $lua_binary"
}
exit 1
}
if ((Get-Command "luarocks" -ErrorAction SilentlyContinue) -eq $null) {
echo "luarocks not found"
exit 1
}
$lua_version = (Invoke-Expression -Command "& $lua_binary -v 2>&1") -Replace '^Lua (\d+)\.(\d+).*$','$1.$2'
echo "Detected lua version $lua_version"
$luarocks_args=@(
"--tree",
"$(Get-Location)/lua_modules",
"--lua-version",
"$lua_version"
)
try {
cd ./libs/ldoc
luarocks @luarocks_args make
} finally {
popd
}
} finally {
popd
}
+39
View File
@@ -0,0 +1,39 @@
#!/usr/bin/env bash
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
cd "$DIR/.."
lua_binary="${LUA_BINARY:-lua}"
if ! command -v "$lua_binary" &> /dev/null; then
if [[ -z "${LUA_BINARY+x}" ]]; then
echo "lua binary not found; please set \$LUA_BINARY manually."
else
echo "lua binary not found: $lua_binary"
fi
exit 1
fi
if ! command -v "$lua_binary" &> /dev/null; then
echo "luarocks not found"
exit 1
fi
lua_version="$("$lua_binary" -v | grep -Po '^Lua \K(\d+)\.(\d+)')"
echo "Detected lua version $lua_version"
# Install dependencies (npm style)
# NOTE: you need to have lua header files installed.
# On debian-based distros: apt install libluaX.X-dev
luarocks_args=(
"--tree"
"$PWD/lua_modules"
"--lua-version"
"$lua_version"
)
(
cd libs/ldoc
luarocks ${luarocks_args[@]} make
)
+12
View File
@@ -0,0 +1,12 @@
try {
cd $PSScriptRoot/..
if ((Get-Command "python3" -ErrorAction SilentlyContinue) -eq $null) {
echo "python3 not found"
exit 1
}
python3 -m http.server -d html
} finally {
popd
}
+11
View File
@@ -0,0 +1,11 @@
#!/usr/bin/env bash
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
cd "$DIR/.."
if ! command -v "python3" &> /dev/null; then
echo "python3 not found"
exit 1
fi
python3 -m http.server -d html
+3 -3
View File
@@ -55,18 +55,18 @@ end
<body>
<main>
{(docs/templates/sidebar.ltp)}
{(templates/sidebar.ltp)}
<article>
{% if (ldoc.root) then -- we're rendering the landing page (index.html) %}
{(docs/templates/landing.ltp)}
{(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">
{(docs/templates/module.ltp)}
{(templates/module.ltp)}
</div>
{% end %}
</article>