Skip to content

Commit 9226365

Browse files
committed
Merge branch '5.x' of github.com:cakephp/docs into 5.x
2 parents d8adddf + 76a9fde commit 9226365

File tree

12 files changed

+342
-255
lines changed

12 files changed

+342
-255
lines changed

.github/workflows/docs-validation.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,17 @@ jobs:
4848
echo "✅ Valid: $file"
4949
done
5050
51+
toc-link-check:
52+
name: Validate TOC Links
53+
runs-on: ubuntu-latest
54+
55+
steps:
56+
- name: Checkout code
57+
uses: actions/checkout@v6
58+
59+
- name: Check TOC links exist
60+
run: node bin/check-toc-links.js
61+
5162
markdown-lint:
5263
name: Lint Markdown
5364
runs-on: ubuntu-latest

bin/check-toc-links.js

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
#!/usr/bin/env node
2+
3+
/**
4+
* TOC Link Validator
5+
*
6+
* Validates that all links in toc_*.json files point to existing markdown files.
7+
*
8+
* Usage:
9+
* node bin/check-toc-links.js
10+
*/
11+
12+
const fs = require("fs");
13+
const path = require("path");
14+
15+
/**
16+
* Recursively extract all links from TOC items
17+
*/
18+
function extractLinks(items, links = []) {
19+
for (const item of items) {
20+
if (item.link && !item.link.startsWith("http")) {
21+
links.push(item.link);
22+
}
23+
if (item.items) {
24+
extractLinks(item.items, links);
25+
}
26+
}
27+
return links;
28+
}
29+
30+
/**
31+
* Check if a TOC link resolves to an existing file
32+
*/
33+
function checkLink(link, docsDir, lang) {
34+
// TOC links may include language prefix: "/ja/quickstart" or just "/quickstart"
35+
// Strip the language prefix if present
36+
let relativePath = link.startsWith("/") ? link.slice(1) : link;
37+
38+
// Remove language prefix if link starts with it (e.g., "ja/quickstart" -> "quickstart")
39+
const langPrefix = lang + "/";
40+
if (relativePath.startsWith(langPrefix)) {
41+
relativePath = relativePath.slice(langPrefix.length);
42+
}
43+
44+
const filePath = path.join(docsDir, relativePath + ".md");
45+
46+
return fs.existsSync(filePath);
47+
}
48+
49+
/**
50+
* Extract language code from TOC filename
51+
* e.g., "toc_en.json" -> "en"
52+
*/
53+
function getLangFromTocFile(tocFile) {
54+
const match = tocFile.match(/^toc_(\w+)\.json$/);
55+
return match ? match[1] : null;
56+
}
57+
58+
/**
59+
* Main validation function
60+
*/
61+
function validateTocFiles() {
62+
const tocFiles = fs.readdirSync(".").filter((f) => f.match(/^toc_.*\.json$/));
63+
64+
if (tocFiles.length === 0) {
65+
console.error("No toc_*.json files found");
66+
process.exit(1);
67+
}
68+
69+
let hasErrors = false;
70+
71+
for (const tocFile of tocFiles) {
72+
const lang = getLangFromTocFile(tocFile);
73+
if (!lang) {
74+
console.error(`Could not extract language from ${tocFile}`);
75+
continue;
76+
}
77+
78+
const docsDir = path.join("docs", lang);
79+
if (!fs.existsSync(docsDir)) {
80+
console.error(`Docs directory not found: ${docsDir}`);
81+
hasErrors = true;
82+
continue;
83+
}
84+
85+
console.log(`Checking ${tocFile} against ${docsDir}/...`);
86+
87+
const content = fs.readFileSync(tocFile, "utf8");
88+
const toc = JSON.parse(content);
89+
90+
// TOC structure has keys like "/" with arrays of items
91+
const allLinks = [];
92+
for (const key of Object.keys(toc)) {
93+
extractLinks(toc[key], allLinks);
94+
}
95+
96+
const missingFiles = [];
97+
for (const link of allLinks) {
98+
if (!checkLink(link, docsDir, lang)) {
99+
missingFiles.push(link);
100+
}
101+
}
102+
103+
if (missingFiles.length > 0) {
104+
hasErrors = true;
105+
console.error(`\n✗ ${tocFile}: ${missingFiles.length} broken link(s)\n`);
106+
for (const link of missingFiles) {
107+
// Calculate expected path (strip lang prefix if present)
108+
let relativePath = link.startsWith("/") ? link.slice(1) : link;
109+
const langPrefix = lang + "/";
110+
if (relativePath.startsWith(langPrefix)) {
111+
relativePath = relativePath.slice(langPrefix.length);
112+
}
113+
const expectedPath = path.join(docsDir, relativePath + ".md");
114+
console.error(` ${link}`);
115+
console.error(` Expected: ${expectedPath}`);
116+
}
117+
console.error("");
118+
} else {
119+
console.log(`✓ ${tocFile}: ${allLinks.length} link(s) valid\n`);
120+
}
121+
}
122+
123+
if (hasErrors) {
124+
console.error("TOC validation failed");
125+
process.exit(1);
126+
}
127+
128+
console.log("✓ All TOC links are valid!");
129+
}
130+
131+
validateTocFiles();

docs/en/contributing/cakephp-coding-conventions.md

Lines changed: 12 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -411,40 +411,18 @@ be preceded by a newline.
411411

412412
Variable types for use in DocBlocks:
413413

414-
Type
415-
Description
416-
417-
mixed
418-
A variable with undefined (or multiple) type.
419-
420-
int
421-
Integer type variable (whole number).
422-
423-
float
424-
Float type (point number).
425-
426-
bool
427-
Logical type (true or false).
428-
429-
string
430-
String type (any value in " " or ' ').
431-
432-
null
433-
Null type. Usually used in conjunction with another type.
434-
435-
array
436-
Array type.
437-
438-
object
439-
Object type. A specific class name should be used if possible.
440-
441-
resource
442-
Resource type (returned by for example mysql_connect()).
443-
Remember that when you specify the type as mixed, you should indicate
444-
whether it is unknown, or what the possible types are.
445-
446-
callable
447-
Callable function.
414+
| Type | Description |
415+
|------|-------------|
416+
| mixed | A variable with undefined (or multiple) type. |
417+
| int | Integer type variable (whole number). |
418+
| float | Float type (point number). |
419+
| bool | Logical type (true or false). |
420+
| string | String type (any value in " " or ' '). |
421+
| null | Null type. Usually used in conjunction with another type. |
422+
| array | Array type. |
423+
| object | Object type. A specific class name should be used if possible. |
424+
| resource | Resource type (returned by for example mysql_connect()). Remember that when you specify the type as mixed, you should indicate whether it is unknown, or what the possible types are. |
425+
| callable | Callable function. |
448426

449427
You can also combine types using the pipe char:
450428

docs/en/controllers/request-response.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -782,12 +782,12 @@ $response = $this->response->withFile(
782782
The supported options are:
783783

784784
name
785-
The name allows you to specify an alternate file name to be sent to
786-
the user.
785+
: The name allows you to specify an alternate file name to be sent to
786+
the user.
787787

788788
download
789-
A boolean value indicating whether headers should be set to force
790-
download.
789+
: A boolean value indicating whether headers should be set to force
790+
download.
791791

792792
### Sending a String as a File
793793

docs/en/core-libraries/logging.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ more information.
467467
`static` Cake\\Log\\Log::**configured**(): array
468468

469469
returns
470-
An array of configured loggers.
470+
: An array of configured loggers.
471471

472472
Get the names of the configured loggers.
473473

docs/en/development/configuration.md

Lines changed: 48 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,11 @@ Below is a description of the variables and how they affect your CakePHP
8787
application.
8888

8989
debug
90-
Changes CakePHP debugging output. `false` = Production mode. No error
91-
messages, errors, or warnings shown. `true` = Errors and warnings shown.
90+
: Changes CakePHP debugging output. `false` = Production mode. No error
91+
messages, errors, or warnings shown. `true` = Errors and warnings shown.
9292

9393
App.namespace
94-
The namespace to find app classes under.
94+
: The namespace to find app classes under.
9595

9696
> [!NOTE]
9797
> When changing the namespace in your configuration, you will also
@@ -102,78 +102,77 @@ The namespace to find app classes under.
102102
<div id="core-configuration-baseurl">
103103

104104
App.baseUrl
105-
Un-comment this definition if you **dont** plan to use Apaches
106-
mod_rewrite with CakePHP. Dont forget to remove your .htaccess
107-
files too.
105+
: Un-comment this definition if you **don't** plan to use Apache's
106+
mod_rewrite with CakePHP. Don't forget to remove your .htaccess
107+
files too.
108108

109109
App.base
110-
The base directory the app resides in. If `false` this
111-
will be auto detected. If not `false`, ensure your string starts
112-
with a `/` and does NOT end with a `/`. For example, `/basedir` is a valid
113-
App.base.
110+
: The base directory the app resides in. If `false` this
111+
will be auto detected. If not `false`, ensure your string starts
112+
with a `/` and does NOT end with a `/`. For example, `/basedir` is a valid
113+
App.base.
114114

115115
App.encoding
116-
Define what encoding your application uses. This encoding
117-
is used to generate the charset in the layout, and encode entities.
118-
It should match the encoding values specified for your database.
116+
: Define what encoding your application uses. This encoding
117+
is used to generate the charset in the layout, and encode entities.
118+
It should match the encoding values specified for your database.
119119

120120
App.webroot
121-
The webroot directory.
121+
: The webroot directory.
122122

123123
App.wwwRoot
124-
The file path to webroot.
124+
: The file path to webroot.
125125

126126
App.fullBaseUrl
127-
The fully qualified domain name (including protocol) to your application's
128-
root. This is used when generating absolute URLs. By default, this value
129-
is generated using the `$_SERVER` environment. However, you should define it
130-
manually to optimize performance or if you are concerned about people
131-
manipulating the `Host` header.
132-
In a CLI context (from command) the `fullBaseUrl` cannot be read from $_SERVER,
133-
as there is no webserver involved. You do need to specify it yourself if
134-
you do need to generate URLs from a shell (for example, when sending emails).
127+
: The fully qualified domain name (including protocol) to your application's
128+
root. This is used when generating absolute URLs. By default, this value
129+
is generated using the `$_SERVER` environment. However, you should define it
130+
manually to optimize performance or if you are concerned about people
131+
manipulating the `Host` header.
132+
In a CLI context (from command) the `fullBaseUrl` cannot be read from $_SERVER,
133+
as there is no webserver involved. You do need to specify it yourself if
134+
you do need to generate URLs from a shell (for example, when sending emails).
135135

136136
App.imageBaseUrl
137-
Web path to the public images directory under webroot. If you are using
138-
a `CDN` you should set this value to the CDN's location.
137+
: Web path to the public images directory under webroot. If you are using
138+
a `CDN` you should set this value to the CDN's location.
139139

140140
App.cssBaseUrl
141-
Web path to the public css directory under webroot. If you are using
142-
a `CDN` you should set this value to the CDN's location.
141+
: Web path to the public css directory under webroot. If you are using
142+
a `CDN` you should set this value to the CDN's location.
143143

144144
App.jsBaseUrl
145-
Web path to the public js directory under webroot. If you are using
146-
a `CDN` you should set this value to the CDN's location.
145+
: Web path to the public js directory under webroot. If you are using
146+
a `CDN` you should set this value to the CDN's location.
147147

148148
App.paths
149-
Configure paths for non class based resources. Supports the
150-
`plugins`, `templates`, `locales` subkeys, which allow the definition
151-
of paths for plugins, view templates and locale files respectively.
149+
: Configure paths for non class based resources. Supports the
150+
`plugins`, `templates`, `locales` subkeys, which allow the definition
151+
of paths for plugins, view templates and locale files respectively.
152152

153153
App.uploadedFilesAsObjects
154-
Defines whether uploaded files are being represented as objects (`true`),
155-
or arrays (`false`). This option is being treated as enabled by default.
156-
See the [File Uploads section](../controllers/request-response#request-file-uploads) in the Request &
157-
Response Objects chapter for more information.
154+
: Defines whether uploaded files are being represented as objects (`true`),
155+
or arrays (`false`). This option is being treated as enabled by default.
156+
See the [File Uploads section](../controllers/request-response#request-file-uploads) in the Request &
157+
Response Objects chapter for more information.
158158

159159
Security.salt
160-
A random string used in hashing. This value is also used as the
161-
HMAC salt when doing symmetric encryption.
160+
: A random string used in hashing. This value is also used as the
161+
HMAC salt when doing symmetric encryption.
162162

163163
Asset.timestamp
164-
Appends a timestamp which is last modified time of the particular
165-
file at the end of asset files URLs (CSS, JavaScript, Image) when
166-
using proper helpers. Valid values:
167-
168-
- (bool) `false` - Doesn't do anything (default)
169-
- (bool) `true` - Appends the timestamp when debug is `true`
170-
- (string) 'force' - Always appends the timestamp.
164+
: Appends a timestamp which is last modified time of the particular
165+
file at the end of asset files URLs (CSS, JavaScript, Image) when
166+
using proper helpers. Valid values:
167+
(bool) `false` - Doesn't do anything (default),
168+
(bool) `true` - Appends the timestamp when debug is `true`,
169+
(string) 'force' - Always appends the timestamp.
171170

172171
Asset.cacheTime
173-
Sets the asset cache time. This determines the http header `Cache-Control`'s
174-
`max-age`, and the http header's `Expire`'s time for assets.
175-
This can take anything that you version of PHP's [strtotime function](https://php.net/manual/en/function.strtotime.php) can take.
176-
The default is `+1 day`.
172+
: Sets the asset cache time. This determines the http header `Cache-Control`'s
173+
`max-age`, and the http header's `Expire`'s time for assets.
174+
This can take anything that you version of PHP's [strtotime function](https://php.net/manual/en/function.strtotime.php) can take.
175+
The default is `+1 day`.
177176

178177
</div>
179178

docs/en/index.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Get a CakePHP application running in under 5 minutes:
4040

4141
```bash [Composer]
4242
# Create new project
43-
composer create-project --prefer-dist cakephp/app:~5.0 my_app
43+
composer create-project --prefer-dist cakephp/app:|cakeversion| my_app
4444

4545
# Start development server
4646
cd my_app
@@ -53,14 +53,14 @@ bin/cake server
5353
# Setup with DDEV
5454
mkdir my-cakephp-app && cd my-cakephp-app
5555
ddev config --project-type=cakephp --docroot=webroot
56-
ddev composer create --prefer-dist cakephp/app:~5.0
56+
ddev composer create --prefer-dist cakephp/app:|cakeversion|
5757
ddev launch
5858
```
5959

6060
```bash [Docker]
6161
# Using official PHP image
6262
docker run -it --rm -v $(pwd):/app composer create-project \
63-
--prefer-dist cakephp/app:~5.0 my_app
63+
--prefer-dist cakephp/app:|cakeversion| my_app
6464

6565
cd my_app
6666
docker run -it --rm -p 8765:8765 -v $(pwd):/app \

0 commit comments

Comments
 (0)