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

Ensure developer docs reflect the current version of Go #33643

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions docs/public/.hooks/inject_variables.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from functools import cache
from pathlib import Path

from markdown.preprocessors import Preprocessor


@cache
def variable_replacements():
return {
f"<<<{variable}>>>": replacement
for variable, replacement in (
("GO_VERSION", get_go_version()),
)
}


def get_go_version():
return Path(".go-version").read_text(encoding="utf-8").strip()


class VariableInjectionPreprocessor(Preprocessor):
def run(self, lines): # noqa: PLR6301
markdown = "\n".join(lines)
for variable, replacement in variable_replacements().items():
markdown = markdown.replace(variable, replacement)

return markdown.splitlines()
24 changes: 24 additions & 0 deletions docs/public/.hooks/plugin_register.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import os
import sys

from markdown.extensions import Extension

HERE = os.path.dirname(__file__)


def on_config(
config,
**kwargs, # noqa: ARG001
):
config.markdown_extensions.append(GlobalExtension())


class GlobalExtension(Extension):
def extendMarkdown(self, md): # noqa: N802, PLR6301
sys.path.insert(0, HERE)

from inject_variables import VariableInjectionPreprocessor

md.preprocessors.register(VariableInjectionPreprocessor(), VariableInjectionPreprocessor.__name__, 100)

sys.path.pop(0)
4 changes: 2 additions & 2 deletions docs/public/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ After downloading the archive corresponding to your platform and architecture, e
deva is available on PyPI and can be installed with [pip](https://github.com/pypa/pip).

```
pip install deva
pip install datadog-agent-dev
```

!!! warning
Expand Down Expand Up @@ -150,7 +150,7 @@ See also some notes in [./checks](https://github.com/DataDog/datadog-agent/tree/

### Golang

You must [install Golang](https://golang.org/doc/install) version `1.23.5` or later. Make sure that `$GOPATH/bin` is in your `$PATH`, otherwise [tooling](#tooling) cannot use any additional tool it might need.
You must [install Golang](https://golang.org/doc/install) version `<<<GO_VERSION>>>` or later. Make sure that `$GOPATH/bin` is in your `$PATH`, otherwise [tooling](#tooling) cannot use any additional tool it might need.

!!! note
Versions of Golang that aren't an exact match to the version specified in our build images (see e.g. [here](https://github.com/DataDog/datadog-agent-buildimages/blob/c025473ee467ee6d884d532e4c12c7d982ce8fe1/circleci/Dockerfile#L43)) may not be able to build the agent and/or the [rtloader](https://github.com/DataDog/datadog-agent/tree/main/rtloader) binary properly.
Expand Down
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ nav:
- Internals: architecture/dogstatsd/internals.md

hooks:
- docs/public/.hooks/plugin_register.py
- docs/public/.hooks/title_from_content.py

plugins:
Expand Down
1 change: 0 additions & 1 deletion tasks/update_go.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
("./cmd/process-agent/README.md", "`go >= ", "`", False),
("./pkg/logs/launchers/windowsevent/README.md", "install go ", "+,", False),
("./.wwhrd.yml", "raw.githubusercontent.com/golang/go/go", "/LICENSE", True),
("./docs/public/setup.md", "version `", "` or later", True),
("./go.work", "go ", "", False),
("./go.work", "toolchain go", "", True),
]
Expand Down
Loading