Skip to content

Commit 43a4a9b

Browse files
Add AGENTS.md and GH action
1 parent 41dd218 commit 43a4a9b

File tree

5 files changed

+217
-2
lines changed

5 files changed

+217
-2
lines changed

.github/workflows/docs-ci.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Docs CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
validate-test-build:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Check out repository
18+
uses: actions/checkout@v4
19+
20+
- name: Set up Python
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: "3.12"
24+
25+
- name: Install Python dependencies
26+
run: |
27+
python -m pip install --upgrade pip
28+
python -m pip install pytest PyYAML multilingualprogramming
29+
30+
- name: Validate multilingual docs metadata
31+
run: python scripts/validate_multilingual_docs.py --strict-freshness
32+
33+
- name: Run docs tests
34+
run: python -m pytest _tests -q
35+
36+
- name: Set up Ruby
37+
uses: ruby/setup-ruby@v1
38+
with:
39+
ruby-version: "3.3"
40+
bundler-cache: true
41+
42+
- name: Build Jekyll site
43+
run: bundle exec jekyll build --baseurl "/docs"
44+
45+
- name: Check Pages artifact
46+
run: python scripts/check_pages_artifact.py --site-dir _site --base-path /docs
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Docs Deploy Pages
2+
3+
on:
4+
workflow_run:
5+
workflows:
6+
- Docs CI
7+
types:
8+
- completed
9+
branches:
10+
- main
11+
12+
permissions:
13+
contents: read
14+
pages: write
15+
id-token: write
16+
17+
concurrency:
18+
group: docs-pages
19+
cancel-in-progress: true
20+
21+
jobs:
22+
build:
23+
if: github.event.workflow_run.conclusion == 'success'
24+
runs-on: ubuntu-latest
25+
26+
steps:
27+
- name: Check out repository
28+
uses: actions/checkout@v4
29+
with:
30+
ref: ${{ github.event.workflow_run.head_sha }}
31+
32+
- name: Configure GitHub Pages
33+
uses: actions/configure-pages@v5
34+
35+
- name: Set up Python
36+
uses: actions/setup-python@v5
37+
with:
38+
python-version: "3.12"
39+
40+
- name: Install Python dependencies
41+
run: |
42+
python -m pip install --upgrade pip
43+
python -m pip install PyYAML multilingualprogramming
44+
45+
- name: Validate multilingual docs metadata
46+
run: python scripts/validate_multilingual_docs.py --strict-freshness
47+
48+
- name: Set up Ruby
49+
uses: ruby/setup-ruby@v1
50+
with:
51+
ruby-version: "3.3"
52+
bundler-cache: true
53+
54+
- name: Build Jekyll site
55+
run: bundle exec jekyll build --baseurl "/docs"
56+
57+
- name: Check Pages artifact
58+
run: python scripts/check_pages_artifact.py --site-dir _site --base-path /docs
59+
60+
- name: Upload Pages artifact
61+
uses: actions/upload-pages-artifact@v3
62+
with:
63+
path: _site
64+
65+
deploy:
66+
needs: build
67+
runs-on: ubuntu-latest
68+
environment:
69+
name: github-pages
70+
url: ${{ steps.deployment.outputs.page_url }}
71+
72+
steps:
73+
- name: Deploy to GitHub Pages
74+
id: deployment
75+
uses: actions/deploy-pages@v4

AGENTS.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# AGENTS.md
2+
3+
Repository guidance for LLM agents working in `docs/`.
4+
5+
## Scope
6+
7+
- This repository contains the documentation site for the `multilingualprogramming` project.
8+
- The public site is built with Jekyll from the top-level site files (`index.md`, `_layouts/`, `_includes/`, `assets/`, `_config.yml`).
9+
- The structured multilingual source of truth lives under `docs/` and currently supports English (`en`) and French (`fr`).
10+
11+
## Primary Goal
12+
13+
Help users write, explain, or update programs for the `multilingualprogramming` language using the documentation in this repository.
14+
15+
For now, optimize for:
16+
17+
- English code and explanations
18+
- French code and explanations
19+
- EN/FR documentation parity when editing docs assets
20+
21+
## Source Of Truth
22+
23+
When answering language or API questions, prefer these locations in order:
24+
25+
1. `docs/content/en/` and `docs/content/fr/` for authored documentation
26+
2. `docs/snippets/<snippet_id>/en.code` and `docs/snippets/<snippet_id>/fr.code` for runnable examples
27+
3. `docs/routing/*.routes.yml` and `docs/i18n/*/ui.yml` for localized paths and UI labels
28+
4. Top-level Jekyll pages only when you need to understand the published site shell
29+
30+
Do not invent syntax if the docs or snippets already show it.
31+
32+
## Programming Guidance
33+
34+
When a user asks for code in this language:
35+
36+
- Pick the requested locale. If unspecified, default to English unless the user writes in French.
37+
- Keep one lexical style per file. Do not mix French and English keywords in the same example unless the user asks for comparison.
38+
- Prefer examples that match documented syntax from the repo.
39+
- For French examples, use documented forms such as `soit`, `afficher`, `si`, `sinon`, `pour`, `dans`, `fonction`, `retourner`, `classe`, `importer`.
40+
- For English examples, use documented forms such as `let`, `print`, `if`, `else`, `for`, `in`, `function`, `return`, `class`, `import`.
41+
- When helpful, provide parallel EN and FR versions of the same program.
42+
43+
## Docs Editing Rules
44+
45+
If you modify multilingual docs content:
46+
47+
- Keep `page_id` identical across locales.
48+
- Keep `source_hash` synchronized from the English source to the French translation.
49+
- Keep `path_segments` localized per language.
50+
- Ensure every referenced `{{snippet:<id>}}` has both `en.code` and `fr.code`.
51+
- Do not add inline runnable Python blocks inside `docs/content/`; use snippet tokens instead.
52+
53+
## Validation Commands
54+
55+
Run these when your changes touch docs structure, snippets, or CI:
56+
57+
```powershell
58+
python scripts/validate_multilingual_docs.py --strict-freshness
59+
python -m pytest _tests -q
60+
bundle exec jekyll build
61+
python scripts/check_pages_artifact.py --site-dir _site --base-path /docs
62+
```
63+
64+
## CI Files
65+
66+
- `.github/workflows/docs-ci.yml` validates docs metadata, runs tests, and builds the site.
67+
- `.github/workflows/docs-deploy-pages.yml` rebuilds and deploys the site to GitHub Pages after successful CI on `main`.
68+
69+
## Known Constraint
70+
71+
The `_tests/` suite exercises docs examples through the PyPI package `multilingualprogramming`.
72+
Install it with `pip install multilingualprogramming`.
73+
If that package is not installed in the current environment, those tests should be skipped rather than failing at import time.

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,16 @@ This repository contains the Jekyll site source for the documentation portal, in
3232

3333
Prerequisites:
3434

35+
- Python 3.x
3536
- Ruby 3.x
3637
- Bundler
3738

39+
Install the Python package used by the docs tests:
40+
41+
```bash
42+
pip install multilingualprogramming
43+
```
44+
3845
Install dependencies:
3946

4047
```bash

_tests/test_code_blocks.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
Run buttons (Pyodide client-side).
88
99
Run locally (requires multilingualprogramming installed):
10+
pip install multilingualprogramming
1011
pytest _tests/ -v
1112
1213
Each code block becomes its own parametrized test case, identified by
@@ -20,7 +21,10 @@
2021

2122
import pytest
2223

23-
from multilingualprogramming.codegen.executor import ProgramExecutor
24+
try:
25+
from multilingualprogramming.codegen.executor import ProgramExecutor
26+
except ModuleNotFoundError:
27+
ProgramExecutor = None
2428

2529
# ---------------------------------------------------------------------------
2630
# Configuration — language tags that are not executable multilingual source.
@@ -100,7 +104,7 @@ def _collect_blocks():
100104
# Test
101105
# ---------------------------------------------------------------------------
102106

103-
@pytest.mark.parametrize('code', _collect_blocks())
107+
@pytest.mark.parametrize('code', _collect_blocks() if ProgramExecutor is not None else [])
104108
def test_block(code):
105109
"""
106110
Each executable code block in the docs must execute without errors
@@ -111,3 +115,13 @@ def test_block(code):
111115
f'ProgramExecutor reported failure:\n' +
112116
'\n'.join(result.errors or ['(no error details)'])
113117
)
118+
119+
120+
def test_program_executor_dependency_available():
121+
"""
122+
Make dependency absence an explicit skip instead of a collection-time error.
123+
"""
124+
if ProgramExecutor is None:
125+
pytest.skip(
126+
"Install multilingualprogramming from PyPI with 'pip install multilingualprogramming' to run docs code-block execution tests."
127+
)

0 commit comments

Comments
 (0)