Skip to content

Commit b178595

Browse files
authored
Merge pull request #222 from javaevolved/brunoborges-prevent-pattern-pr-conflicts
Prevent conflicts between pattern pull requests
2 parents 74fc3e6 + 08d0fcd commit b178595

284 files changed

Lines changed: 1800 additions & 1913 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: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Content files are YAML (preferred) or JSON under `content/{category}/{slug}.yaml
5151
| `related` | Exactly **3** entries as `category/slug` paths (cross-category OK) |
5252
| `tags` | Non-empty list of slugs registered in `html-generators/tags.properties` |
5353
| `docs` | At least **1** entry with `title` and `href` |
54-
| `prev` / `next` | `category/slug` path or `null` for first/last in the global chain |
54+
| `navigationOrder` | Non-negative integer; global order is `(navigationOrder, category/slug)` |
5555
| `jdkVersion` | The JDK version where the feature became **final** (not preview) |
5656
| `difficulty` | One of: `beginner`, `intermediate`, `advanced` |
5757
| `support.state` | One of: `available`, `preview`, `experimental` |
@@ -60,24 +60,24 @@ Content files are YAML (preferred) or JSON under `content/{category}/{slug}.yaml
6060

6161
1. Create `content/{category}/new-slug.yaml` with all required fields (use `content/template.json` as reference) and generate its `id` with `uuidgen`.
6262
2. Add a non-empty `tags` list. Every tag slug must already exist in `html-generators/tags.properties`; add new `slug=Display Name` entries there in the same change.
63-
3. Update `prev`/`next` in the adjacent patterns to maintain the navigation chain.
63+
3. Set `navigationOrder` to place the pattern in the global sequence. Values are spaced by 1000; duplicate values are allowed and tie-break by pattern key.
6464
4. Create `proof/{category}/{PascalCaseSlug}.java` — JBang script wrapping the modern code.
6565
5. Create a partial translation at `translations/content/{locale}/{category}/{slug}.yaml` for every non-English locale registered in `html-generators/locales.properties`.
6666
6. Run `jbang html-generators/generate.java` and verify all localized output builds. Generated site files are ignored and must not be committed. The generator rejects missing, malformed, or duplicate UUIDs as well as missing, empty, malformed, and unregistered tags.
67-
7. Run `jbang html-generators/generatesocialqueue.java` without `--reshuffle`. Commit the appended `social/queue.txt` entry and `social/tweets.yaml` draft; do not change `social/state.yaml`.
68-
8. Run `jbang html-generators/validatepatternchanges.java --file content/{category}/{slug}.yaml` and the new proof. The validator enforces translations, proof, navigation, related targets, and social artifacts.
67+
7. Run `jbang html-generators/generatesocialqueue.java --file content/{category}/{slug}.yaml`. Commit the generated `social/tweets/{category}/{slug}.yaml`; do not change `social/queue.txt` or `social/state.yaml`.
68+
8. Run `jbang html-generators/validatepatternchanges.java --file content/{category}/{slug}.yaml` and the new proof. The validator enforces translations, proof, navigation order, related targets, and the tweet draft.
6969

7070
### Removing or reordering a pattern
7171

72-
Update `prev`/`next` in adjacent patterns. Search for the slug in other patterns' `related` arrays and replace with an appropriate alternative.
72+
Update `navigationOrder` when reordering. Search for a removed slug in other patterns' `related` arrays and replace it with an appropriate alternative.
7373

7474
## Internationalization
7575

7676
Full spec: `specs/i18n/i18n-spec.md`. Key rules:
7777

7878
- All locales (including English) go through the same build pipeline.
7979
- UI strings: `translations/strings/{locale}.yaml`. Missing keys fall back to English with a build-time warning.
80-
- Content translations contain **only** translatable fields: `title`, `summary`, `explanation`, `oldApproach`, `modernApproach`, `whyModernWins`, `support.description`. Code, slugs, navigation, and docs are never translated.
80+
- Content translations contain **only** translatable fields: `title`, `summary`, `explanation`, `oldApproach`, `modernApproach`, `whyModernWins`, `support.description`. Code, slugs, navigation order, and docs are never translated.
8181
- `oldCode`/`modernCode` in translation files are **always overwritten** with English values at build time to prevent hallucinated code.
8282
- Locale registry: `html-generators/locales.properties` (format: `locale=Display Name`).
8383
- When adding a new UI string key, add it to `en.yaml` first, then to all other locale files. The generator warns on missing keys but doesn't fail.

.github/workflows/content-validation.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ on:
66
- '.github/workflows/content-validation.yml'
77
- 'content/**'
88
- 'proof/**'
9-
- 'social/queue.txt'
10-
- 'social/tweets.yaml'
9+
- 'social/tweets/**'
1110
- 'translations/**'
1211
- 'templates/**'
1312
- 'html-generators/generate.java'
13+
- 'html-generators/generatesocialqueue.java'
14+
- 'html-generators/socialpost.java'
1415
- 'html-generators/validatepatternchanges.java'
1516
- 'html-generators/tags.properties'
1617
- 'html-generators/categories.properties'
@@ -42,5 +43,10 @@ jobs:
4243
--base "${{ github.event.pull_request.base.sha }}"
4344
--head "${{ github.event.pull_request.head.sha }}"
4445
46+
- name: Validate social posting flow
47+
run: |
48+
jbang html-generators/generatesocialqueue.java
49+
jbang html-generators/socialpost.java --dry-run
50+
4551
- name: Validate content and generate site
4652
run: jbang html-generators/generate.java

.github/workflows/social-post.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ jobs:
2525

2626
- uses: jbangdev/setup-jbang@main
2727

28+
- name: Reconcile pending queue
29+
run: jbang html-generators/generatesocialqueue.java
30+
2831
- name: Post to Twitter
2932
env:
3033
TWITTER_CONSUMER_KEY: ${{ secrets.TWITTER_APP_CONSUMER_KEY }}
@@ -37,7 +40,7 @@ jobs:
3740
run: |
3841
git config user.name "github-actions[bot]"
3942
git config user.email "github-actions[bot]@users.noreply.github.com"
40-
git add social/state.yaml social/queue.txt social/tweets.yaml
43+
git add social/state.yaml social/queue.txt
4144
git diff --cached --quiet && exit 0
4245
git commit -m "chore: update social post state [skip ci]"
4346
git pull --rebase

CONTRIBUTING.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ Contributions are welcome! Content is managed as YAML files — never edit gener
77
1. Fork the repo
88
2. Create a new YAML file in the appropriate `content/<category>/` folder (e.g. `content/language/my-feature.yaml`)
99
3. Copy [`content/template.json`](content/template.json) as a starting point for all required fields (see the [snippet schema](.github/copilot-instructions.md) for details)
10-
4. Update the `prev`/`next` fields in adjacent pattern files to maintain navigation
11-
5. Run `jbang html-generators/generate.java` to verify your changes build correctly
12-
6. Open a pull request
10+
4. Set `navigationOrder` to place the pattern in the global sequence. Values are spaced by 1000; duplicate values are allowed and are ordered by pattern key.
11+
5. Generate its tweet draft with `jbang html-generators/generatesocialqueue.java --file content/<category>/<slug>.yaml`
12+
6. Run `jbang html-generators/generate.java` to verify your changes build correctly
13+
7. Open a pull request
1314

1415
Please ensure JDK version labels only reference the version where a feature became **final** (non-preview).
1516

@@ -51,6 +52,6 @@ support:
5152
description: "Ampliamente disponible desde JDK 10 (marzo 2018)"
5253
```
5354
54-
Do **not** include `id`, `slug`, `category`, `difficulty`, `jdkVersion`, `oldCode`, `modernCode`, `prev`, `next`, `related`, or `docs` — these are always taken from the English source.
55+
Do **not** include `id`, `slug`, `category`, `navigationOrder`, `difficulty`, `jdkVersion`, `oldCode`, `modernCode`, `related`, or `docs` — these are always taken from the English source.
5556

5657
**Important:** If your text contains colons (`:`), ensure the value is properly quoted in YAML to avoid parse errors. Always validate with `jbang html-generators/generate.java` before submitting.

content/collections/collection-bulk-operations.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ id: 6a0d1711-a495-490e-a830-95087e092b69
33
slug: "collection-bulk-operations"
44
title: "Collection bulk operations instead of mutation loops"
55
category: "collections"
6+
navigationOrder: 39000
67
difficulty: "beginner"
78
jdkVersion: "8"
89
oldLabel: "Iterator mutation loop"
@@ -32,8 +33,6 @@ whyModernWins:
3233
support:
3334
state: "available"
3435
description: "Available since JDK 8 (March 2014)"
35-
prev: "collections/stack-to-deque"
36-
next: "collections/comparator-factories"
3736
related:
3837
- "collections/reverse-list-iteration"
3938
- "collections/copying-collections-immutably"

content/collections/collectors-teeing.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ id: a04b95a4-d198-4e96-ac9b-870ec57fdeb9
33
slug: "collectors-teeing"
44
title: "Collectors.teeing()"
55
category: "collections"
6+
navigationOrder: 32000
67
difficulty: "intermediate"
78
jdkVersion: "12"
89
oldLabel: "Java 8"
@@ -40,8 +41,6 @@ whyModernWins:
4041
support:
4142
state: "available"
4243
description: "Widely available since JDK 12 (March 2019)"
43-
prev: "collections/sequenced-collections"
44-
next: "collections/stream-toarray-typed"
4544
related:
4645
- "collections/copying-collections-immutably"
4746
- "collections/unmodifiable-collectors"

content/collections/comparator-factories.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ id: a1ac8e52-14cf-49be-a22a-be72de7caa4e
33
slug: "comparator-factories"
44
title: "Comparator factories and fluent ordering"
55
category: "collections"
6+
navigationOrder: 40000
67
difficulty: "beginner"
78
jdkVersion: "8"
89
oldLabel: "Anonymous comparator"
@@ -35,8 +36,6 @@ whyModernWins:
3536
support:
3637
state: "available"
3738
description: "Available since JDK 8 (March 2014)"
38-
prev: "collections/collection-bulk-operations"
39-
next: null
4039
related:
4140
- "collections/collection-bulk-operations"
4241
- "collections/reverse-list-iteration"

content/collections/copying-collections-immutably.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ id: 34332f56-c837-4ddb-b00f-aca32bb68bef
33
slug: "copying-collections-immutably"
44
title: "Copying collections immutably"
55
category: "collections"
6+
navigationOrder: 29000
67
difficulty: "beginner"
78
jdkVersion: "10"
89
oldLabel: "Java 8"
@@ -34,8 +35,6 @@ whyModernWins:
3435
support:
3536
state: "available"
3637
description: "Widely available since JDK 10 (March 2018)"
37-
prev: "collections/immutable-set-creation"
38-
next: "collections/map-entry-factory"
3938
related:
4039
- "collections/immutable-set-creation"
4140
- "collections/map-entry-factory"

content/collections/immutable-list-creation.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ id: 1fa578db-e750-4adb-a88e-bdd2bbda14c4
33
slug: "immutable-list-creation"
44
title: "Immutable list creation"
55
category: "collections"
6+
navigationOrder: 26000
67
difficulty: "beginner"
78
jdkVersion: "9"
89
oldLabel: "Java 8"
@@ -36,8 +37,6 @@ whyModernWins:
3637
support:
3738
state: "available"
3839
description: "Widely available since JDK 9 (Sept 2017)"
39-
prev: "language/exhaustive-switch"
40-
next: "collections/immutable-map-creation"
4140
related:
4241
- "collections/immutable-map-creation"
4342
- "collections/immutable-set-creation"

content/collections/immutable-map-creation.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ id: d118236d-2cfb-4c8a-81b6-f870fc10c25d
33
slug: "immutable-map-creation"
44
title: "Immutable map creation"
55
category: "collections"
6+
navigationOrder: 27000
67
difficulty: "beginner"
78
jdkVersion: "9"
89
oldLabel: "Java 8"
@@ -34,8 +35,6 @@ whyModernWins:
3435
support:
3536
state: "available"
3637
description: "Widely available since JDK 9 (Sept 2017)"
37-
prev: "collections/immutable-list-creation"
38-
next: "collections/immutable-set-creation"
3938
related:
4039
- "collections/copying-collections-immutably"
4140
- "collections/sequenced-collections"

0 commit comments

Comments
 (0)