Skip to content

Commit

Permalink
fix: embed markdown as bindata
Browse files Browse the repository at this point in the history
We can't read runfiles unless we distribute a package that lays them out on the users disk.
We just want a self-contained statically linked binary, which is what bindata is for.

Fixes #48
  • Loading branch information
alexeagle committed Oct 12, 2021
1 parent 387364f commit 2e85286
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 28 deletions.
3 changes: 3 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ rules_proto_dependencies()
rules_proto_toolchains()

load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
load("@io_bazel_rules_go//extras:embed_data_deps.bzl", "go_embed_data_dependencies")
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
load("//:go.bzl", _go_repositories = "deps")

Expand All @@ -65,6 +66,8 @@ _go_repositories()

go_rules_dependencies()

go_embed_data_dependencies()

go_register_toolchains(version = "1.17.1")

gazelle_dependencies()
Expand Down
6 changes: 3 additions & 3 deletions cmd/aspect/root/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,17 @@ func NewRootCmd(streams ioutils.Streams, defaultInteractive bool) *cobra.Command
cmd.AddCommand(&cobra.Command{
Use: "target-syntax",
Short: "Explains the syntax for specifying targets.",
Long: topics.Read("target-syntax.md"),
Long: topics.MustAssetString("target-syntax.md"),
})
cmd.AddCommand(&cobra.Command{
Use: "info-keys",
Short: "Displays a list of keys used by the info command.",
Long: topics.Read("info-keys.md"),
Long: topics.MustAssetString("info-keys.md"),
})
cmd.AddCommand(&cobra.Command{
Use: "tags",
Short: "Conventions for tags which are special",
Long: topics.Read("tags.md"),
Long: topics.MustAssetString("tags.md"),
})

return cmd
Expand Down
15 changes: 10 additions & 5 deletions docs/help/topics/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
load("@io_bazel_rules_go//extras:bindata.bzl", "bindata")
load("@io_bazel_rules_go//go:def.bzl", "go_library")

go_library(
name = "topics",
srcs = ["main.go"],
data = [
bindata(
name = "bindata",
srcs = [
"info-keys.md",
"tags.md",
"target-syntax.md",
],
package = "topics",
)

go_library(
name = "topics",
srcs = [":bindata"],
importpath = "aspect.build/cli/docs/help/topics",
visibility = ["//visibility:public"],
deps = ["@io_bazel_rules_go//go/tools/bazel:go_default_library"],
)
20 changes: 0 additions & 20 deletions docs/help/topics/main.go

This file was deleted.

0 comments on commit 2e85286

Please sign in to comment.