Skip to content

Commit a32b03d

Browse files
authored
Merge pull request #1118 from mlco2/issue-1108
docs: restructure documentation using Diataxis framework
2 parents 7f09936 + 462b216 commit a32b03d

73 files changed

Lines changed: 4652 additions & 2918 deletions

Some content is hidden

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

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ What types of changes does your code introduce? Put an `x` in all the boxes that
2020

2121
## AI Usage Disclosure
2222

23-
Please refer to [docs/contributing/AI_POLICY.md](https://github.com/mlco2/codecarbon/blob/master/docs/contributing/AI_POLICY.md) for detailed guidelines on how to disclose AI usage in your PR. Accurately completing this section is mandatory.
23+
Please refer to [docs/how-to/ai-policy.md](https://docs.codecarbon.io/how-to/ai_policy/) for detailed guidelines on how to disclose AI usage in your PR. Accurately completing this section is mandatory.
2424

2525
- [ ] 🟥 AI-vibecoded: You cannot explain the logic. Car analogy : the car drive by itself, you are outside it and just tell it where to go.
2626
- [ ] 🟠 AI-generated: Car analogy : the car drive by itself, you are inside and give instructions.
@@ -32,7 +32,7 @@ Go over all the following points, and put an `x` in all the boxes that apply.
3232
- [ ] My code follows the code style of this project.
3333
- [ ] My change requires a change to the documentation.
3434
- [ ] I have updated the documentation accordingly.
35-
- [ ] I have read the **[docs/contributing/CONTRIBUTING.md](https://github.com/mlco2/codecarbon/blob/master/docs/contributing/CONTRIBUTING.md)** document.
35+
- [ ] I have read the **[docs/how-to/contributing.md](https://docs.codecarbon.io/how-to/contributing/)** document.
3636
- [ ] I have added tests to cover my changes.
3737
- [ ] All new and existing tests passed.
3838

.github/copilot-instructions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
../docs/contributing/agents-instructions.md
1+
../docs/how-to/agent-instructions.md

.github/workflows/build-docs.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ on:
99
paths:
1010
- "docs/**"
1111
- "mkdocs.yml"
12+
- "pyproject.toml"
13+
- "uv.lock"
14+
- "scripts/check_docs_links.py"
15+
- ".github/workflows/build-docs.yml"
1216
pull_request:
1317
branches: [master]
14-
paths:
15-
- "docs/**"
16-
- "mkdocs.yml"
17-
- ".github/workflows/build-docs.yml"
1818

1919
jobs:
2020
build:
@@ -23,7 +23,7 @@ jobs:
2323
- uses: actions/checkout@v4
2424

2525
- name: Install uv
26-
uses: astral-sh/setup-uv@caf0cab7a618c569241d31dcd442f54681755d39 # v3.2.4
26+
uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57 # v8.0.0
2727
with:
2828
version: "latest"
2929

@@ -36,10 +36,11 @@ jobs:
3636
- name: Build docs
3737
run: |
3838
set -euo pipefail
39-
# Run zensical and capture output, fail if command exits non-zero
4039
uv run zensical build -f mkdocs.yml --clean 2>&1 | tee docs_build.log
41-
# If output contains common error indicators, fail the step.
4240
if grep -Ei "\b(error|failed|traceback|exception)\b" docs_build.log >/dev/null; then
4341
echo "Documentation build produced errors; failing workflow."
4442
exit 1
4543
fi
44+
45+
- name: Check documentation links (site/)
46+
run: uv run python scripts/check_docs_links.py site

.github/workflows/build-server.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ jobs:
1515
build_server:
1616
runs-on: ubuntu-latest
1717
steps:
18-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
18+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
1919
- name: Install uv
20-
uses: astral-sh/setup-uv@caf0cab7a618c569241d31dcd442f54681755d39 # v3.2.4
20+
uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57 # v8.0.0
2121
with:
2222
version: "latest"
2323
- name: Set up Python
@@ -52,9 +52,9 @@ jobs:
5252
# Maps tcp port 5432 on service container to the host
5353
- 5480:5432
5454
steps:
55-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
55+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
5656
- name: Install uv
57-
uses: astral-sh/setup-uv@caf0cab7a618c569241d31dcd442f54681755d39 # v3.2.4
57+
uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57 # v8.0.0
5858
with:
5959
version: "latest"
6060
- name: Set up Python

.github/workflows/build-ui.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
build-ui:
2222
runs-on: ubuntu-22.04
2323
steps:
24-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
24+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2525
- name: Use Node.js
2626
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
2727
with:

.github/workflows/codeql.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
# your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
5252
steps:
5353
- name: Checkout repository
54-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
54+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
5555

5656
# Add any setup steps before running the `github/codeql-action/init` action.
5757
# This includes steps like installing compilers or runtimes (`actions/setup-node`

.github/workflows/deploy-docs.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ on:
1414
- "scripts/deploy-docs.sh"
1515
- "codecarbon/_version.py"
1616
- "pyproject.toml"
17+
- "scripts/check_docs_links.py"
1718
release:
1819
types: [published]
1920

@@ -36,7 +37,7 @@ jobs:
3637
fetch-depth: 0
3738

3839
- name: Install uv
39-
uses: astral-sh/setup-uv@caf0cab7a618c569241d31dcd442f54681755d39 # v3.2.4
40+
uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57 # v8.0.0
4041
with:
4142
version: "latest"
4243

@@ -60,6 +61,9 @@ jobs:
6061
- name: Build docs
6162
run: uv run zensical build -f mkdocs.yml --clean
6263

64+
- name: Check documentation links
65+
run: uv run python scripts/check_docs_links.py site
66+
6367
- name: Deploy to GitHub Pages
6468
env:
6569
GITHUB_REPOSITORY: ${{ github.repository }}

.github/workflows/deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
runs-on: ubuntu-latest
1717
steps:
1818
- name: Checkout code
19-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
19+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2020
with:
2121
fetch-depth: 0 # Same as git fetch --unshallow
2222
clean: true # Remove any untracked files or modifications

.github/workflows/package-validation-reusable.yml

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@ env:
1111

1212
jobs:
1313
build-package:
14+
if: github.event_name == 'release' || github.ref == 'refs/heads/master' || (github.event_name == 'pull_request' && github.base_ref == 'master')
1415
runs-on: ubuntu-latest
1516
steps:
16-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
17+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
1718
- name: Install uv
18-
uses: astral-sh/setup-uv@caf0cab7a618c569241d31dcd442f54681755d39 # v3.2.4
19+
uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57 # v8.0.0
1920
with:
2021
version: "latest"
2122
- name: Set up Python
@@ -25,7 +26,7 @@ jobs:
2526
- name: Build pip package
2627
run: uv build
2728
- name: Archive Pypi artifacts
28-
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
29+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
2930
with:
3031
name: pypi_dist
3132
path: dist
@@ -34,40 +35,37 @@ jobs:
3435
runs-on: ubuntu-24.04
3536
needs: [build-package]
3637
steps:
37-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
38+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
3839
with:
3940
sparse-checkout: |
4041
tests/
4142
pytest.ini
43+
docs/
44+
pyproject.toml
45+
uv.lock
4246
sparse-checkout-cone-mode: false
4347
- name: Install uv
44-
uses: astral-sh/setup-uv@caf0cab7a618c569241d31dcd442f54681755d39 # v3.2.4
48+
uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57 # v8.0.0
4549
with:
4650
version: "latest"
4751
- name: Set up Python
4852
run: uv python install ${{ env.MAIN_PYTHON_VERSION }}
4953
- name: Download built package
50-
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
54+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
5155
with:
5256
name: pypi_dist
5357
path: dist
54-
- name: Create clean virtual environment
58+
- name: Sync dev dependencies from lockfile and install wheel
5559
run: |
56-
uv venv .venv --python ${{ env.MAIN_PYTHON_VERSION }}
57-
echo "VIRTUAL_ENV=$PWD/.venv" >> $GITHUB_ENV
58-
echo "$PWD/.venv/bin" >> $GITHUB_PATH
59-
- name: Install package from wheel (without source)
60-
run: |
61-
# Install the wheel and test dependencies without the source code
62-
uv pip install dist/*.whl
63-
uv pip install pytest pytest-mock requests-mock responses pandas logfire
60+
uv sync --python ${{ env.MAIN_PYTHON_VERSION }} --frozen --no-install-project --group dev
61+
uv pip install --python .venv/bin/python dist/*.whl
6462
- name: Test package integrity
6563
run: |
66-
# Run the package integrity tests to verify all data files are included
67-
uv run python -m pytest tests/test_package_integrity.py -v
68-
CODECARBON_ALLOW_MULTIPLE_RUNS=True pytest --ignore=tests/test_viz_data.py -vv -m 'not integ_test' tests/
64+
.venv/bin/python -m pytest tests/test_package_integrity.py -v
65+
CODECARBON_ALLOW_MULTIPLE_RUNS=True .venv/bin/python -m pytest \
66+
--ignore=tests/test_viz_data.py \
67+
-vv -m 'not integ_test' tests/
6968
- name: Test CLI functionality
7069
run: |
71-
# Test that the CLI is functional
72-
codecarbon --help
73-
python -c "from codecarbon import EmissionsTracker; print('Package import successful')"
70+
.venv/bin/codecarbon --help
71+
.venv/bin/python -c "from codecarbon import EmissionsTracker; print('Package import successful')"

.github/workflows/pre-commit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
pre-commit:
1313
runs-on: ubuntu-latest
1414
steps:
15-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
15+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
1616
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
1717
- name: set PY
1818
run: echo "PY=$(python -c 'import hashlib, sys;print(hashlib.sha256(sys.version.encode()+sys.executable.encode()).hexdigest())')" >> $GITHUB_ENV

0 commit comments

Comments
 (0)