Skip to content

Commit c95eb98

Browse files
authored
[TASK] Improve missing guide handling in CI (#36)
Now adds a "create" link to all missing guide links and sets all missing links as italic text. Also fixes a missing user/group setting in a Makefile command.
1 parent 8fa36dc commit c95eb98

File tree

4 files changed

+25
-4
lines changed

4 files changed

+25
-4
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ generate-tos: ## Generates table of contents in all Index.md files
3636

3737
.PHONY: expand-tags
3838
expand-tags: ## Expands tags into Markdown
39-
docker run --rm -v "$(shell pwd)":/app php:8.3-cli php app/bin/expand-tags
39+
docker run --user $(shell id -u):$(shell id -g) --rm -v "$(shell pwd)":/app php:8.3-cli php app/bin/expand-tags
4040

4141
.PHONY: prepare-docs ## Prepares files for rendering: Backing up, generating TOS, expanding tags, etc.
4242
prepare-docs: stage-docs index-files expand-links generate-tos expand-tags

bin/expand-links

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,22 @@ foreach ($filesAndLinks['files'] as $file) {
3232
. '(' . $link['toFile']
3333
. ($link['titleAttribute'] ? ' "' . $link['titleAttribute'] . '"' : '')
3434
. ')';
35+
} elseif (
36+
!str_starts_with($file['path'], '/00Incoming/')
37+
&& !str_starts_with($file['path'], '/80GuidesRegistry/')
38+
&& !str_starts_with($file['path'], '/90Contribute/')
39+
) {
40+
$fileName = preg_replace(
41+
'/[^A-Za-z0-9]/',
42+
'',
43+
iconv(
44+
'UTF-8',
45+
'ASCII//TRANSLIT',
46+
ucwords($link['linkText'])
47+
)
48+
) . '.md';
49+
50+
$replaceLinkString = '*' . $link['linkText'] . '* [(CREATE)]' . '(' . newGuideUrl($fileName) . ' "Create this missing step-by-step guide")';
3551
}
3652

3753
$fileContents = str_replace(
@@ -44,4 +60,10 @@ foreach ($filesAndLinks['files'] as $file) {
4460
if ($changedLinks > 0) {
4561
file_put_contents(SEARCH_PATH . $file['path'], $fileContents);
4662
}
47-
}
63+
}
64+
65+
function newGuideUrl(string $fileName = 'GiveYourGuideAName.md') {
66+
return 'https://github.com/TYPO3-Documentation/TYPO3CMS-Guide-StepByStep/new/contrib/Documentation/00Incoming?'
67+
. 'filename=' . rawurlencode(basename($fileName))
68+
. '&value=' . rawurlencode('Copy content the template from: https://raw.githubusercontent.com/TYPO3-Documentation/TYPO3CMS-Guide-StepByStep/refs/heads/contrib/Documentation/90Contribute/10Template/Index.md');
69+
}

bin/generate-tos

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ foreach ($filesAndLinks['links'] as $link) {
7474

7575
$mentionedUris[] = $link['uri'];
7676

77-
$output .= '* ' . ($link['linkText'] ?? basename($link['uri'])) . ' [CREATE](' . newGuideUrl(basename($link['uri'])) . ')' . PHP_EOL;
77+
$output .= '* ' . ($link['linkText'] ?? basename($link['uri'])) . ' [CREATE](' . newGuideUrl(basename($link['uri'])) . ' "Create this missing step-by-step guide")' . PHP_EOL;
7878
}
7979

8080
file_put_contents(SEARCH_PATH . '/80GuidesRegistry/Index.md', $output);

bin/index-files

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ $allLinks = [];
1818

1919
foreach ($files as $fullFilePath) {
2020
$file = str_replace(SEARCH_PATH, '', $fullFilePath);
21-
2221
$allFiles[$file] = [
2322
'title' => null,
2423
'path' => $file,

0 commit comments

Comments
 (0)