Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: do not create garbage in examples nav bar #652

Merged
merged 2 commits into from Dec 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions examples/main.go
Expand Up @@ -145,11 +145,13 @@ func generate(example Example, rootDir string) error {

// make sure the index.md is the first element in the list of examples in the nav
examplesNav := make([]string, len(mkdocsExamplesNav)-1)
j := 0

for _, exampleNav := range mkdocsExamplesNav {
// filter out the index.md file
if !strings.HasSuffix("index.md", exampleNav) {
examplesNav = append(examplesNav, exampleNav)
if !strings.HasSuffix(exampleNav, "index.md") {
examplesNav[j] = exampleNav
j++
}
}

Expand Down
12 changes: 9 additions & 3 deletions examples/main_test.go
Expand Up @@ -68,6 +68,9 @@ func TestGenerate(t *testing.T) {
err = copyInitialConfig(t, rootTmp)
assert.Nil(t, err)

originalConfig, err := readMkdocsConfig(rootTmp)
assert.Nil(t, err)

example := Example{
Name: "foo",
Image: "docker.io/example/foo:latest",
Expand Down Expand Up @@ -109,7 +112,7 @@ func TestGenerate(t *testing.T) {
assertGoModContent(t, example, filepath.Join(generatedTemplatesDir, "go.mod"))
assertMakefileContent(t, example, filepath.Join(generatedTemplatesDir, "Makefile"))
assertToolsGoContent(t, example, filepath.Join(generatedTemplatesDir, "tools", "tools.go"))
assertMkdocsExamplesNav(t, example, rootTmp)
assertMkdocsExamplesNav(t, example, originalConfig, rootTmp)
}

// assert content example file in the docs
Expand Down Expand Up @@ -197,12 +200,15 @@ func assertMakefileContent(t *testing.T, example Example, makefile string) {
}

// assert content in the Examples nav from mkdocs.yml
func assertMkdocsExamplesNav(t *testing.T, example Example, rootDir string) {
func assertMkdocsExamplesNav(t *testing.T, example Example, originalConfig *MkDocsConfig, rootDir string) {
config, err := readMkdocsConfig(rootDir)
assert.Nil(t, err)

// the example should be in the nav
examples := config.Nav[3].Examples

assert.Equal(t, len(originalConfig.Nav[3].Examples)+1, len(examples))

// the example should be in the nav
found := false
for _, ex := range examples {
markdownExample := "examples/" + example.Lower() + ".md"
Expand Down
126 changes: 63 additions & 63 deletions mkdocs.yml
@@ -1,71 +1,71 @@
site_name: Testcontainers for Go
plugins:
- search
- codeinclude
- markdownextradata
- search
- codeinclude
- markdownextradata
theme:
name: 'material'
palette:
scheme: testcontainers
font:
text: Roboto
code: Roboto Mono
logo: 'logo.svg'
favicon: 'favicon.ico'
name: material
palette:
scheme: testcontainers
font:
text: Roboto
code: Roboto Mono
logo: logo.svg
favicon: favicon.ico
extra_css:
- 'css/extra.css'
repo_name: 'testcontainers-go'
repo_url: 'https://github.com/testcontainers/testcontainers-go'
- css/extra.css
repo_name: testcontainers-go
repo_url: https://github.com/testcontainers/testcontainers-go
markdown_extensions:
- admonition
- codehilite:
linenums: False
- pymdownx.superfences
- pymdownx.tabbed:
alternate_style: true
- pymdownx.snippets
- admonition
- codehilite:
linenums: false
- pymdownx.superfences
- pymdownx.tabbed:
alternate_style: true
- pymdownx.snippets
nav:
- Home: index.md
- Quickstart:
- quickstart/gotest.md
- Features:
- features/creating_container.md
- features/networking.md
- features/garbage_collector.md
- features/build_from_dockerfile.md
- features/docker_compose.md
- features/follow_logs.md
- features/override_container_command.md
- features/copy_file.md
- Wait Strategies:
- Introduction: features/wait/introduction.md
- Exec: features/wait/exec.md
- Exit: features/wait/exit.md
- Health: features/wait/health.md
- HostPort: features/wait/host_port.md
- HTTP: features/wait/http.md
- Log: features/wait/log.md
- Multi: features/wait/multi.md
- SQL: features/wait/sql.md
- Examples:
- examples/index.md
- examples/cockroachdb.md
- examples/datastore.md
- examples/firestore.md
- examples/nginx.md
- examples/redis.md
- examples/pubsub.md
- examples/pulsar.md
- examples/spanner.md
- examples/toxiproxy.md
- System Requirements:
- system_requirements/index.md
- system_requirements/using_colima.md
- system_requirements/using_podman.md
- Contributing:
- contributing.md
- contributing_docs.md
- Getting help: getting_help.md
- Home: index.md
- Quickstart:
- quickstart/gotest.md
- Features:
- features/creating_container.md
- features/networking.md
- features/garbage_collector.md
- features/build_from_dockerfile.md
- features/docker_compose.md
- features/follow_logs.md
- features/override_container_command.md
- features/copy_file.md
- Wait Strategies:
- Introduction: features/wait/introduction.md
- Exec: features/wait/exec.md
- Exit: features/wait/exit.md
- Health: features/wait/health.md
- HostPort: features/wait/host_port.md
- HTTP: features/wait/http.md
- Log: features/wait/log.md
- Multi: features/wait/multi.md
- SQL: features/wait/sql.md
- Examples:
- examples/index.md
- examples/cockroachdb.md
- examples/datastore.md
- examples/firestore.md
- examples/nginx.md
- examples/redis.md
- examples/pubsub.md
- examples/pulsar.md
- examples/spanner.md
- examples/toxiproxy.md
- System Requirements:
- system_requirements/index.md
- system_requirements/using_colima.md
- system_requirements/using_podman.md
- Contributing:
- contributing.md
- contributing_docs.md
- Getting help: getting_help.md
edit_uri: edit/main/docs/
extra:
latest_version: 0.16.0
latest_version: 0.16.0