Skip to content

Commit

Permalink
Update documentation in preparation for next release (#276)
Browse files Browse the repository at this point in the history
# Problem

Our docs need an overhaul to reflect the upcoming release

# Solution

This is a big PR so I'll try to break things down.

First of all here's what our new sidebar looks like:
![Screenshot 2024-11-16 at 9 07
23 AM](https://github.com/user-attachments/assets/4560cd03-89b0-415e-a8a2-6f1d120ac51c)

And here's a summary of the changes:
1. Introduced `code-samples` package to the root of the repo. 
1. This is a package containing various examples for use in our
documentation. The kicker is these are run through analysis and linting
just like any of our other Luau code, so our code samples in docs are
easy to validate for correctness. It can also be synced to Studio and
all of the included stories can be viewed in Flipbook
3. Docs on writing stories have been rewritten
4. Updated docs on our Story/Storybook formats to reflect changes from
Storyteller
5. Docs have been added for writing React, Fusion, and Roact stories
along with tabs to switch to Storyteller variants
6. Updated docs for contributors
7. Minor change to our build script which now makes sure Flipbook's
storybook does not leak through to prod builds

# Checklist

- [x] Ran `lune run test` locally before merging
  • Loading branch information
vocksel authored Nov 16, 2024
1 parent 251b7b0 commit cf981d6
Show file tree
Hide file tree
Showing 61 changed files with 5,603 additions and 3,421 deletions.
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ sourcemap*.json
globalTypes.d.luau

# Wally
/DevPackages
/Packages
/wally.lock
DevPackages
Packages
wally.lock

# Other
/*.log
9 changes: 9 additions & 0 deletions .lune/analyze.luau
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,12 @@ run("luau-lsp", {
constants.LUNE_SCRIPTS_PATH,
constants.EXAMPLE_PATH,
})

run("luau-lsp", {
"analyze",
`--sourcemap={constants.SOURCEMAP_PATH}`,
`--defs={globalDefsPath}`,
"--settings=./.vscode/settings.json",
"--ignore=**/_Index/**",
"code-samples/src",
})
12 changes: 9 additions & 3 deletions .lune/build.luau
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,20 @@ assert(target == "dev" or target == "prod", `bad value for target (must be one o
local output = if args.output then args.output else `{getPluginsPath(process.os)}/{constants.PLUGIN_FILENAME}`
assert(typeof(output) == "string", `bad value for output (string expected, got {typeof(output)})`)

local PRUNED_FILES = {
"*.spec.luau",
"*.story.luau",
"*.storybook.luau",
}

local function build()
clean()
compile(target)

if target == "prod" then
run("rm", { "-rf", `{constants.BUILD_PATH}/**/*.spec.luau` })
run("rm", { "-rf", `{constants.BUILD_PATH}/**/*.story.luau` })
run("rm", { "-rf", `{constants.BUILD_PATH}/**/*.storybook.luau` })
for _, pattern in PRUNED_FILES do
run("find", { constants.BUILD_PATH, "-type", "f", "-name", pattern, "-delete" })
end
end

run("rojo", { "build", "-o", output })
Expand Down
1 change: 1 addition & 0 deletions .lune/lib/constants.luau
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ return {
"src",
".lune",
"example",
"code-samples/src",
},
}
20 changes: 17 additions & 3 deletions .lune/wally-install.luau
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
local run = require("./lib/run")

run("wally", { "install" })
run("rojo", { "sourcemap", "build.project.json", "-o", "sourcemap.json" })
run("wally-package-types", { "--sourcemap", "sourcemap.json", "Packages" })
do
run("wally", { "install" })
run("rojo", { "sourcemap", "build.project.json", "-o", "sourcemap.json" })
run("wally-package-types", { "--sourcemap", "sourcemap.json", "Packages" })
end

do
run("wally", { "install" }, {
cwd = "code-samples",
})
run("rojo", { "sourcemap", "default.project.json", "-o", "sourcemap.json" }, {
cwd = "code-samples",
})
run("wally-package-types", { "--sourcemap", "sourcemap.json", "Packages" }, {
cwd = "code-samples",
})
end
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
"@root": "./src",
"@lune/": "~/.lune/.typedefs/0.8.3/"
}
}
}
38 changes: 26 additions & 12 deletions analysis.project.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,29 @@
{
"name": "flipbook",
"name": "Analysis",
"tree": {
"Lune": {
"$path": ".lune"
},
"TestRunner": {
"$path": "tests"
},
"Example": {
"$path": "example"
},
"$path": "build.project.json"
"$className": "DataModel",
"ReplicatedStorage": {
"Packages": {
"$path": "code-samples/Packages"
},
"CodeSamples": {
"$path": "code-samples"
},

"Lune": {
"$path": ".lune"
},

"Flipbook": {
"TestRunner": {
"$path": "tests"
},
"Example": {
"$path": "example"
},

"$path": "build.project.json"
}
}
}
}
}
19 changes: 19 additions & 0 deletions code-samples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# code-samples

Package of code samples for using flipbook. Includes example Storybooks and Stories for each supported framework.

The code samples are for illustrating usage of flipbook on the docs site. This package can also be synced into Studio and viewed in the flipbook plugin.

All code samples are analyzed to ensure correctness before being deployed.

## Setup

Run the following commands from the root of the repo.

```sh
lune run wally-install
lune run build
rojo serve code-samples/default.project.json
```

Open Studio and sync with Rojo. Then open flipbook to preview the code samples.
14 changes: 14 additions & 0 deletions code-samples/default.project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "CodeSamples",
"tree": {
"$className": "DataModel",
"ReplicatedStorage": {
"Packages": {
"$path": "Packages"
},
"CodeSamples": {
"$path": "src"
}
}
}
}
18 changes: 18 additions & 0 deletions code-samples/src/Default/Button.story.luau
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
return {
story = function()
local button = Instance.new("TextButton")
button.Text = "Button"
button.TextSize = 16
button.Font = Enum.Font.BuilderSansExtraBold
button.TextColor3 = Color3.fromRGB(50, 50, 50)
button.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
button.BorderSizePixel = 0
button.Size = UDim2.fromOffset(200, 40)

button.Activated:Connect(function()
print("clicked")
end)

return button
end,
}
5 changes: 5 additions & 0 deletions code-samples/src/Default/ProjectName.storybook.luau
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
return {
storyRoots = {
script.Parent,
},
}
13 changes: 13 additions & 0 deletions code-samples/src/Fusion/Fusion.storybook.luau
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local Fusion = require(ReplicatedStorage.Packages.Fusion)

return {
name = "Fusion",
storyRoots = {
script.Parent,
},
packages = {
Fusion = Fusion,
},
}
24 changes: 24 additions & 0 deletions code-samples/src/Fusion/FusionButton.luau
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local Fusion = require(ReplicatedStorage.Packages.Fusion)

local New = Fusion.New
local OnEvent = Fusion.OnEvent

local function FusionButton(props: {
text: string,
onActivated: () -> (),
})
return New("TextButton")({
Text = props.text,
TextSize = 16,
Font = Enum.Font.BuilderSansExtraBold,
TextColor3 = Color3.fromRGB(50, 50, 50),
BackgroundColor3 = Color3.fromRGB(255, 255, 255),
BorderSizePixel = 0,
Size = UDim2.fromOffset(200, 40),
[OnEvent("Activated")] = props.onActivated,
})
end

return FusionButton
12 changes: 12 additions & 0 deletions code-samples/src/Fusion/FusionButton.story.luau
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
local FusionButton = require(script.Parent.FusionButton)

return {
story = function()
return FusionButton({
text = "Click Me",
onActivated = function()
print("click")
end,
})
end,
}
16 changes: 16 additions & 0 deletions code-samples/src/FusionStoryteller/Fusion.storybook.luau
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local Fusion = require(ReplicatedStorage.Packages.Fusion)
local Storyteller = require(ReplicatedStorage.Packages.Storyteller)

local storybook: Storyteller.Storybook = {
name = "Fusion (Storyteller)",
storyRoots = {
script.Parent,
},
packages = {
Fusion = Fusion,
},
}

return storybook
24 changes: 24 additions & 0 deletions code-samples/src/FusionStoryteller/FusionButton.luau
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local Fusion = require(ReplicatedStorage.Packages.Fusion)

local New = Fusion.New
local OnEvent = Fusion.OnEvent

local function FusionButton(props: {
text: string,
onActivated: () -> (),
})
return New("TextButton")({
Text = props.text,
TextSize = 16,
Font = Enum.Font.BuilderSansExtraBold,
TextColor3 = Color3.fromRGB(50, 50, 50),
BackgroundColor3 = Color3.fromRGB(255, 255, 255),
BorderSizePixel = 0,
Size = UDim2.fromOffset(200, 40),
[OnEvent("Activated")] = props.onActivated,
})
end

return FusionButton
18 changes: 18 additions & 0 deletions code-samples/src/FusionStoryteller/FusionButton.story.luau
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local Storyteller = require(ReplicatedStorage.Packages.Storyteller)

local FusionButton = require(script.Parent.FusionButton)

local story: Storyteller.Story<any> = {
story = function()
return FusionButton({
text = "Click Me",
onActivated = function()
print("click")
end,
})
end,
}

return story
15 changes: 15 additions & 0 deletions code-samples/src/React/React.storybook.luau
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local React = require(ReplicatedStorage.Packages.React)
local ReactRoblox = require(ReplicatedStorage.Packages.ReactRoblox)

return {
name = "React",
storyRoots = {
script.Parent,
},
packages = {
React = React,
ReactRoblox = ReactRoblox,
},
}
21 changes: 21 additions & 0 deletions code-samples/src/React/ReactButton.luau
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local React = require(ReplicatedStorage.Packages.React)

local function ReactButton(props: {
text: string,
onActivated: () -> (),
})
return React.createElement("TextButton", {
Text = props.text,
TextSize = 16,
Font = Enum.Font.BuilderSansExtraBold,
TextColor3 = Color3.fromRGB(50, 50, 50),
BackgroundColor3 = Color3.fromRGB(255, 255, 255),
BorderSizePixel = 0,
Size = UDim2.fromOffset(200, 40),
[React.Event.Activated] = props.onActivated,
})
end

return ReactButton
16 changes: 16 additions & 0 deletions code-samples/src/React/ReactButton.story copy.luau
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local React = require(ReplicatedStorage.Packages.React)

local ReactButton = require(script.Parent.ReactButton)

return {
story = function()
return React.createElement(ReactButton, {
text = "Click Me",
onActivated = function()
print("click")
end,
})
end,
}
16 changes: 16 additions & 0 deletions code-samples/src/React/ReactButton.story.luau
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local React = require(ReplicatedStorage.Packages.React)

local ReactButton = require(script.Parent.ReactButton)

return {
story = function()
return React.createElement(ReactButton, {
text = "Click Me",
onActivated = function()
print("click")
end,
})
end,
}
Loading

0 comments on commit cf981d6

Please sign in to comment.