-
Notifications
You must be signed in to change notification settings - Fork 882
Expand file tree
/
Copy pathdocs.go
More file actions
36 lines (31 loc) · 726 Bytes
/
docs.go
File metadata and controls
36 lines (31 loc) · 726 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package main
import (
"fmt"
"dagger/python-sdk-dev/internal/dagger"
)
type Docs struct {
// +private
Container *dagger.Container
}
// Build the documentation
func (d *Docs) Build() *dagger.Directory {
return d.Container.
WithWorkdir("docs").
WithExec(uvRun(
"sphinx-build", "-v", ".", "/dist",
)).
Directory("/dist")
}
// Build and preview the documentation in the browser
func (d *Docs) Preview(
// The port to bind the web preview for the built docs
// +default=8000
bind int,
) *dagger.Service {
return d.Container.
With(mountedWorkdir(d.Build())).
WithExposedPort(bind).
AsService(dagger.ContainerAsServiceOpts{Args: uvRun(
"python", "-m", "http.server", fmt.Sprintf("%d", bind),
)})
}