Skip to content

Commit f046bf2

Browse files
authored
Merge pull request #30 from museslabs/kyma-docs
feat: kyma docs command
2 parents 2c3e53b + 1e63025 commit f046bf2

File tree

13 files changed

+508
-13
lines changed

13 files changed

+508
-13
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ go build -o kyma
7070

7171
## Usage
7272

73+
> run `kyma docs` for an interactive presentation of the documentation
74+
7375
### Basic Usage
7476

7577
```bash

cmd/docs.go

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
package cmd
2+
3+
import (
4+
"fmt"
5+
"log/slog"
6+
7+
tea "github.com/charmbracelet/bubbletea"
8+
"github.com/spf13/cobra"
9+
10+
"github.com/museslabs/kyma/docs"
11+
"github.com/museslabs/kyma/internal/config"
12+
"github.com/museslabs/kyma/internal/logger"
13+
"github.com/museslabs/kyma/internal/tui"
14+
)
15+
16+
var docsCmd = &cobra.Command{
17+
Use: "docs",
18+
Short: "Start documentation as a presentation",
19+
Args: cobra.NoArgs,
20+
RunE: func(cmd *cobra.Command, args []string) error {
21+
if err := logger.Load(logPath); err != nil {
22+
return fmt.Errorf("failed to initialize slog: %w", err)
23+
}
24+
25+
slog.Info("Starting Kyma Docs")
26+
27+
if err := config.Load(configPath); err != nil {
28+
slog.Error("Failed to load config", "error", err, "config_path", configPath)
29+
return err
30+
}
31+
32+
data, err := docs.FS.ReadFile("presentation.md")
33+
if err != nil {
34+
slog.Error(
35+
"Failed to read presentation file",
36+
"error",
37+
err,
38+
"filename",
39+
"presentation.md",
40+
)
41+
return err
42+
}
43+
44+
root, err := parseSlides(string(data))
45+
if err != nil {
46+
slog.Error("Failed to parse slides", "error", err, "filename", "presentation.md")
47+
return err
48+
}
49+
50+
slog.Info("Successfully parsed presentation")
51+
52+
p := tea.NewProgram(
53+
tui.New(root, "presentation.md"),
54+
tea.WithAltScreen(),
55+
tea.WithMouseAllMotion(),
56+
)
57+
58+
slog.Info("Starting TUI program")
59+
if _, err := p.Run(); err != nil {
60+
slog.Error("TUI program failed", "error", err)
61+
return err
62+
}
63+
64+
slog.Info("Kyma docs session ended")
65+
return nil
66+
},
67+
}

cmd/root.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ func init() {
3333
StringVarP(&logPath, "log", "l", "", "Path to log file (default: ~/.config/kyma/logs/<timestamp>.kyma.log)")
3434
rootCmd.Flags().BoolVarP(&notes, "notes", "n", false, "Run in speaker notes mode")
3535
rootCmd.AddCommand(versionCmd)
36+
rootCmd.AddCommand(docsCmd)
3637
}
3738

3839
var rootCmd = &cobra.Command{

cmd/version.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ var version = "dev"
1111
var versionCmd = &cobra.Command{
1212
Use: "version",
1313
Short: "Print the version number of kyma",
14-
Args: func(cmd *cobra.Command, args []string) error {
15-
return cobra.NoArgs(cmd, args)
16-
},
14+
Args: cobra.NoArgs,
1715
Run: func(cmd *cobra.Command, args []string) {
1816
fmt.Printf("Kyma %s\n", version)
1917
},

docs/docs.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package docs
2+
3+
import "embed"
4+
5+
//go:embed *
6+
var FS embed.FS

docs/kyma.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
global:
2+
style:
3+
border: rounded
4+
border_color: "#9999CC"
5+
layout: center
6+
theme: dracula
7+
transition: none
8+
9+
presets:
10+
minimal:
11+
style:
12+
border: hidden
13+
theme: notty
14+
transition: none
15+
dark:
16+
style:
17+
border: rounded
18+
theme: dracula
19+
transition: swipeLeft
20+
animated:
21+
transition: slideUp

docs/kyma_logo.png

4.05 KB
Loading

docs/laratalk.jpg

98 KB
Loading

docs/presentation.md

Lines changed: 231 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,231 @@
1+
---
2+
title: Welcome
3+
image_backend: docs
4+
style:
5+
border: hidden
6+
---
7+
8+
![img|43x10](kyma_logo.png)
9+
10+
> Κῦμα (Kyma) - Ancient Greek: A wave, billow, or surge; metaphorically
11+
representing the flow and movement of ideas and presentations.
12+
13+
A terminal-based presentation tool that creates beautiful presentations from
14+
markdown files with smooth animated transitions.
15+
16+
## Basic navigation:
17+
18+
- **Next slide**: ``, `l`, or `Space`
19+
- **Previous slide**: `` or `h`
20+
- **Quit**: `q`, `Esc`, or `Ctrl+C`
21+
22+
----
23+
---
24+
title: Features
25+
transition: swipeLeft
26+
style:
27+
border: hidden
28+
theme: dracula
29+
---
30+
31+
# Features
32+
33+
- **Markdown-based**: Write your presentations in simple markdown syntax
34+
- **Rich rendering**: Beautiful terminal rendering using Glamour markdown renderer
35+
- **Smooth transitions**: Multiple animated transition effects between slides
36+
- **Image Rendering**: Render high quality images
37+
- **Hot reload**: Live reloading of presentation files during editing by default
38+
- **Customizable styling**: Configure borders, colors, and layouts via YAML
39+
- **Theme support**: Choose from built-in Glamour themes or load custom JSON theme
40+
- **Flexible layouts**: Center, align, and position content with various layouts
41+
- **Simple navigation**: Intuitive keyboard controls for presentation flow
42+
- Command palette with slide search and filtering
43+
- Direct slide jumping by number
44+
- Multi-slide forward/backward jumping
45+
- Quick first/last slide navigation
46+
- **Presentation timer**: Built-in timer system with per-slide and global timing
47+
- Toggle timer display with a single key
48+
- Track time spent on each slide
49+
- Monitor total presentation duration
50+
- Automatic pause/resume during slide transitions
51+
52+
----
53+
---
54+
title: Transitions
55+
transition: swipeLeft
56+
style:
57+
border: hidden
58+
theme: dracula
59+
---
60+
61+
# Available transitions
62+
63+
- `none` - No transition (default)
64+
- `swipeLeft` - Slide swipes in from right to left
65+
- `swipeRight` - Slide swipes in from left to right
66+
- `slideUp` - Slide slides up from bottom
67+
- `slideDown` - Slide slides down from top
68+
- `flip` - Flip transition effect
69+
70+
----
71+
---
72+
title: Styles
73+
transition: slideUp
74+
style:
75+
border: rounded
76+
border_color: "#FF0000"
77+
layout: center
78+
theme: tokyo-night
79+
---
80+
81+
# Styling and theme support
82+
83+
- `border` - normal, rounded, double, thick, hidden, block
84+
- `border_color` - Hex color for border (or "default" for theme-based color)
85+
- `layout` - center, left, right, top, bottom
86+
- `theme` - predefined theme name or path to custom JSON theme file
87+
88+
----
89+
---
90+
title: Style usage
91+
style:
92+
border: hidden
93+
transition: swipeLeft
94+
---
95+
96+
# Style usage
97+
98+
To use these styles you can do so by writing yaml at the top of each slide in
99+
wrapped between three dashes `---`
100+
101+
```yaml
102+
transition: swipeLeft
103+
style:
104+
border: rounded
105+
border_color: "#FF0000"
106+
layout: center
107+
theme: dracula
108+
```
109+
110+
----
111+
---
112+
title: Config
113+
preset: dark
114+
---
115+
116+
# Configuration
117+
118+
A configuration file is created by default in `~/.config/kyma.yaml` but you
119+
can use another config file using the `-c` flag or by having a `kyma.yaml`
120+
file present in the directory you are executing the command from.
121+
122+
A `kyma.yaml` file looks like this:
123+
124+
```yaml
125+
global:
126+
style:
127+
border: rounded
128+
border_color: "#9999CC"
129+
layout: center
130+
theme: dracula
131+
132+
presets:
133+
minimal:
134+
style:
135+
border: hidden
136+
theme: notty
137+
dark:
138+
style:
139+
border: rounded
140+
theme: dracula
141+
```
142+
143+
----
144+
---
145+
title: Global styles
146+
---
147+
148+
# Global styles
149+
150+
You can define a global style config that all slides use if no configuration is
151+
provided.
152+
153+
If we take a look at our `kyma.yaml` from before you can see the global
154+
configuration in lines 1-6
155+
156+
```yaml{1-6} --numbered
157+
global:
158+
style:
159+
border: rounded
160+
border_color: "#9999CC"
161+
layout: center
162+
theme: dracula
163+
164+
presets:
165+
minimal:
166+
style:
167+
border: hidden
168+
theme: notty
169+
dark:
170+
style:
171+
border: rounded
172+
theme: dracula
173+
```
174+
175+
----
176+
---
177+
title: Presets
178+
---
179+
180+
# Presets
181+
182+
Presets are a way to define reusable style configurations to apply to individual
183+
slides withou having to copy pase each time
184+
185+
If we take a look again at our `kyma.yaml` from before you can see the presets
186+
in lines 8-16
187+
188+
```yaml{8-16} --numbered
189+
global:
190+
style:
191+
border: rounded
192+
border_color: "#9999CC"
193+
layout: center
194+
theme: dracula
195+
196+
presets:
197+
minimal:
198+
style:
199+
border: hidden
200+
theme: notty
201+
dark:
202+
style:
203+
border: rounded
204+
theme: dracula
205+
```
206+
207+
----
208+
---
209+
title: More ways to navigate
210+
---
211+
212+
# More ways to navigate
213+
214+
- **Last slide**: `End`, `Shift+↓`, or `$`
215+
- **Command palette**: `/` or `p` - Opens a searchable list of all slides for quick navigation
216+
- **Go to slide**: `g` or `:` - Jump directly to a specific slide number
217+
- **Jump slides**: `1-9` + `h`/`←` or `l`/`→` - Jump multiple slides backward/forward (e.g., `5h` jumps 5 slides back)
218+
219+
----
220+
---
221+
title: Achievements
222+
transition: swipeLeft
223+
image_backend: docs
224+
---
225+
226+
# Achievements
227+
228+
_Kyma being used for a talk at Laravel Greece's 10 year anniversary meetup in Athens_
229+
230+
![img|60x18](laratalk.jpg)
231+

0 commit comments

Comments
 (0)