Skip to content

Commit

Permalink
fix: replace gh-md-toc with custom generate_toc (#352)
Browse files Browse the repository at this point in the history
- Remove `gh-md-toc` which relies on GitHub service.
- Introduce `generate_toc` tool that uses a Go library to parse markdown
files.

Closes #350.
  • Loading branch information
cgrindel committed Sep 23, 2023
1 parent e576259 commit b694ee0
Show file tree
Hide file tree
Showing 27 changed files with 574 additions and 1,556 deletions.
4 changes: 4 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
run:
skip-dirs:
- .*/usr/local/Cellar/
- .*/go/pkg/mod/
4 changes: 2 additions & 2 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ _RUNTIME_PKGS = [
"//markdown",
"//markdown/private",
"//markdown/tools",
"//markdown/tools/github_markdown_toc",
"//markdown/tools/github_markdown_toc/cmd/gh-md-toc",
"//markdown/tools/markdown_toc/cmd/generate_toc",
"//markdown/tools/markdown_toc/mdtoc",
"//shlib/lib",
"//shlib/rules",
"//shlib/rules/private",
Expand Down
3 changes: 1 addition & 2 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,9 @@ go_deps.from_file(go_mod = "//:go.mod")
use_repo(
go_deps,
"com_github_creasty_defaults",
"com_github_gomarkdown_markdown",
"com_github_stretchr_testify",
"in_gopkg_alecthomas_kingpin_v2",
"in_gopkg_yaml_v3",
"org_golang_x_net",
)

# MARK: - Dev Dependencies
Expand Down
6 changes: 1 addition & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,12 @@ go 1.19

require (
github.com/creasty/defaults v1.7.0
github.com/gomarkdown/markdown v0.0.0-20230922112808-5421fefb8386
github.com/stretchr/testify v1.8.4
golang.org/x/net v0.15.0
gopkg.in/alecthomas/kingpin.v2 v2.2.4
gopkg.in/yaml.v3 v3.0.1
)

require (
github.com/alecthomas/assert v1.0.0 // indirect
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc // indirect
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
)
17 changes: 2 additions & 15 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,26 +1,13 @@
github.com/alecthomas/assert v1.0.0 h1:3XmGh/PSuLzDbK3W2gUbRXwgW5lqPkuqvRgeQ30FI5o=
github.com/alecthomas/assert v1.0.0/go.mod h1:va/d2JC+M7F6s+80kl/R3G7FUiW6JzUO+hPhLyJ36ZY=
github.com/alecthomas/colour v0.1.0 h1:nOE9rJm6dsZ66RGWYSFrXw461ZIt9A6+nHgL7FRrDUk=
github.com/alecthomas/repr v0.0.0-20210801044451-80ca428c5142 h1:8Uy0oSf5co/NZXje7U1z8Mpep++QJOldL2hs/sBQf48=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc h1:cAKDfWh5VpdgMhJosfJnn5/FoN2SRZ4p7fJNX58YPaU=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf h1:qet1QNfXsQxTZqLG4oE62mJzwPIB8+Tee4RNCL9ulrY=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/creasty/defaults v1.7.0 h1:eNdqZvc5B509z18lD8yc212CAqJNvfT1Jq6L8WowdBA=
github.com/creasty/defaults v1.7.0/go.mod h1:iGzKe6pbEHnpMPtfDXZEr0NVxWnPTjb1bbDy08fPzYM=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
github.com/gomarkdown/markdown v0.0.0-20230922112808-5421fefb8386 h1:EcQR3gusLHN46TAD+G+EbaaqJArt5vHhNpXAa12PQf4=
github.com/gomarkdown/markdown v0.0.0-20230922112808-5421fefb8386/go.mod h1:JDGcbDT52eL4fju3sZ4TeHGsQwhG9nbDV21aMyhwPoA=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
golang.org/x/net v0.15.0 h1:ugBLEUaxABaB5AJqW9enI0ACdci2RUd4eP51NTBvuJ8=
golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
gopkg.in/alecthomas/kingpin.v2 v2.2.4 h1:CC8tJ/xljioKrK6ii3IeWVXU4Tw7VB+LbjZBJaBxN50=
gopkg.in/alecthomas/kingpin.v2 v2.2.4/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
Expand Down
98 changes: 8 additions & 90 deletions go_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,7 @@ load("@bazel_gazelle//:deps.bzl", "go_repository")

def bazel_starlib_go_dependencies():
"""Load dependencies for `bazel-starlib`."""
go_repository(
name = "com_github_alecthomas_assert",
build_external = "external",
importpath = "github.com/alecthomas/assert",
sum = "h1:3XmGh/PSuLzDbK3W2gUbRXwgW5lqPkuqvRgeQ30FI5o=",
version = "v1.0.0",
)
go_repository(
name = "com_github_alecthomas_colour",
build_external = "external",
importpath = "github.com/alecthomas/colour",
sum = "h1:nOE9rJm6dsZ66RGWYSFrXw461ZIt9A6+nHgL7FRrDUk=",
version = "v0.1.0",
)
go_repository(
name = "com_github_alecthomas_repr",
build_external = "external",
importpath = "github.com/alecthomas/repr",
sum = "h1:8Uy0oSf5co/NZXje7U1z8Mpep++QJOldL2hs/sBQf48=",
version = "v0.0.0-20210801044451-80ca428c5142",
)
go_repository(
name = "com_github_alecthomas_template",
build_external = "external",
importpath = "github.com/alecthomas/template",
sum = "h1:cAKDfWh5VpdgMhJosfJnn5/FoN2SRZ4p7fJNX58YPaU=",
version = "v0.0.0-20160405071501-a0175ee3bccc",
)
go_repository(
name = "com_github_alecthomas_units",
build_external = "external",
importpath = "github.com/alecthomas/units",
sum = "h1:qet1QNfXsQxTZqLG4oE62mJzwPIB8+Tee4RNCL9ulrY=",
version = "v0.0.0-20151022065526-2efee857e7cf",
)

go_repository(
name = "com_github_creasty_defaults",
build_external = "external",
Expand All @@ -56,26 +22,21 @@ def bazel_starlib_go_dependencies():
version = "v1.1.1",
)
go_repository(
name = "com_github_mattn_go_isatty",
name = "com_github_gomarkdown_markdown",
build_external = "external",
importpath = "github.com/mattn/go-isatty",
sum = "h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=",
version = "v0.0.14",
importpath = "github.com/gomarkdown/markdown",
sum = "h1:EcQR3gusLHN46TAD+G+EbaaqJArt5vHhNpXAa12PQf4=",
version = "v0.0.0-20230922112808-5421fefb8386",
)

go_repository(
name = "com_github_pmezard_go_difflib",
build_external = "external",
importpath = "github.com/pmezard/go-difflib",
sum = "h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=",
version = "v1.0.0",
)
go_repository(
name = "com_github_sergi_go_diff",
build_external = "external",
importpath = "github.com/sergi/go-diff",
sum = "h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ=",
version = "v1.2.0",
)

go_repository(
name = "com_github_stretchr_objx",
build_external = "external",
Expand All @@ -90,13 +51,7 @@ def bazel_starlib_go_dependencies():
sum = "h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=",
version = "v1.8.4",
)
go_repository(
name = "in_gopkg_alecthomas_kingpin_v2",
build_external = "external",
importpath = "gopkg.in/alecthomas/kingpin.v2",
sum = "h1:CC8tJ/xljioKrK6ii3IeWVXU4Tw7VB+LbjZBJaBxN50=",
version = "v2.2.4",
)

go_repository(
name = "in_gopkg_check_v1",
build_external = "external",
Expand All @@ -111,40 +66,3 @@ def bazel_starlib_go_dependencies():
sum = "h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=",
version = "v3.0.1",
)
go_repository(
name = "org_golang_x_crypto",
build_external = "external",
importpath = "golang.org/x/crypto",
sum = "h1:mvySKfSWJ+UKUii46M40LOvyWfN0s2U+46/jDd0e6Ck=",
version = "v0.13.0",
)

go_repository(
name = "org_golang_x_net",
build_external = "external",
importpath = "golang.org/x/net",
sum = "h1:ugBLEUaxABaB5AJqW9enI0ACdci2RUd4eP51NTBvuJ8=",
version = "v0.15.0",
)

go_repository(
name = "org_golang_x_sys",
build_external = "external",
importpath = "golang.org/x/sys",
sum = "h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=",
version = "v0.12.0",
)
go_repository(
name = "org_golang_x_term",
build_external = "external",
importpath = "golang.org/x/term",
sum = "h1:/ZfYdc3zq+q02Rv9vGqTeSItdzZTSNDmfTi0mBAuidU=",
version = "v0.12.0",
)
go_repository(
name = "org_golang_x_text",
build_external = "external",
importpath = "golang.org/x/text",
sum = "h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=",
version = "v0.13.0",
)
3 changes: 2 additions & 1 deletion markdown/tools/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ sh_binary(
srcs = ["update_markdown_toc.sh"],
data = [
":update_markdown_doc",
"//markdown/tools/github_markdown_toc/cmd/gh-md-toc",
# "//markdown/tools/github_markdown_toc/cmd/gh-md-toc",
"//markdown/tools/markdown_toc/cmd/generate_toc",
],
visibility = ["//visibility:public"],
deps = [
Expand Down
20 changes: 0 additions & 20 deletions markdown/tools/github_markdown_toc/LICENSE

This file was deleted.

40 changes: 0 additions & 40 deletions markdown/tools/github_markdown_toc/Makefile

This file was deleted.

14 changes: 0 additions & 14 deletions markdown/tools/github_markdown_toc/README.md

This file was deleted.

92 changes: 0 additions & 92 deletions markdown/tools/github_markdown_toc/cmd/gh-md-toc/main.go

This file was deleted.

Loading

0 comments on commit b694ee0

Please sign in to comment.