Build studio docs

This commit is contained in:
marked 2025-12-02 00:24:35 +01:00
parent b5bd5a9a02
commit 4d5f7179e3
No known key found for this signature in database
6 changed files with 111 additions and 0 deletions

22
.github/workflows/studio-docs.yaml vendored Normal file
View file

@ -0,0 +1,22 @@
on:
push:
jobs:
studio-docs:
name: Build Studio Docs
runs-on: ubuntu-latest
steps:
- name: Checkout Project
uses: actions/checkout@v4
- name: Install Rokit
uses: CompeyDev/setup-rokit@v0.1.2
- name: Build Studio Docs
run: zune run scripts/build_studio_docs
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: studio_docs
path: studio_docs.rbxm

1
.gitignore vendored
View file

@ -75,3 +75,4 @@ genhtml.perl
rokit.toml
package-lock.json
mirror.luau
studio_docs/

View file

@ -22,6 +22,8 @@ This repository includes a few subfolders that can help you get started with jec
- examples:
These are larger programs that showcase real use cases and can help you understand how everything fits together.
<!-- After testing is complete, replace this with the path for the Jecs repo -->
If you wish to view the documentation inside Roblox Studio, you can find an importable model file [here](https://nightly.link/Mark-Marks/jecs/workflows/studio-docs/docs%2Fstudio/studio_docs.rbxm).
### Benchmarks

View file

@ -2,3 +2,4 @@
wally = "upliftgames/wally@0.3.2"
rojo = "rojo-rbx/rojo@7.4.4"
luau = "luau-lang/luau@0.701"
zune = "scythe-technology/zune@0.5.1"

View file

@ -0,0 +1,79 @@
--!strict
-- Copies all docs related files into a dist folder where all `@jecs` aliases inside them are replaced with their relative require path to jecs source code
-- This script may break if there's ever a Luau module (`init.luau`) in the mix, as it just counts how deep the file is and prepends `../` to `jecs` that many times
local fs = zune.fs
local process = zune.process
local text_files = { "README.md", "LICENSE" }
local extension_whitelist = { ".luau", ".json" }
local dirs = { "examples", "how_to", "modules" }
local dist = "studio_docs"
local function traverse(dir: string, fn: (path: string, depth: number, metadata: Metadata) -> (), depth: number?)
depth = depth or 0
for _, entry in fs.entries(dir) do
local path = `{dir}/{entry.name}`
local metadata = fs.metadata(path)
fn(path, depth, metadata)
if entry.kind == "directory" then
traverse(path, fn, depth + 1)
end
end
end
local function relativify(depth: number): string
return string.rep("../", depth) .. "jecs"
end
if fs.stat(dist).kind ~= "none" then
fs.deleteDir(dist, true)
end
fs.makeDir(dist)
fs.copy("src/jecs.luau", `{dist}/jecs.luau`)
for _, file in text_files do
local source = fs.readFile(file)
local scriptified_source = `--[\[\n{source}\n]\]`
local stem = fs.path.stem(file)
fs.writeFile(`{dist}/{stem}.server.luau`, scriptified_source)
fs.writeFile(
`{dist}/{stem}.meta.json`,
-- stylua: ignore
[[
{
"properties": {
"Disabled": true
}
}
]]
)
end
for _, dir in dirs do
fs.copy(dir, `{dist}/{dir}`)
end
traverse(dist, function(path, depth, metadata)
if metadata.kind ~= "file" then
return
end
-- whitelist instead of blacklist
local extension = fs.path.extension(path)
if not table.find(extension_whitelist, extension) then
fs.deleteFile(path)
return
end
local source = fs.readFile(path)
local relative_jecs_path = relativify(depth)
source = string.gsub(source, "@jecs", relative_jecs_path)
fs.writeFile(path, source)
end)
process.run(
"rojo",
{ "build", "studio_docs.project.json", "-o", "studio_docs.rbxm" },
-- Luau
{ stdout = "inherit", stderr = "inherit" } :: any
)

6
studio_docs.project.json Normal file
View file

@ -0,0 +1,6 @@
{
"name": "jecs_studio_docs",
"tree": {
"$path": "studio_docs"
}
}