Skip to content
This repository was archived by the owner on Jun 6, 2025. It is now read-only.

Commit eeada43

Browse files
committed
Add basic docs website
1 parent 0fba348 commit eeada43

18 files changed

+131
-13
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.vscode
22
./*.code-workspace
33
*.code-workspace
4-
flib-docs/
4+
doc-html/
55
NOTES.txt
66
workspace.html
77
faketorio

bounding-box.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ local position = require("__flib__/position")
33
--- Utilities for manipulating bounding boxes. All functions support both the shorthand and explicit syntaxes for boxes
44
--- and positions, and will preserve the syntax that was passed in. Boxes are considered immutable; all functions will
55
--- return new boxes.
6+
--- ```lua
7+
--- local flib_bounding_box = require("__flib__/bounding-box")
8+
--- ```
69
--- @class flib_bounding_box
710
local flib_bounding_box = {}
811

data-util.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
--- Utilities for data stage prototype manipulation.
2+
--- ```lua
3+
--- local flib_data_util = require("__flib__/data-util")
4+
--- ```
25
--- @class flib_data_util
36
local flib_data_util = {}
47

dictionary-lite.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ local mod_gui = require("__core__/lualib/mod-gui")
33
local table = require("__flib__/table")
44

55
--- Utilities for creating dictionaries of localised string translations.
6+
--- ```lua
7+
--- local flib_dictionary = require("__flib__/dictionary-lite")
8+
--- ```
69
--- @class flib_dictionary
710
local flib_dictionary = {}
811

direction.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
local flib_math = require("__flib__/math")
22

33
--- Functions for working with directions.
4+
--- ```lua
5+
--- local flib_direction = require("__flib__/direction")
6+
--- ```
47
--- @class flib_direction
58
local flib_direction = {}
69

docs/index.html

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<link rel="stylesheet" href="style.css">
5+
<title>flib documentation</title>
6+
</head>
7+
<body>
8+
<h1>Factorio Library documentation</h1>
9+
<p>This documentation is auto-generated by the Lua language server.
10+
These docs are greatly unpolished and lack any quality of life features
11+
whatsoever. This site will be replaced with a custom implementation in the
12+
future.</p>
13+
<nav>
14+
<a href="https://github.com/factoriolib/flib">GitHub</a>
15+
<a href="https://mods.factorio.com/mod/flib">Mod portal</a>
16+
</nav>
17+
{{docs}}
18+
</body>
19+
</html>

docs/style.css

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
title { display: none }
2+
3+
body {
4+
background-color: #282828;
5+
color: #fff;
6+
font-family: sans-serif;
7+
margin: 0 auto;
8+
max-width: 1200px;
9+
padding: 1rem;
10+
width: auto;
11+
}
12+
13+
h1 {
14+
font-size: 1.5rem;
15+
color: #ffe6c0;
16+
}
17+
18+
h2 {
19+
font-size: 1.2rem;
20+
}
21+
22+
h3 {
23+
font-size: 1rem;
24+
font-weight: 800;
25+
}
26+
27+
pre {
28+
background-color: #353535;
29+
padding: 0.5rem;
30+
overflow: scroll;
31+
font-family: monospace;
32+
}
33+
34+
a {
35+
color: #ff9f1c;
36+
}
37+
38+
nav a {
39+
margin: 0 1rem;
40+
}

format.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
--- Various string formatting functions.
2+
--- ```lua
3+
--- local flib_format = require("__flib__/format")
4+
--- ```
25
--- @class flib_format
36
local flib_format = {}
47

gen-docs.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
if [ -d doc-html ]; then
6+
rm -rf doc-html
7+
fi
8+
mkdir doc-html
9+
10+
docs=$(cmark < $(lua-language-server --doc=. | awk -F ] '/Markdown/ { print $1 }' | awk '{ print substr($2, 2, length($2)) }'))
11+
cat docs/index.html \
12+
| awk -v docs="$docs" '
13+
{ flag = 1 }
14+
/{{docs}}/ { flag = 0; print docs }
15+
flag { print }
16+
' > doc-html/index.html
17+
cp docs/style.css doc-html/style.css

gui-lite.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
--- Utilities for building GUIs and handling GUI events.
2+
--- ```lua
3+
--- local flib_gui = require("__flib__/gui-lite")
4+
--- ```
25
--- @class flib_gui
36
local flib_gui = {}
47

0 commit comments

Comments
 (0)