Skip to content

Commit db0d749

Browse files
davidberenstein1957prmths128SaboniAmineinimazbenoit-cty
authored
docs: port documentation to Markdown with Zensical theme (#1073)
* docs: port documentation to Markdown with Zensical theme - Convert RST docs to Markdown format - Add zensical.yml configuration - Use CodeCarbon teal branding (matching logo) - Fix index.md formatting - Add proper headers and structure matching original RST * chore: update documentation and configuration for Zensical theme - Added deployment directory to .gitignore - Updated CONTRIBUTING.md to reflect changes in documentation structure - Replaced Sphinx with Zensical for documentation generation - Updated README and other documentation files to align with new structure - Removed obsolete zensical.toml and related files - Adjusted build commands in pyproject.toml for Zensical integration --------- Co-authored-by: Amine Saboni <saboni.amine@gmail.com> Co-authored-by: inimaz <93inigo93@gmail.com> * refactor(tests): format assertion for better readability in test_emissions_tracker_constant - Updated the assertion for cpu_power to improve code clarity by breaking it into multiple lines. * docs: add standalone installer instructions for non-Python users - Included instructions for downloading and running a standalone installer using curl for Unix-based systems and PowerShell for Windows users. - Updated command line section header to include an anchor for easier navigation. * ci: add GitHub Actions workflows for documentation build and deployment - Introduced `build-docs.yml` to automate Sphinx and Zensical documentation builds on push and pull request events. - Added `deploy-docs.yml` for deploying documentation to GitHub Pages with versioning on master branch pushes and release events. - Configured Python environment and dependencies for both workflows. * ci: update deploy-docs workflow to include script path and fix pip command - Added the path for `scripts/deploy-docs.sh` to the workflow triggers. - Corrected the pip installation command by removing the 'uv' prefix for clarity. * ci: update deploy-docs workflow to include script path and fix pip command - Added the path for `scripts/deploy-docs.sh` to the trigger paths in `deploy-docs.yml`. - Corrected the command to install dependencies from `uv pip install` to `pip install` for proper execution. * ci: refactor build-docs workflow to streamline documentation build process - Consolidated Sphinx and Zensical build steps into a single job. - Updated paths to trigger on changes to `mkdocs.yml` instead of `zensical.toml`. - Replaced Sphinx build commands with Zensical commands for documentation generation. - Adjusted Python version setup and dependency installation using `uv` for improved compatibility. * ci: update workflows to enhance documentation build and deployment - Added permissions for read access in `build-docs.yml` and adjusted the build command to use `uv run`. - Updated `deploy-docs.yml` to set permissions for write access and modified the version retrieval command to utilize `uv run` for consistency in execution. * docs(quickstart): add login and no-api guidance in markdown docs * fix(docs): address PR review comments - usage.md: remove def_list colon, fix indentation, remove escaping - comet.md, api.md: remove unnecessary escaping - rapl.md: fix Threadripper measurements formatting - output.md: add CodeCarbon API and Logfire sections - faq.md: update API data answer, link to methodology for hardware - mkdocs.yml: edit_uri master, Parameters nav label, add test_on_scaleway Made-with: Cursor * docs: update parameter documentation and fix formatting issues - Removed `grafana_token` parameter from the parameters table in `parameters.md`. - Corrected formatting inconsistencies in `methodology.md` and `visualize.md`, including adjustments to bullet points and mathematical expressions for clarity. * docs: enhance documentation and update mkdocs configuration - Added mkdocstrings plugin for improved documentation generation with Python support. - Updated navigation in mkdocs.yml to include the Parameters section. - Enhanced parameter descriptions in emissions_tracker.py for clarity and consistency. - Corrected minor typos in API and parameters documentation. - Introduced new check-docs-drift script in pyproject.toml for documentation consistency checks. * chore: update dependencies and workflow configurations - Added `setuptools` to the `dev` dependencies in `pyproject.toml` for improved package management. - Updated `uv.lock` to include specific versions of `setuptools` based on Python version compatibility. - Modified `build-docs.yml` to restrict branch triggers to `master` only, simplifying the workflow. * fix: add new line back between 1: & 2: * chore: add new lines for improved readability in various scripts - Added new lines in `check_powerstat_approach.py`, `intel_rapl_show.py`, `test_default_dram.py`, `test_dram_option.py`, `test_rapl_domains.py`, and `test_rapl_fix.py` for better code organization and readability. - Fixed formatting in `emissions_tracker.py` to ensure consistent spacing in parameter documentation. --------- Co-authored-by: Patrick LLORET <plloret@hyperlex.fr> Co-authored-by: Amine Saboni <saboni.amine@gmail.com> Co-authored-by: inimaz <93inigo93@gmail.com> Co-authored-by: inimaz <49730431+inimaz@users.noreply.github.com> Co-authored-by: benoit-cty <anne@onyme.fr> Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: LarytheLord <llawlietbagsum@gmail.com> Co-authored-by: Amine Saboni <43726203+SaboniAmine@users.noreply.github.com>
1 parent 521adc8 commit db0d749

235 files changed

Lines changed: 4365 additions & 45285 deletions

File tree

Some content is hidden

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

.github/copilot-instructions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Here's what you need to know to navigate and contribute effectively.
3838
### Key Directories
3939

4040
- **tests/** - Unit tests for the core package
41-
- **docs/** - Sphinx documentation (build with `uv run task docs`)
41+
- **docs/** - Zensical documentation (build with `uv run task docs`)
4242
- **examples/** - Usage examples and demos
4343
- **deploy/** - Deployment configurations and scripts
4444

.github/pyproject_versions.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def get_version_from_file(filepath: str, pattern: str) -> str:
3535

3636
def get_all_versions() -> dict:
3737
"""
38-
Read versions from all three files managed by bumpver.
38+
Read versions from files managed by bumpver.
3939
4040
:return: Dict containing versions from all files
4141
"""
@@ -60,11 +60,6 @@ def get_all_versions() -> dict:
6060
"codecarbon/_version.py", r'^__version__\s*=\s*["\']([^"\']+)["\']'
6161
)
6262

63-
# Get version from docs/edit/conf.py
64-
versions["docs_conf"] = get_version_from_file(
65-
"docs/edit/conf.py", r'^release\s*=\s*["\']([^"\']+)["\']'
66-
)
67-
6863
return versions
6964

7065

@@ -95,7 +90,6 @@ def check_version_coherence(quiet=False) -> bool:
9590
file_mapping = {
9691
"pyproject_toml": "pyproject.toml [tool.bumpver] current_version",
9792
"codecarbon_version": "codecarbon/_version.py __version__",
98-
"docs_conf": "docs/edit/conf.py release",
9993
}
10094
logging.error(f" {file_mapping[file_key]}: {version}")
10195
logging.error(

.github/workflows/build-docs.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Build Documentation
2+
3+
permissions:
4+
contents: read
5+
6+
on:
7+
push:
8+
branches: [master]
9+
paths:
10+
- "docs/**"
11+
- "mkdocs.yml"
12+
pull_request:
13+
branches: [master]
14+
paths:
15+
- "docs/**"
16+
- "mkdocs.yml"
17+
18+
jobs:
19+
build:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v4
23+
24+
- name: Install uv
25+
uses: astral-sh/setup-uv@caf0cab7a618c569241d31dcd442f54681755d39 # v3.2.4
26+
with:
27+
version: "latest"
28+
29+
- name: Set up Python
30+
run: uv python install 3.11
31+
32+
- name: Install dependencies
33+
run: uv sync --group doc
34+
35+
- name: Build docs
36+
run: uv run zensical build -f mkdocs.yml --clean

.github/workflows/deploy-docs.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Deploys docs to GitHub Pages with versioning.
2+
# Configure GitHub Pages: Settings > Pages > Source = "Deploy from a branch" > Branch = gh-pages
3+
4+
# Docs deploy to gh-pages with versioning. Set Pages: Settings > Pages > Source = gh-pages branch.
5+
6+
name: Deploy documentation
7+
8+
on:
9+
push:
10+
branches: [master]
11+
paths:
12+
- "docs/**"
13+
- "mkdocs.yml"
14+
- "scripts/deploy-docs.sh"
15+
- "codecarbon/_version.py"
16+
- "pyproject.toml"
17+
release:
18+
types: [published]
19+
20+
permissions:
21+
contents: read
22+
23+
concurrency:
24+
group: deploy-docs
25+
cancel-in-progress: false
26+
27+
jobs:
28+
deploy:
29+
runs-on: ubuntu-latest
30+
permissions:
31+
contents: write # push to gh-pages
32+
steps:
33+
- name: Checkout
34+
uses: actions/checkout@v4
35+
with:
36+
fetch-depth: 0
37+
38+
- name: Install uv
39+
uses: astral-sh/setup-uv@caf0cab7a618c569241d31dcd442f54681755d39 # v3.2.4
40+
with:
41+
version: "latest"
42+
43+
- name: Set up Python
44+
run: uv python install 3.11
45+
46+
- name: Install dependencies
47+
run: uv sync --group doc
48+
49+
- name: Get version
50+
id: version
51+
run: |
52+
if [[ "${{ github.event_name }}" == "release" ]]; then
53+
VERSION="${{ github.event.release.tag_name }}"
54+
VERSION="${VERSION#v}"
55+
else
56+
VERSION=$(uv run python -c "from codecarbon._version import __version__; print(__version__)")
57+
fi
58+
echo "full=$VERSION" >> $GITHUB_OUTPUT
59+
60+
- name: Build docs
61+
run: uv run zensical build -f mkdocs.yml --clean
62+
63+
- name: Deploy to GitHub Pages
64+
env:
65+
GITHUB_REPOSITORY: ${{ github.repository }}
66+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
67+
run: |
68+
chmod +x scripts/deploy-docs.sh
69+
scripts/deploy-docs.sh "${{ steps.version.outputs.full }}"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ venv.bak/
103103

104104
# mkdocs documentation
105105
/site
106+
/deploy
106107

107108
# mypy
108109
.mypy_cache/

CONTRIBUTING.md

Lines changed: 58 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,34 @@
44

55
<!-- TOC start (generated with https://github.com/derlin/bitdowntoc) -->
66

7-
- [</a> Have a Question?](#have-a-question)
8-
- [</a> Found a Bug?](#found-a-bug)
9-
- [</a> Have a Feature Request?](#have-a-feature-request)
10-
- [Alternative ways of contributing](#alternative-ways-of-contributing)
11-
- [</a> Ready to Contribute!](#ready-to-contribute)
12-
* [Installation](#installation)
13-
* [Some UV commands](#some-uv-commands)
14-
* [Tests](#tests)
15-
* [Stress your computer](#stress-your-computer)
16-
* [Update all dependancies](#update-all-dependancies)
17-
* [Branching and Pull Requests](#branching-and-pull-requests)
18-
* [Debug in VS Code](#debug-in-vs-code)
19-
* [Coding style && Linting](#coding-style-linting)
20-
* [Dependencies management](#dependencies-management)
21-
* [Build Documentation 🖨️](#build-documentation)
22-
* [Release process](#release-process)
23-
+ [Test the build in Docker](#test-the-build-in-docker)
24-
- [API and Dashboard](#api-and-dashboard)
25-
* [CSV Dashboard](#csv-dashboard)
26-
* [Web dashboard](#web-dashboard)
27-
* [API](#api)
28-
* [Test the API](#test-the-api)
29-
* [Restore database from a production Backup](#restore-database-from-a-production-backup)
30-
* [Deployment](#deployment)
31-
+ [API](#api-1)
32-
+ [Dashboard](#dashboard)
33-
- [License](#license)
7+
- [Contributing to Code Carbon](#contributing-to-code-carbon)
8+
- [ Have a Question?](#-have-a-question)
9+
- [ Found a Bug?](#-found-a-bug)
10+
- [ Have a Feature Request?](#-have-a-feature-request)
11+
- [Alternative ways of contributing](#alternative-ways-of-contributing)
12+
- [ Ready to Contribute!](#-ready-to-contribute)
13+
- [Installation](#installation)
14+
- [Some UV commands](#some-uv-commands)
15+
- [Tests](#tests)
16+
- [Stress your computer](#stress-your-computer)
17+
- [Update all dependancies](#update-all-dependancies)
18+
- [Branching and Pull Requests](#branching-and-pull-requests)
19+
- [Debug in VS Code](#debug-in-vs-code)
20+
- [Coding style \&\& Linting](#coding-style--linting)
21+
- [Dependencies management](#dependencies-management)
22+
- [Build Documentation 🖨️](#build-documentation-️)
23+
- [Release process](#release-process)
24+
- [Test the build in Docker](#test-the-build-in-docker)
25+
- [API and Dashboard](#api-and-dashboard)
26+
- [CSV Dashboard](#csv-dashboard)
27+
- [Web dashboard](#web-dashboard)
28+
- [API](#api)
29+
- [Test the API](#test-the-api)
30+
- [Restore database from a production Backup](#restore-database-from-a-production-backup)
31+
- [Deployment](#deployment)
32+
- [API](#api-1)
33+
- [Dashboard](#dashboard)
34+
- [License](#license)
3435

3536
<!-- TOC end -->
3637

@@ -225,7 +226,7 @@ Here is the launch.json to be able to debug examples and tests:
225226

226227
Then run opened test with this button:
227228

228-
![vscode_debug](docs/edit/images/vscode_debug.png)
229+
![vscode_debug](docs/images/vscode_debug.png)
229230

230231

231232
<!-- TOC --><a name="coding-style-linting"></a>
@@ -271,15 +272,40 @@ Dependencies are defined in different places:
271272
### Build Documentation 🖨️
272273

273274
No software is complete without great documentation!
274-
To make generating documentation easier, we use [`sphinx` package](https://www.sphinx-doc.org/en/master/usage/installation.html#installation-from-pypi).
275+
To make generating documentation easier, we use [Zensical](https://zensical.org/).
275276

276-
In order to make changes, edit the `.rst` files that are in the `/docs/edit` folder, and then run in root folder:
277+
In order to make changes, edit the `.md` files in the `/docs` folder, and then run in root folder:
277278

278279
```sh
279280
uv run --only-group doc task docs
280281
```
281282

282-
to regenerate the html files.
283+
to regenerate the html files. For local preview with live reload, run `uv run --only-group doc task docs-serve`.
284+
285+
### Rebase your branch on master
286+
287+
Before creating a PR, please make sure to rebase your branch on master to avoid merge conflicts and make the review easier. You can do it with the following command:
288+
```sh
289+
# Be careful, this command will delete every local changes you have, make sure to commit or stash them before running it
290+
TARGET_BRANCH=master
291+
current_branch=$(git symbolic-ref --short HEAD)
292+
git switch $TARGET_BRANCH && git pull
293+
git switch $current_branch --force && git fetch origin $TARGET_BRANCH
294+
git rebase $TARGET_BRANCH
295+
```
296+
297+
In case of a conflict during a rebase, "incoming" refers to your branch, and "current" refers to master. This is because the commits from your branch are being applied to master, so they are incoming. In case of a merge, it's the opposite!
298+
299+
Check if everything is fine:
300+
301+
```sh
302+
git status
303+
```
304+
305+
Push force
306+
```sh
307+
git push --force-with-lease
308+
```
283309

284310
### Rebase your branch on master
285311

@@ -313,7 +339,7 @@ git push --force-with-lease
313339
- Create a PR bumping the version with `uv run bumpver update --patch`. For a release candidate, use `uv run bumpver update --set-version 3.0.0_rc1`.
314340
- Run `uv run python .github/pyproject_versions.py -c` to check version consistancy.
315341
- Update the dependencies with `uv sync --upgrade`
316-
- [Build Documentation](#documentation) with `uv run --only-group doc task docs`.
342+
- [Build Documentation](#build-documentation) with `uv run --only-group doc task docs`.
317343
- Push the changes.
318344
- Merge the PR.
319345
- Wait for the Github Action `ReleaseDrafter` to finish running on the merge commit.

README.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
![banner](docs/edit/images/banner.png)
1+
![banner](docs/images/banner.png)
22

33
Estimate and track carbon emissions from your computer, quantify and analyze their impact.
44

@@ -22,14 +22,18 @@ CodeCarbon websites:
2222

2323
- [About CodeCarbon 💡](#about-codecarbon-)
2424
- [Quickstart 🚀](#quickstart-)
25-
- [Installation 🔧](#installation-)
26-
- [Start to estimate your impact 📏](#start-to-estimate-your-impact-)
27-
- [Monitoring your whole machine](#monitoring-your-machine-)
28-
- [In your python code](#in-your-python-code-)
29-
- [Visualize](#visualize-)
25+
- [Installation 🔧](#installation-)
26+
- [Start to estimate your impact 📏](#start-to-estimate-your-impact-)
27+
- [Without using the online dashboard](#without-using-the-online-dashboard)
28+
- [With the online dashboard](#with-the-online-dashboard)
29+
- [Monitoring your machine 💻](#monitoring-your-machine-)
30+
- [Detecting your hardware 🔍](#detecting-your-hardware-)
31+
- [In your Python code 🐍](#in-your-python-code-)
32+
- [Visualize 📊](#visualize-)
3033
- [Contributing 🤝](#contributing-)
3134
- [How To Cite 📝](#how-to-cite-)
3235
- [Contact 📝](#contact-)
36+
- [Star History](#star-history)
3337

3438
# About CodeCarbon 💡
3539

@@ -45,7 +49,7 @@ At **CodeCarbon**, we believe, along with Niels Bohr, that "Nothing exists until
4549

4650
We created a Python package that estimates your hardware electricity power consumption (GPU + CPU + RAM) and we apply to it the carbon intensity of the region where the computing is done.
4751

48-
![calculation Summary](docs/edit/images/calculation.png)
52+
![calculation Summary](docs/images/calculation.png)
4953

5054
We explain more about this calculation in the [**Methodology**](https://mlco2.github.io/codecarbon/methodology.html#) section of the documentation.
5155

@@ -128,7 +132,7 @@ There is other ways to use **codecarbon** package, please refer to the documenta
128132
## Visualize 📊
129133

130134
You can now visualize your experiment emissions on the [dashboard](https://dashboard.codecarbon.io/).
131-
![dashboard](docs/edit/images/dashboard.png)
135+
![dashboard](docs/images/dashboard.png)
132136

133137

134138
> Hope you enjoy your first steps monitoring your carbon computing impact!

0 commit comments

Comments
 (0)