diff --git a/.devcontainer/Dockerfile.dev b/.devcontainer/Dockerfile.dev new file mode 100644 index 000000000..3537c3e86 --- /dev/null +++ b/.devcontainer/Dockerfile.dev @@ -0,0 +1,19 @@ +FROM mcr.microsoft.com/vscode/devcontainers/python:0-3.10 + +SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +RUN \ + curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \ + && apt-get update \ + && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + # Additional library needed by some tests and accordingly by VScode Tests Discovery + gettext \ + git \ + hunspell \ + hunspell-fr-comprehensive \ + make \ + python3-pip \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +ENV SHELL /bin/bash \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 000000000..dafca84c5 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,28 @@ +{ + "name": "Environnement de traduction française de la Documentation Python", + "context": "..", + "dockerFile": "./Dockerfile.dev", + "postCreateCommand": ".devcontainer/script/setup", + "containerEnv": { + "DEVCONTAINER": "1" + }, + "forwardPorts": [8000], + "runArgs": [ + "-e", + "GIT_EDITOR=code --wait" + ], + "extensions": [ + "mrorz.language-gettext" + ], + "settings": { + "editor.rulers": [ + 79 + ], + "terminal.integrated.profiles.linux": { + "zsh": { + "path": "/usr/bin/zsh" + } + }, + "terminal.integrated.defaultProfile.linux": "zsh" + } +} \ No newline at end of file diff --git a/.devcontainer/script/setup b/.devcontainer/script/setup new file mode 100755 index 000000000..ab08d736d --- /dev/null +++ b/.devcontainer/script/setup @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +# Setups the repository + +# Stop on errors +set -e + +# Go to base directory +cd "$(git rev-parse --show-toplevel)" + +# Install venv +make venv/cpython/.git/HEAD + +# Install python deps +python3 -m pip install -r requirements.txt -r venv/cpython/Doc/requirements.txt +make ensure_prerequisites + +# Generate .vscode configuration +if [ ! -d ".vscode" ]; then + mkdir .vscode + cp .devcontainer/vscode/*.json .vscode/ +fi + +# Install and configure pre-commit +python3 -m pip install pre-commit +pre-commit install diff --git a/.devcontainer/vscode/tasks.json b/.devcontainer/vscode/tasks.json new file mode 100644 index 000000000..df5ab0672 --- /dev/null +++ b/.devcontainer/vscode/tasks.json @@ -0,0 +1,61 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "verifs: vérifications de longueur de ligne et d'orthographe", + "type": "shell", + "command": "make verifs", + "group": "lint", + "presentation": { + "reveal": "always", + "panel": "new" + }, + "problemMatcher": [] + }, + { + "label": "make: génère la documentation", + "type": "shell", + "command": "make", + "group": "build", + "presentation": { + "reveal": "always", + "panel": "new" + }, + "problemMatcher": [] + }, + { + "label": "serve: publie la documentation localement", + "type": "shell", + "command": "make serve", + "group": "build", + "dependsOn": ["make: génère la documentation"], + "presentation": { + "reveal": "always", + "panel": "new" + }, + "problemMatcher": [] + }, + { + "label": "wrap: corrige la longueur des lignes", + "type": "shell", + "command": "make wrap", + "group": "lint", + "presentation": { + "reveal": "always", + "panel": "new" + }, + "problemMatcher": [] + }, + { + "label": "todo: liste les traductions à réaliser", + "type": "shell", + "command": "make todo", + "group": "lint", + "presentation": { + "reveal": "always", + "panel": "new" + }, + "problemMatcher": [] + } + ] +} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 6d4d663da..9f3a4f45e 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ venv/ .potodo/ locales/ .venv/ +.vscode/ \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..cd155815d --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,10 @@ +repos: +- repo: https://github.com/AFPy/powrap + rev: v1.0.0 + hooks: + - id: powrap +- repo: https://github.com/AFPy/pospell + rev: v1.1 + hooks: + - id: pospell + args: [--language, fr, -p, dict] \ No newline at end of file diff --git a/Makefile b/Makefile index e581c68b3..614043840 100644 --- a/Makefile +++ b/Makefile @@ -84,9 +84,11 @@ all: ensure_prerequisites venv/cpython/.git/HEAD: git clone https://github.com/python/cpython venv/cpython +.git/refs/heads/$(BRANCH): + git fetch $(shell git remote | head -n 1) $(BRANCH):$(BRANCH) .PHONY: ensure_prerequisites -ensure_prerequisites: venv/cpython/.git/HEAD +ensure_prerequisites: venv/cpython/.git/HEAD .git/refs/heads/$(BRANCH) @if ! (blurb help >/dev/null 2>&1 && sphinx-build --version >/dev/null 2>&1); then \ git -C venv/cpython/ checkout $(BRANCH); \ echo "You're missing dependencies please install:"; \