Skip to content

Commit e854757

Browse files
committed
docs: generating module docs, fixing build settings, and working on the standard docs pages for python
1 parent fadb4dc commit e854757

File tree

100 files changed

+6292
-259
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+6292
-259
lines changed

Makefile

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,12 @@ DOCS_DOCKERFILE := Dockerfile.docs
7878
.PHONY: clean-docs
7979
clean-docs:
8080
@echo "Destroying docs"
81-
docker rm -f $(DOCS_CONTAINER) || true
82-
docker rmi $(DOCS_IMAGE) || true
81+
@if docker ps -a --format '{{.Names}}' | grep -q '^$(DOCS_CONTAINER)$$'; then \
82+
docker rm -f $(DOCS_CONTAINER); \
83+
fi
84+
@if docker images -q $(DOCS_IMAGE) | grep -q .; then \
85+
docker rmi $(DOCS_IMAGE); \
86+
fi
8387

8488
.PHONY: docs-ensure-image
8589
docs-ensure-image:
@@ -96,15 +100,6 @@ serve-docs: docs-ensure-image
96100
cd docs && poetry install --no-root && \
97101
poetry run mkdocs serve -f ../mkdocs.yml -a 0.0.0.0:8000"
98102

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-
108103
# Needed if dependencies are added to the docs site
109104
.PHONY: export-docs-deps
110105
export-docs-deps:

docs/contributing.md

Lines changed: 72 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,96 @@
1-
# Contributing
1+
# Contributing to `testcontainers-python`
22

3-
`Testcontainers for Go` is open source, and we love to receive contributions from our community — you!
3+
Welcome to the `testcontainers-python` community!
4+
This should give you an idea about how we build, test and release `testcontainers-python`!
45

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+
Highly recommended to read this document thoroughly to understand what we're working on right now
7+
and what our priorities are before you are trying to contribute something.
68

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+
This will greatly increase your chances of getting prompt replies as the maintainers are volunteers themselves.
910

10-
## Questions
11+
## Before you begin
1112

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.
13+
We recommend following these steps:
1514

16-
## Code contributions
15+
1. Finish reading this document.
16+
2. Read the [recently updated issues](https://github.com/testcontainers/testcontainers-python/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc){:target="\_blank"}
17+
3. Look for existing issues on the subject you are interested in - we do our best to label everything correctly
1718

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.
19+
## Local development
2120

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.
21+
### Pre-Requisites
2422

25-
### Submitting your changes
23+
You need to have the following tools available to you:
2624

27-
Please just be sure to:
25+
- `make` - You'll need a GNU Make for common developer activities
26+
- `poetry` - This is the primary package manager for the project
27+
- `pyenv` **Recommended**: For installing python versions for your system.
28+
Poetry infers the current latest version from what it can find on the `PATH` so you are still fine if you don't use `pyenv`.
2829

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.
30+
### Build and test
3931

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).
32+
- Run `make install` to get `poetry` to install all dependencies and set up `pre-commit`
33+
- **Recommended**: Run `make` or `make help` to see other commands available to you.
34+
- After this, you should have a working virtual environment and proceed with writing code with your favorite IDE
35+
- **TIP**: You can run `make core/tests` or `make modules/<my-module>/tests` to run the tests specifically for that to speed up feedback cycles
36+
- You can also run `make lint` to run the `pre-commit` for the entire codebase.
4337

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
38+
## Adding new modules
5339

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
40+
We have an [issue template](https://github.com/testcontainers/testcontainers-python/blob/main/.github/ISSUE_TEMPLATE/new-container.md){:target="\_blank"} for adding new module containers, please refer to that for more information.
41+
Once you've talked to the maintainers (we do our best to reply!) then you can proceed with contributing the new container.
5642

57-
- when updating the `go.mod` file, please run `make tidy-all` to ensure all modules are updated.
43+
!!!WARNING
44+
45+
Please raise an issue before you try to contribute a new container! It helps maintainersunderstand your use-case and motivation.
46+
This way we can keep pull requests forced on the "how", not the "why"! :pray:
47+
It also gives maintainers a chance to give you last-minute guidance on caveats orexpectations, particularly with
48+
new extra dependencies and how to manage them.
49+
50+
### Module documentation
51+
52+
Leave examples for others with your mew module such as `modules/<new_module>/basic_example.py`. You can create as many examples as you want.
53+
54+
Create a new `docs/modules/<new_module>.md` describing the basic use of the new container. There is a [starter template provided here](https://raw.githubusercontent.com/testcontainers/testcontainers-python/blob/main/docs/modules/template.md){:target="\_blank"}.
55+
56+
!!! important
57+
58+
Make sure to add your new module to the sidebar nav in the `mkdocs.yml`
59+
60+
## Raising issues
61+
62+
We have [Issue Templates](https://raw.githubusercontent.com/testcontainers/testcontainers-python/refs/heads/main/.github/ISSUE_TEMPLATE/new-container.md){:target="\_blank"} to cover most cases, please try to adhere to them, they will guide you through the process.
63+
Try to look through the existing issues before you raise a new one.
64+
65+
## Releasing versions
66+
67+
We have automated Semantic Versioning and release via [release-please](https://github.com/testcontainers/testcontainers-python/blob/main/.github/workflows/release-please.yml){:target="\_blank"}.
68+
This takes care of:
69+
70+
- Detecting the next version, based on the commits that landed on `main`
71+
- When a Release PR has been merged
72+
- Create a GitHub Release with the CHANGELOG included
73+
- Update the [CHANGELOG](https://github.com/testcontainers/testcontainers-python/blob/main/CHANGELOG.md){:target="\_blank"}, similar to the GitHub Release
74+
- Release to PyPI via a [trusted publisher](https://docs.pypi.org/trusted-publishers/using-a-publisher/){:target="\_blank"}
75+
- Automatically script updates in files where it's needed instead of hand-crafting it (i.e. in `pyproject.toml`)
76+
77+
!!!DANGER
78+
79+
Community modules are supported on a best-effort basis and for maintenance reasons, any change to them
80+
is only covered under minor and patch changes.
81+
Community modules changes DO NOT contribute to major version changes!
82+
If your community module container was broken by a minor or patch version change, check out the change logs!
5883

5984
## Documentation contributions
6085

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.
86+
The _Testcontainers for Go_ documentation is a static site built with [MkDocs](https://www.mkdocs.org/){:target="\_blank"}.
87+
We use the [Material for MkDocs](https://squidfunk.github.io/mkdocs-material/){:target="\_blank"} theme, which offers a number of useful extensions to MkDocs.
6388

6489
We publish our documentation using Netlify.
6590

6691
### Adding code snippets
6792

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:
93+
To include code snippets in the documentation, we use the [codeinclude plugin](https://github.com/rnorth/mkdocs-codeinclude-plugin){:target="\_blank"}, which uses the following syntax:
6994

7095
> &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/>
7196
@@ -75,7 +100,7 @@ in the snippet, and each `targeting_expression` would be:
75100
- `block:someString` or
76101
- `inside_block:someString`
77102

78-
Please refer to the [codeinclude plugin documentation](https://github.com/rnorth/mkdocs-codeinclude-plugin) for more information.
103+
Please refer to the [codeinclude plugin documentation](https://github.com/rnorth/mkdocs-codeinclude-plugin){:target="\_blank"} for more information.
79104

80105
### Previewing rendered content
81106

@@ -93,7 +118,7 @@ Once finished, you can destroy the container with the following command:
93118
make clean-docs
94119
```
95120

96-
### PR Preview deployments
121+
### PR preview deployments
97122

98123
Note that documentation for pull requests will automatically be published by Netlify as 'deploy previews'.
99124
These deployment previews can be accessed via the `deploy/netlify` check that appears for each pull request.

docs/contributing_docs.md

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

docs/css/extra.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,3 +126,11 @@ body .card-grid-item:focus {
126126
height: 1.75em;
127127
}
128128
}
129+
130+
.md-typeset__table {
131+
min-width: 100%;
132+
}
133+
134+
.md-typeset table:not([class]) {
135+
display: table;
136+
}

docs/features/configuration.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Custom configuration
2+
3+
.....
4+
5+
## Docker host detection
6+
7+
_Testcontainers for Go_ will attempt to detect the Docker environment and configure everything to work automatically.
8+
9+
However, sometimes customization is required. _Testcontainers for Go_ will respect the following order:
10+
11+
1. Read the **tc.host** property in the `~/.testcontainers.properties` file. E.g. `tc.host=tcp://my.docker.host:1234`
12+
13+
2. Read the **DOCKER_HOST** environment variable. E.g. `DOCKER_HOST=unix:///var/run/docker.sock`
14+
See [Docker environment variables](https://docs.docker.com/engine/reference/commandline/cli/#environment-variables) for more information.
15+
16+
3. Read the Go context for the **DOCKER_HOST** key. E.g. `ctx.Value("DOCKER_HOST")`. This is used internally for the library to pass the Docker host to the resource reaper.
17+
18+
4. Read the default Docker socket path, without the unix schema. E.g. `/var/run/docker.sock`
19+
20+
5. Read the **docker.host** property in the `~/.testcontainers.properties` file. E.g. `docker.host=tcp://my.docker.host:1234`
21+
22+
6. Read the rootless Docker socket path, checking in the following alternative locations:
23+
24+
1. `${XDG_RUNTIME_DIR}/.docker/run/docker.sock`.
25+
2. `${HOME}/.docker/run/docker.sock`.
26+
3. `${HOME}/.docker/desktop/docker.sock`.
27+
4. `/run/user/${UID}/docker.sock`, where `${UID}` is the user ID of the current user.
28+
29+
7. The library panics if none of the above are set, meaning that the Docker host was not detected.

0 commit comments

Comments
 (0)