Skip to content

Commit fadb4dc

Browse files
committed
feat: scaffolding out a new docs site
1 parent 632e5f4 commit fadb4dc

40 files changed

+2703
-48
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,6 @@ venv
7272
.python-version
7373
.env
7474
.github-token
75+
76+
# docs build
77+
site/

Dockerfile.docs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FROM python:3.11-slim
2+
3+
RUN pip install poetry
4+
5+
WORKDIR /docs

Makefile

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,44 @@ clean-all: clean ## Remove all generated files and reset the local virtual envir
6868
.PHONY: help
6969
help: ## Display command usage
7070
@grep -E '^[0-9a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
71+
72+
## --------------------------------------
73+
74+
DOCS_CONTAINER=mkdocs-container
75+
DOCS_IMAGE=mkdocs-poetry
76+
DOCS_DOCKERFILE := Dockerfile.docs
77+
78+
.PHONY: clean-docs
79+
clean-docs:
80+
@echo "Destroying docs"
81+
docker rm -f $(DOCS_CONTAINER) || true
82+
docker rmi $(DOCS_IMAGE) || true
83+
84+
.PHONY: docs-ensure-image
85+
docs-ensure-image:
86+
@if [ -z "$$(docker images -q $(DOCS_IMAGE))" ]; then \
87+
docker build -f $(DOCS_DOCKERFILE) -t $(DOCS_IMAGE) . ; \
88+
fi
89+
90+
.PHONY: serve-docs
91+
serve-docs: docs-ensure-image
92+
docker run --rm --name $(DOCS_CONTAINER) -it -p 8000:8000 \
93+
-v $(PWD):/testcontainers-go \
94+
-w /testcontainers-go \
95+
$(DOCS_IMAGE) bash -c "\
96+
cd docs && poetry install --no-root && \
97+
poetry run mkdocs serve -f ../mkdocs.yml -a 0.0.0.0:8000"
98+
99+
.PHONY: watch-docs
100+
watch-docs: docs-ensure-image
101+
docker run --rm --name $(DOCS_CONTAINER) -it -p 8000:8000 \
102+
-v $(PWD):/testcontainers-go \
103+
-w /testcontainers-go \
104+
$(DOCS_IMAGE) bash -c "\
105+
cd docs && poetry install --no-root && \
106+
poetry run mkdocs serve -f ../mkdocs.yml -a 0.0.0.0:8000" --live-reload
107+
108+
# Needed if dependencies are added to the docs site
109+
.PHONY: export-docs-deps
110+
export-docs-deps:
111+
cd docs && poetry export --without-hashes --output requirements.txt

docs/_headers

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/search/search_index.json
2+
Access-Control-Allow-Origin: *

docs/_redirects

Whitespace-only changes.

docs/contributing.md

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# Contributing
2+
3+
`Testcontainers for Go` is open source, and we love to receive contributions from our community — you!
4+
5+
There are many ways to contribute, from writing tutorials or blog posts, improving the documentation, submitting bug reports and feature requests, or writing code for the core library or for a technology module.
6+
7+
In any case, if you like the project, please star the project on [GitHub](https://github.com/testcontainers/testcontainers-go/stargazers) and help spread the word :)
8+
Also join our [Slack workspace](http://slack.testcontainers.org) to get help, share your ideas, and chat with the community.
9+
10+
## Questions
11+
12+
GitHub is reserved for bug reports and feature requests; it is not the place for general questions.
13+
If you have a question or an unconfirmed bug, please visit our [Slack workspace](https://testcontainers.slack.com/);
14+
feedback and ideas are always welcome.
15+
16+
## Code contributions
17+
18+
If you have a bug fix or new feature that you would like to contribute, please find or open an [issue](https://github.com/testcontainers/testcontainers-go/issues) first.
19+
It's important to talk about what you would like to do, as there may already be someone working on it,
20+
or there may be context to be aware of before implementing the change.
21+
22+
Next would be to fork the repository and make your changes in a feature branch. **Please do not commit changes to the `main` branch**,
23+
otherwise we won't be able to contribute to your changes directly in the PR.
24+
25+
### Submitting your changes
26+
27+
Please just be sure to:
28+
29+
- follow the style, naming and structure conventions of the rest of the project.
30+
- make commits atomic and easy to merge.
31+
- use [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) for the PR title. This will help us to understand the nature of the changes, and to generate the changelog after all the commits in the PR are squashed.
32+
- Please use the `feat!`, `chore!`, `fix!`... types for breaking changes, as these categories are considered as `breaking change` in the changelog. Please use the `!` to denote a breaking change.
33+
- Please use the `security` type for security fixes, as these categories are considered as `security` in the changelog.
34+
- Please use the `feat` type for new features, as these categories are considered as `feature` in the changelog.
35+
- Please use the `fix` type for bug fixes, as these categories are considered as `bug` in the changelog.
36+
- Please use the `docs` type for documentation updates, as these categories are considered as `documentation` in the changelog.
37+
- Please use the `chore` type for housekeeping commits, including `build`, `ci`, `style`, `refactor`, `test`, `perf` and so on, as these categories are considered as `chore` in the changelog.
38+
- Please use the `deps` type for dependency updates, as these categories are considered as `dependencies` in the changelog.
39+
40+
!!!important
41+
There is a GitHub Actions workflow that will check if your PR title follows the conventional commits convention. If not, it contributes a failed check to your PR.
42+
To know more about the conventions, please refer to the [workflow file](https://github.com/testcontainers/testcontainers-go/blob/main/.github/workflows/conventions.yml).
43+
44+
- use [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) for your commit messages, as it improves the readability of the commit history, and the review process. Please follow the above conventions for the PR title.
45+
- unless necessary, please try to **avoid pushing --force** to the published branch you submitted a PR from, as it makes it harder to review the changes from a given previous state.
46+
- apply format running `make lint-all`. It will run `golangci-lint` for the core and modules with the configuration set in the root directory of the project. Please be aware that the lint stage on CI could fail if this is not done.
47+
- For linting just the modules: `make -C modules lint-modules`
48+
- For linting just the examples: `make -C examples lint-examples`
49+
- For linting just the modulegen: `make -C modulegen lint`
50+
- verify all tests are passing. Build and test the project with `make test-all` to do this.
51+
_ For a given module or example, go to the module or example directory and run `make test`.
52+
_ If you find an `ld warning` message on MacOS, you can ignore it. It is indeed a warning: https://github.com/golang/go/issues/61229
53+
54+
> === Errors
55+
> ld: warning: '/private/var/folders/3y/8hbf585d4yl6f8j5yzqx6wz80000gn/T/go-link-2319589277/000018.o' has malformed LC_DYSYMTAB, expected 98 undefined symbols to start at index 1626, found 95 undefined symbols starting at index 1626
56+
57+
- when updating the `go.mod` file, please run `make tidy-all` to ensure all modules are updated.
58+
59+
## Documentation contributions
60+
61+
The _Testcontainers for Go_ documentation is a static site built with [MkDocs](https://www.mkdocs.org/).
62+
We use the [Material for MkDocs](https://squidfunk.github.io/mkdocs-material/) theme, which offers a number of useful extensions to MkDocs.
63+
64+
We publish our documentation using Netlify.
65+
66+
### Adding code snippets
67+
68+
To include code snippets in the documentation, we use the [codeinclude plugin](https://github.com/rnorth/mkdocs-codeinclude-plugin), which uses the following syntax:
69+
70+
> &lt;!--codeinclude--&gt;<br/> > &#91;Human readable title for snippet&#93;(./relative_path_to_example_code.go) targeting_expression<br/> > &#91;Human readable title for snippet&#93;(./relative_path_to_example_code.go) targeting_expression<br/> > &lt;!--/codeinclude--&gt;<br/>
71+
72+
Where each title snippet in the same `codeinclude` block would represent a new tab
73+
in the snippet, and each `targeting_expression` would be:
74+
75+
- `block:someString` or
76+
- `inside_block:someString`
77+
78+
Please refer to the [codeinclude plugin documentation](https://github.com/rnorth/mkdocs-codeinclude-plugin) for more information.
79+
80+
### Previewing rendered content
81+
82+
From the root directory of the repository, you can use the following command to build and serve the documentation locally:
83+
84+
```shell
85+
make serve-docs
86+
```
87+
88+
It will use a Docker container to install the required dependencies and start a local server at `http://localhost:8000`.
89+
90+
Once finished, you can destroy the container with the following command:
91+
92+
```shell
93+
make clean-docs
94+
```
95+
96+
### PR Preview deployments
97+
98+
Note that documentation for pull requests will automatically be published by Netlify as 'deploy previews'.
99+
These deployment previews can be accessed via the `deploy/netlify` check that appears for each pull request.
100+
101+
Please check the GitHub comment Netlify posts on the PR for the URL to the deployment preview.

docs/contributing_docs.md

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# Contributing to documentation
2+
3+
The Testcontainers for Java documentation is a static site built with [MkDocs](https://www.mkdocs.org/).
4+
We use the [Material for MkDocs](https://squidfunk.github.io/mkdocs-material/) theme, which offers a number of useful extensions to MkDocs.
5+
6+
In addition we use a [custom plugin](https://github.com/rnorth/mkdocs-codeinclude-plugin) for inclusion of code snippets.
7+
8+
We publish our documentation using Netlify.
9+
10+
## Previewing rendered content
11+
12+
### Using Docker locally
13+
14+
The root of the project contains a `docker-compose.yml` file. Simply run `docker-compose up` and then access the docs at [http://localhost:8000](http://localhost:8000).
15+
16+
### Using Python locally
17+
18+
* Ensure that you have Python 3.8.0 or higher.
19+
* Set up a virtualenv and run `pip install -r requirements.txt` in the `testcontainers-java` root directory.
20+
* Once Python dependencies have been installed, run `mkdocs serve` to start a local auto-updating MkDocs server.
21+
22+
### PR Preview deployments
23+
24+
Note that documentation for pull requests will automatically be published by Netlify as 'deploy previews'.
25+
These deployment previews can be accessed via the `deploy/netlify` check that appears for each pull request.
26+
27+
## Codeincludes
28+
29+
The Gradle project under `docs/examples` is intended to hold compilable, runnable example code that can be included as
30+
snippets into the documentation at build-time.
31+
32+
As a result, we can have more confidence that code samples shown in the documentation is valid.
33+
34+
We use a custom plugin for MkDocs to include snippets into our docs.
35+
36+
A codeinclude block will resemble a regular markdown link surrounded by a pair of XML comments, e.g.:
37+
38+
<!--
39+
To prevent this from being rendered as a codeinclude when rendering this page, we use HTML tags.
40+
See this in its rendered form to understand its actual appearance, or look at other pages in the
41+
docs.
42+
-->
43+
44+
<pre><code>&lt;!--codeinclude--&gt;
45+
[Human readable title for snippet](./relative_path_to_example_code.java) targeting_expression
46+
&lt;!--/codeinclude--&gt;
47+
</code></pre>
48+
49+
Where `targeting_expression` could be:
50+
51+
* `block:someString` or
52+
* `inside_block:someString`
53+
54+
If these are provided, the macro will seek out any line containing the token `someString` and grab the next curly brace
55+
delimited block that it finds. `block` will grab the starting line and closing brace, whereas `inside_block` will omit
56+
these.
57+
58+
e.g., given:
59+
```java
60+
61+
public class FooService {
62+
63+
public void doFoo() {
64+
foo.doSomething();
65+
}
66+
67+
...
68+
69+
```
70+
71+
If we use `block:doFoo` as our targeting expression, we will have the following content included into our page:
72+
73+
```java
74+
public void doFoo() {
75+
foo.doSomething();
76+
}
77+
```
78+
79+
Whereas using `inside_block:doFoo` we would just have the inner content of the method included:
80+
81+
```java
82+
foo.doSomething();
83+
```
84+
85+
Note that:
86+
87+
* Any code included will have its indentation reduced
88+
* Every line in the source file will be searched for an instance of the token (e.g. `doFoo`). If more than one line
89+
includes that token, then potentially more than one block could be targeted for inclusion. It is advisable to use a
90+
specific, unique token to avoid unexpected behaviour.
91+
92+
When we wish to include a section of code that does not naturally appear within braces, we can simply insert our token,
93+
with matching braces, in a comment.
94+
While a little ugly, this has the benefit of working in any context and is easy to understand.
95+
For example:
96+
97+
```java
98+
public class FooService {
99+
100+
public void boringMethod() {
101+
doSomethingBoring();
102+
103+
// doFoo {
104+
doTheThingThatWeActuallyWantToShow();
105+
// }
106+
}
107+
108+
109+
```

0 commit comments

Comments
 (0)