Skip to content

Make the documentation runnable, and fix the config examples - #12

Merged
pavel-te merged 1 commit into
mainfrom
ci18-7398-docs-that-run
Aug 6, 2026
Merged

Make the documentation runnable, and fix the config examples#12
pavel-te merged 1 commit into
mainfrom
ci18-7398-docs-that-run

Conversation

@pavel-te

@pavel-te pavel-te commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

Documentation and shipped examples, plus one new test suite. No CLI behaviour changes.

detect_config note

The README and the CLI both said detect_config had to be reached at a different host. It answers on the default API host without a token:

$ curl -s -X POST https://app.ptc.wpml.org/api/v1/detect_config \
    -H 'Content-Type: application/json' -d '{"file_paths":["locales/en.json","locales/fr.json","package.json"]}'
{"kind":"node","source_locale":"en","files":[{"file":"locales/en.json","output":"locales/{{lang}}.json"}], ...}   # HTTP 200

ptc init is the first command the docs recommend, so that note stood between a new user and their first run. Removed from the README, from show_init_help and from the 404 hint, which now says what a 404 there means. The quick start also passed a token to init, which needs none.

A README example could not be copied

./ptc-cli.sh -c config.yml --file-tag-name=feature-branch exits 1. The = form is implemented for --api-url, --api-token, --monitor-interval, --monitor-max-attempts and --action only, while another example in the same file uses a working --api-url=…, so the rule was not inferable. The example now uses the separate-argument form, and the rule is written down under Main Options.

Accepting = everywhere is the other way to resolve this. That changes CLI behaviour and needs a release, so it is not part of a documentation change.

Both CI blocks were out of date

was now
GitHub old pinned release, superseded third-party actions, a fresh PR per run what ptc init prints
GitLab never downloaded the CLI, triggered on merge requests what ptc init prints

Checked by running ptc init for a GitHub project and a GitLab project and diffing its output against the page.

Dependencies in the generated job

It installed jq, which this script never invokes, and did not name unzip, which unpacks every download. alpine:3.22 provides unzip as a busybox applet and extraction works, so the job ran either way — naming it keeps it working if the image is ever swapped. git stays for the push step.

Three of five examples could not be used

java-app, react-app and wordpress-wpsite were KEY=VALUE files with a single-brace placeholder. Each stopped at Missing 'files:' section, and only {{lang}} is substituted. They are YAML now, renamed .config.yml since the extension is what suggested the wrong format. config.local.yml.example no longer shows api_token:, ignored with a warning for several releases.

New suite

Nothing had ever fed an example to the parser. tests/test-config-examples.sh builds a scratch project from each config's declared paths, runs a real --dry-run, then checks the placeholder form and the absence of a token key.

Confirmed it reports the previous files as failures before relying on it:

[FAIL] zz-probe.yml is parsed as a config (got: Missing 'files:' section)
[FAIL] zz-probe.yml uses {lang}; only {{lang}} is substituted
exit code with a broken example: 1

Verification

  • 230 assertions across seven suites, no failures (215 before this one)
  • bash -n ptc-cli.sh clean
  • All 20 fenced blocks in the README parse as the language they are tagged with — four showed CLI output while tagged bash and are text now
  • Every link in the README resolves

Also drops internal tracker identifiers from source comments throughout.

Three surfaces claimed things that were not true, and the one command we
recommend first was gated behind a note telling the reader it would not work.

**The QA note was false.** README and the CLI both said detect_config lives on
the QA environment and that --api-url must be pointed there. Checked against
production: POST https://app.ptc.wpml.org/api/v1/detect_config returns 200 with
a real body, anonymously, no token. `ptc init` completes against the default
URL. Removed from the README, from `show_init_help` and from the 404 hint,
which now says what a 404 there actually means. While there: the quick start
passed PTC_API_TOKEN to `init`, which does not need one — detect_config is
anonymous, and the CLI itself logs that.

**A README example failed on copy-paste.** `--file-tag-name=feature-branch`
exits 1 with "Unknown option". The `=` form is implemented for --api-url,
--api-token, --monitor-interval, --monitor-max-attempts and --action only, and
README:85 uses a working --api-url=..., so the rule cannot be inferred. Fixed
the example and wrote the rule down under Main Options. Widening the parser is
the other way to resolve this; it changes CLI behaviour and needs a release, so
it is not in a documentation fix.

**Both CI blocks were stale.** The GitHub one pinned v1.0.0, used
actions/checkout@v4 and peter-evans/create-pull-request@v5, and opened a fresh
PR per run; the GitLab one never downloaded the CLI and triggered on
merge_requests, which is not loop-safe. Both are now what `ptc init` prints,
verified by running it. The version-pinning example moved v1.0.0 -> v1.0.3.

**Dependencies.** The generated GitLab job installed `jq`, which appears
nowhere in this script, and omitted `unzip`, which unpacks every download.
Checked alpine:3.22: unzip is present as a busybox applet and extraction works,
so the recipe was not broken — but it is named now so it survives an image
swap. git stays: the push step needs it, the CLI does not.

**Three of five examples did not parse.** java-app, react-app and
wordpress-wpsite were KEY=VALUE files using {lang}; each died with "Missing
'files:' section", and only {{lang}} is ever substituted. Rewritten as YAML the
parser accepts, renamed .config -> .yml since the extension is what suggested
the wrong format. config.local.yml.example taught api_token:, deprecated and
ignored since v1.0.x — it now shows the env var instead.

**Why nothing caught this:** no test ever fed an example to the parser. Added
tests/test-config-examples.sh, which builds a scratch project from each config
and runs a real --dry-run. Confirmed it fails on the old files before trusting
it: dropping the previous java-app.config back in turns it red on both the
format and the placeholder.

Suite: 230 assertions across 7 files, 0 failures. `bash -n` clean. Every fenced
block in the README parses as what it is labelled (four Troubleshooting blocks
showed CLI output while tagged bash; they are `text` now), and every link
resolves. The wiki half of this ticket is pushed separately as 3d3282d.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@pavel-te
pavel-te merged commit 9ff8ca3 into main Aug 6, 2026
@pavel-te
pavel-te deleted the ci18-7398-docs-that-run branch August 6, 2026 07:19
@pavel-te pavel-te changed the title [ci18-7398] Make the docs runnable: kill the QA note, fix the examples Make the documentation runnable, and fix the config examples Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants