auto doc gen

This commit is contained in:
Michael Freno
2025-11-15 11:29:44 -05:00
parent 3861a5f472
commit 4142b7e831
7 changed files with 249173 additions and 0 deletions

25
.luarc.json Normal file
View File

@@ -0,0 +1,25 @@
{
"runtime": {
"version": "LuaJIT"
},
"workspace": {
"library": [
"${3rd}/love2d/library"
],
"ignoreDir": [
"testing",
"examples",
".git",
"tasks",
"themes"
],
"ignoreSubmodules": true
},
"diagnostics": {
"globals": ["love"]
},
"doc": {
"privateName": ["_.*"],
"protectedName": []
}
}

35
config.ld Normal file
View File

@@ -0,0 +1,35 @@
-- LDoc configuration for FlexLöve
project = 'FlexLöve'
title = 'FlexLöve Documentation'
description = 'UI Library for LÖVE Framework based on flexbox'
format = 'discount' -- Use markdown formatting
-- Source files and directories
file = 'modules/'
-- Output directory
dir = 'docs'
-- Documentation options
all = false -- Don't document private (_prefixed) items by default
boilerplate = false -- Don't include boilerplate
not_luadoc = true -- Allow non-standard annotations
no_return_or_parms = true -- More lenient with params/returns
no_summary = true -- Don't require summary
-- README file to include as index
readme = 'README.md'
-- Sort items alphabetically
sort = true
-- Show function signatures
pretty = 'lua'
-- Topics
topics = {
'README.md',
}
-- Use full names
full_description = true

69
docs/README.md Normal file
View File

@@ -0,0 +1,69 @@
# FlexLöve Documentation
This directory contains auto-generated API documentation from LuaLS annotations.
## Files
- **index.html** - GitHub Pages landing page
- **doc.md** - Markdown API reference (47,000+ lines)
- **doc.json** - JSON API reference for tooling (11MB)
## Regenerating Documentation
To regenerate the documentation after making changes:
```bash
./generate_docs.sh
```
Or manually:
```bash
lua-language-server --doc=. --doc_out_path=./docs
```
## Viewing Locally
Open `index.html` in your browser:
```bash
open docs/index.html # macOS
xdg-open docs/index.html # Linux
start docs/index.html # Windows
```
## Publishing to GitHub Pages
1. Commit the docs/ directory:
```bash
git add docs/
git commit -m "Update documentation"
git push
```
2. Enable GitHub Pages in repository settings:
- Go to Settings > Pages
- Source: Deploy from a branch
- Branch: `main` (or your default branch)
- Folder: `/docs`
- Save
3. Your documentation will be available at:
`https://[username].github.io/[repository]/`
## Documentation Format
The documentation is generated from LuaLS (Lua Language Server) annotations using the `lua-language-server` CLI tool. This ensures 100% compatibility with your IDE autocomplete and type checking.
### Supported Annotations
- `---@class` - Class definitions
- `---@field` - Class fields
- `---@param` - Function parameters
- `---@return` - Return values
- `---@type` - Variable types
- And all other LuaLS annotations
## Requirements
- lua-language-server (install via `brew install lua-language-server` on macOS)

200993
docs/doc.json Normal file

File diff suppressed because one or more lines are too long

47809
docs/doc.md Normal file

File diff suppressed because it is too large Load Diff

202
docs/index.html Normal file
View File

@@ -0,0 +1,202 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>FlexLöve Documentation</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/github-markdown-css@5/github-markdown.min.css">
<style>
body {
margin: 0;
padding: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans', Helvetica, Arial, sans-serif;
background-color: #0d1117;
color: #c9d1d9;
}
.container {
max-width: 1200px;
margin: 0 auto;
padding: 2rem;
}
.header {
text-align: center;
padding: 3rem 0;
border-bottom: 1px solid #30363d;
}
.header h1 {
font-size: 3rem;
margin: 0;
background: linear-gradient(45deg, #58a6ff, #79c0ff);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
.header p {
font-size: 1.2rem;
color: #8b949e;
margin: 1rem 0;
}
.nav {
display: flex;
gap: 1rem;
justify-content: center;
flex-wrap: wrap;
margin: 2rem 0;
}
.nav a {
padding: 0.75rem 1.5rem;
background-color: #21262d;
color: #c9d1d9;
text-decoration: none;
border-radius: 6px;
border: 1px solid #30363d;
transition: all 0.2s;
}
.nav a:hover {
background-color: #30363d;
border-color: #58a6ff;
}
.markdown-body {
background-color: #0d1117;
padding: 2rem;
border-radius: 6px;
}
.section {
margin: 3rem 0;
}
.features {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 2rem;
margin: 3rem 0;
}
.feature-card {
background-color: #161b22;
padding: 2rem;
border-radius: 6px;
border: 1px solid #30363d;
}
.feature-card h3 {
color: #58a6ff;
margin-top: 0;
}
code {
background-color: #161b22;
padding: 0.2rem 0.4rem;
border-radius: 3px;
font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}
pre {
background-color: #161b22;
padding: 1rem;
border-radius: 6px;
overflow-x: auto;
}
.footer {
text-align: center;
padding: 3rem 0;
border-top: 1px solid #30363d;
margin-top: 4rem;
color: #8b949e;
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<h1>FlexLöve</h1>
<p>A comprehensive UI library for LÖVE Framework based on flexbox</p>
</div>
<div class="nav">
<a href="https://github.com/mikefreno/FlexLove">GitHub</a>
<a href="#getting-started">Getting Started</a>
<a href="doc.md">API Reference (Markdown)</a>
<a href="doc.json">API Reference (JSON)</a>
</div>
<div class="section">
<div class="features">
<div class="feature-card">
<h3>🎨 Flexbox & Grid Layouts</h3>
<p>Modern CSS-like layout system with full flexbox and grid support for building responsive UIs.</p>
</div>
<div class="feature-card">
<h3>🎭 Theme System</h3>
<p>9-patch NinePatch theming with state support (normal, hover, pressed, disabled).</p>
</div>
<div class="feature-card">
<h3>✨ Animations</h3>
<p>Built-in animation support for smooth transitions and effects with easing functions.</p>
</div>
<div class="feature-card">
<h3>📱 Responsive Design</h3>
<p>Viewport units (vw, vh, %) for automatic resizing and responsive layouts.</p>
</div>
<div class="feature-card">
<h3>⚡ Immediate Mode</h3>
<p>Optional immediate mode support alongside traditional retained mode rendering.</p>
</div>
<div class="feature-card">
<h3>🎯 Event System</h3>
<p>Rich event handling with callbacks, focus management, and input fields.</p>
</div>
</div>
</div>
<div class="section markdown-body" id="getting-started">
<h2>Quick Start</h2>
<pre><code class="language-lua">local FlexLove = require("FlexLove")
-- Initialize with base scaling and theme
FlexLove.init({
baseScale = { width = 1920, height = 1080 },
theme = "space"
})
-- Create a button
local button = FlexLove.new({
width = "20vw",
height = "10vh",
backgroundColor = Color.new(0.2, 0.2, 0.8, 1),
text = "Click Me",
themeComponent = "button",
onEvent = function(element, event)
print("Button clicked!")
end
})
-- In your love callbacks
function love.update(dt)
FlexLove.update(dt)
end
function love.draw()
FlexLove.draw()
end</code></pre>
</div>
<div class="section">
<h2>Documentation</h2>
<p>The API reference is available in two formats:</p>
<ul>
<li><a href="doc.md">Markdown format</a> - Easy to read in browser or convert to HTML</li>
<li><a href="doc.json">JSON format</a> - For programmatic access and tooling</li>
</ul>
<p>These docs are auto-generated from LuaLS annotations using the Lua Language Server.</p>
</div>
<div class="section">
<h2>Installation</h2>
<p>Add the <code>modules</code> directory and <code>FlexLove.lua</code> into your LÖVE project.</p>
<pre><code>git clone https://github.com/mikefreno/FlexLove.git
cp -r FlexLove/modules your-project/
cp FlexLove/FlexLove.lua your-project/</code></pre>
</div>
<div class="footer">
<p>FlexLöve v0.2.0 | MIT License | <a href="https://github.com/mikefreno/FlexLove" style="color: #58a6ff;">GitHub Repository</a></p>
</div>
</div>
</body>
</html>

40
generate_docs.sh Executable file
View File

@@ -0,0 +1,40 @@
#!/bin/bash
# FlexLöve Documentation Generator
# This script generates HTML documentation from LuaLS annotations
echo "Generating FlexLöve documentation..."
# Get the directory where this script is located
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$SCRIPT_DIR"
# Check if lua-language-server is installed
if ! command -v lua-language-server &> /dev/null; then
echo "Error: lua-language-server not found. Please install it first."
echo " macOS: brew install lua-language-server"
echo " Linux: See https://github.com/LuaLS/lua-language-server"
exit 1
fi
# Create docs directory if it doesn't exist
mkdir -p docs
# Generate documentation using lua-language-server
echo "Running lua-language-server documentation export..."
lua-language-server \
--doc="$SCRIPT_DIR" \
--doc_out_path="$SCRIPT_DIR/docs"
if [ $? -eq 0 ]; then
echo "✓ Documentation generated successfully!"
echo " - docs/doc.md (Markdown format)"
echo " - docs/doc.json (JSON format)"
echo " - docs/index.html (GitHub Pages)"
echo ""
echo "To view locally, open: file://$SCRIPT_DIR/docs/index.html"
echo "To publish, commit the docs/ directory and enable GitHub Pages."
else
echo "✗ Documentation generation failed"
exit 1
fi