Skip to content

Commit 016b1d3

Browse files
authored
chore: fork eklanin/github-markdown-toc.go with HTML parsing updates (#342)
- Fork https://github.com/ekalinin/github-markdown-toc.go with [HTML parsing changes](ekalinin/github-markdown-toc.go#38). - Remove references to the original repo. - Removed `cmd/go_deps` as it is no longer needed.
1 parent 5ccd331 commit 016b1d3

22 files changed

+1501
-99
lines changed

BUILD.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@ _RUNTIME_PKGS = [
163163
"//markdown",
164164
"//markdown/private",
165165
"//markdown/tools",
166+
"//markdown/tools/github_markdown_toc",
167+
"//markdown/tools/github_markdown_toc/cmd/gh-md-toc",
166168
"//shlib/lib",
167169
"//shlib/rules",
168170
"//shlib/rules/private",

MODULE.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ go_deps.from_file(go_mod = "//:go.mod")
3333
use_repo(
3434
go_deps,
3535
"com_github_creasty_defaults",
36-
"com_github_ekalinin_github_markdown_toc_go",
3736
"com_github_stretchr_testify",
3837
"in_gopkg_alecthomas_kingpin_v2",
3938
"in_gopkg_yaml_v3",
39+
"org_golang_x_net",
4040
)
4141

4242
# MARK: - Dev Dependencies

README.md

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,48 +3,48 @@
33
[![Build](https://github.com/cgrindel/bazel-starlib/actions/workflows/ci.yml/badge.svg?event=schedule)](https://github.com/cgrindel/bazel-starlib/actions/workflows/ci.yml)
44

55
Bazel Starlib is a collection of projects that contain rulesets and libraries that are useful for
6-
the implementation of Bazel projects.
7-
8-
| Project | Description | Documentation |
9-
| ------- | ----------- | ------------- |
10-
| bazeldoc | Generate Starlark documentation using [Bazel Stardoc](https://github.com/bazelbuild/stardoc). Formerly hosted as [bazel-doc](https://github.com/cgrindel/bazel-doc). | [API](/doc/bazeldoc/), [How-to](/bazeldoc/) |
11-
| bzlformat | Format Bazel Starlark files using [Buildifier](https://github.com/bazelbuild/buildtools/tree/master/buildifier), test that the formatted files exist in the workspace directory, and copy formatted files to the workspace directory. Formerly hosted as [rules_bzlformat](https://github.com/cgrindel/rules_bzlformat). | [API](/doc/bzlformat/), [How-to](/bzlformat/), [Examples](/examples/bzlformat/) |
12-
| bzllib | Collection of Starlark libraries. | [API](/doc/bzllib/), [How-to](/bzllib/) |
13-
| bzlrelease | Automate and customize the generation of releases using GitHub Actions. | [API](/doc/bzlrelease/), [How-to](/bzlrelease/) |
14-
| bzltidy | Collect Bazel actions that keep your source files up-to-date. | [API](/doc/bztidy/), [How-to](/bzltidy/) |
15-
| markdown | Maintain markdown files. | [API](/doc/markdown/), [How-to](/markdown/), [Examples](/examples/markdown/) |
16-
| shlib | Collection of libraries useful when implementing shell binaries, libraries, and tests. Formerly hosted as [bazel_shlib](https://github.com/cgrindel/bazel_shlib). | [API](/doc/shlib/), [How-to](/shlib/) |
17-
| updatesrc | Copy files from the Bazel output directories to the workspace directory. Formerly hosted as [rules_updatesrc](https://github.com/cgrindel/rules_updatesrc) | [API](/doc/updatesrc/), [How-to](/updatesrc/), [Examples](/examples/updatesrc/) |
18-
6+
the implementation of Bazel projects.
7+
8+
| Project | Description | Documentation |
9+
| ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------- |
10+
| bazeldoc | Generate Starlark documentation using [Bazel Stardoc](https://github.com/bazelbuild/stardoc). Formerly hosted as [bazel-doc](https://github.com/cgrindel/bazel-doc). | [API](/doc/bazeldoc/), [How-to](/bazeldoc/) |
11+
| bzlformat | Format Bazel Starlark files using [Buildifier](https://github.com/bazelbuild/buildtools/tree/master/buildifier), test that the formatted files exist in the workspace directory, and copy formatted files to the workspace directory. Formerly hosted as [rules_bzlformat](https://github.com/cgrindel/rules_bzlformat). | [API](/doc/bzlformat/), [How-to](/bzlformat/), [Examples](/examples/bzlformat/) |
12+
| bzllib | Collection of Starlark libraries. | [API](/doc/bzllib/), [How-to](/bzllib/) |
13+
| bzlrelease | Automate and customize the generation of releases using GitHub Actions. | [API](/doc/bzlrelease/), [How-to](/bzlrelease/) |
14+
| bzltidy | Collect Bazel actions that keep your source files up-to-date. | [API](/doc/bztidy/), [How-to](/bzltidy/) |
15+
| markdown | Maintain markdown files. | [API](/doc/markdown/), [How-to](/markdown/), [Examples](/examples/markdown/) |
16+
| shlib | Collection of libraries useful when implementing shell binaries, libraries, and tests. Formerly hosted as [bazel_shlib](https://github.com/cgrindel/bazel_shlib). | [API](/doc/shlib/), [How-to](/shlib/) |
17+
| updatesrc | Copy files from the Bazel output directories to the workspace directory. Formerly hosted as [rules_updatesrc](https://github.com/cgrindel/rules_updatesrc) | [API](/doc/updatesrc/), [How-to](/updatesrc/), [Examples](/examples/updatesrc/) |
1918

2019
## Table of Contents
2120

2221
<!-- MARKDOWN TOC: BEGIN -->
23-
* [Quickstart](#quickstart)
24-
* [Workspace Configuration](#workspace-configuration)
25-
* [Other Documentation](#other-documentation)
26-
<!-- MARKDOWN TOC: END -->
2722

23+
- [Quickstart](#quickstart)
24+
- [Workspace Configuration](#workspace-configuration)
25+
- [Other Documentation](#other-documentation)
26+
<!-- MARKDOWN TOC: END -->
2827

2928
## Quickstart
3029

31-
The following provides a quick introduction on how to load this repository into your workspace. For
30+
The following provides a quick introduction on how to load this repository into your workspace. For
3231
more information on how to use the projects from this repository in your workspace, check out the
3332
how-to links above and review the [the generated documentation](/doc/).
3433

35-
3634
### `MODULE.bazel` Snippet
3735

3836
<!-- BEGIN MODULE SNIPPET -->
37+
3938
```python
4039
bazel_dep(name = "cgrindel_bazel_starlib", version = "0.16.2")
4140
```
42-
<!-- END MODULE SNIPPET -->
4341

42+
<!-- END MODULE SNIPPET -->
4443

4544
### Workspace Configuration
4645

4746
<!-- BEGIN WORKSPACE SNIPPET -->
47+
4848
```python
4949
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
5050

@@ -64,8 +64,23 @@ load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
6464

6565
bazel_skylib_workspace()
6666
```
67+
6768
<!-- END WORKSPACE SNIPPET -->
6869

70+
## Developer Documentation
71+
72+
### To Add a Golang Dependency
73+
74+
Execute the following to update the go module files, resolve the Golang dependencies and update the
75+
Bazel build files.
76+
77+
```sh
78+
$ bazel run @io_bazel_rules_go//go -- github.com/sweet/go_pkg
79+
$ bazel run //:go_mod_tidy
80+
$ bazel run //:gazelle_update_repos
81+
$ bazel run //:update_build_files
82+
```
83+
6984
## Other Documentation
7085

7186
- [Release process for this repository](release/README.md)

cmd/go_deps/README.md

Lines changed: 0 additions & 34 deletions
This file was deleted.

cmd/go_deps/main.go

Lines changed: 0 additions & 24 deletions
This file was deleted.

go.mod

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ go 1.19
44

55
require (
66
github.com/creasty/defaults v1.7.0
7-
github.com/ekalinin/github-markdown-toc.go v1.2.1
87
github.com/stretchr/testify v1.8.4
8+
golang.org/x/net v0.1.0
99
gopkg.in/alecthomas/kingpin.v2 v2.2.4
1010
gopkg.in/yaml.v3 v3.0.1
1111
)
1212

1313
require (
14+
github.com/alecthomas/assert v1.0.0 // indirect
1415
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc // indirect
1516
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf // indirect
1617
github.com/davecgh/go-spew v1.1.1 // indirect

go.sum

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38 h1:smF2tmSOzy2Mm+0dGI2AIUHY+w0BUc+4tn40djz7+6U=
1+
github.com/alecthomas/assert v1.0.0 h1:3XmGh/PSuLzDbK3W2gUbRXwgW5lqPkuqvRgeQ30FI5o=
2+
github.com/alecthomas/assert v1.0.0/go.mod h1:va/d2JC+M7F6s+80kl/R3G7FUiW6JzUO+hPhLyJ36ZY=
23
github.com/alecthomas/colour v0.1.0 h1:nOE9rJm6dsZ66RGWYSFrXw461ZIt9A6+nHgL7FRrDUk=
34
github.com/alecthomas/repr v0.0.0-20210801044451-80ca428c5142 h1:8Uy0oSf5co/NZXje7U1z8Mpep++QJOldL2hs/sBQf48=
45
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc h1:cAKDfWh5VpdgMhJosfJnn5/FoN2SRZ4p7fJNX58YPaU=
@@ -9,14 +10,14 @@ github.com/creasty/defaults v1.7.0 h1:eNdqZvc5B509z18lD8yc212CAqJNvfT1Jq6L8WowdB
910
github.com/creasty/defaults v1.7.0/go.mod h1:iGzKe6pbEHnpMPtfDXZEr0NVxWnPTjb1bbDy08fPzYM=
1011
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
1112
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
12-
github.com/ekalinin/github-markdown-toc.go v1.2.1 h1:6jRFt5qg61XfXZbP3SDaeTX+1OC1EgbHvRceYDmPAUE=
13-
github.com/ekalinin/github-markdown-toc.go v1.2.1/go.mod h1:V5aiwoSLm1+er91D4l0AXn8vr4FX07Iu+zgDMFj3FeU=
1413
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
1514
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
1615
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
1716
github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ=
1817
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
1918
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
19+
golang.org/x/net v0.1.0 h1:hZ/3BUoy5aId7sCpA/Tc5lt8DkFgdVS2onTpJsZ/fl0=
20+
golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco=
2021
golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA=
2122
golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
2223
gopkg.in/alecthomas/kingpin.v2 v2.2.4 h1:CC8tJ/xljioKrK6ii3IeWVXU4Tw7VB+LbjZBJaBxN50=

go_deps.bzl

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ def bazel_starlib_go_dependencies():
1010
name = "com_github_alecthomas_assert",
1111
build_external = "external",
1212
importpath = "github.com/alecthomas/assert",
13-
sum = "h1:smF2tmSOzy2Mm+0dGI2AIUHY+w0BUc+4tn40djz7+6U=",
14-
version = "v0.0.0-20170929043011-405dbfeb8e38",
13+
sum = "h1:3XmGh/PSuLzDbK3W2gUbRXwgW5lqPkuqvRgeQ30FI5o=",
14+
version = "v1.0.0",
1515
)
1616
go_repository(
1717
name = "com_github_alecthomas_colour",
@@ -55,13 +55,6 @@ def bazel_starlib_go_dependencies():
5555
sum = "h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=",
5656
version = "v1.1.1",
5757
)
58-
go_repository(
59-
name = "com_github_ekalinin_github_markdown_toc_go",
60-
build_external = "external",
61-
importpath = "github.com/ekalinin/github-markdown-toc.go",
62-
sum = "h1:6jRFt5qg61XfXZbP3SDaeTX+1OC1EgbHvRceYDmPAUE=",
63-
version = "v1.2.1",
64-
)
6558
go_repository(
6659
name = "com_github_mattn_go_isatty",
6760
build_external = "external",
@@ -118,10 +111,32 @@ def bazel_starlib_go_dependencies():
118111
sum = "h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=",
119112
version = "v3.0.1",
120113
)
114+
go_repository(
115+
name = "org_golang_x_net",
116+
build_external = "external",
117+
importpath = "golang.org/x/net",
118+
sum = "h1:hZ/3BUoy5aId7sCpA/Tc5lt8DkFgdVS2onTpJsZ/fl0=",
119+
version = "v0.1.0",
120+
)
121+
121122
go_repository(
122123
name = "org_golang_x_sys",
123124
build_external = "external",
124125
importpath = "golang.org/x/sys",
125126
sum = "h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA=",
126127
version = "v0.10.0",
127128
)
129+
go_repository(
130+
name = "org_golang_x_term",
131+
build_external = "external",
132+
importpath = "golang.org/x/term",
133+
sum = "h1:g6Z6vPFA9dYBAF7DWcH6sCcOntplXsDKcliusYijMlw=",
134+
version = "v0.1.0",
135+
)
136+
go_repository(
137+
name = "org_golang_x_text",
138+
build_external = "external",
139+
importpath = "golang.org/x/text",
140+
sum = "h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg=",
141+
version = "v0.4.0",
142+
)

markdown/tools/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ sh_binary(
2323
srcs = ["update_markdown_toc.sh"],
2424
data = [
2525
":update_markdown_doc",
26-
"@com_github_ekalinin_github_markdown_toc_go//cmd/gh-md-toc",
26+
"//markdown/tools/github_markdown_toc/cmd/gh-md-toc",
2727
],
2828
visibility = ["//visibility:public"],
2929
deps = [
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
load("@cgrindel_bazel_starlib//bzlformat:defs.bzl", "bzlformat_pkg")
2+
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
3+
4+
filegroup(
5+
name = "all_files",
6+
srcs = glob(["*"]),
7+
visibility = ["//:__subpackages__"],
8+
)
9+
10+
go_library(
11+
name = "github_markdown_toc",
12+
srcs = [
13+
"ghdoc.go",
14+
"headerfinder.go",
15+
"internals.go",
16+
],
17+
importpath = "github.com/cgrindel/bazel-starlib/markdown/tools/github_markdown_toc",
18+
visibility = ["//visibility:public"],
19+
deps = [
20+
"@org_golang_x_net//html",
21+
"@org_golang_x_net//html/atom",
22+
],
23+
)
24+
25+
go_test(
26+
name = "github_markdown_toc_test",
27+
srcs = [
28+
"ghdoc_test.go",
29+
"headerfinder_test.go",
30+
"internal_test.go",
31+
],
32+
embed = [":github_markdown_toc"],
33+
deps = [
34+
"@com_github_stretchr_testify//assert",
35+
"@org_golang_x_net//html",
36+
"@org_golang_x_net//html/atom",
37+
],
38+
)
39+
40+
bzlformat_pkg(name = "bzlformat")

0 commit comments

Comments
 (0)