Skip to content

Commit 6e7bb62

Browse files
committed
doc: Generate list of sites in doc/wordpress.md
1 parent 9faff9b commit 6e7bb62

File tree

5 files changed

+122
-8
lines changed

5 files changed

+122
-8
lines changed

.github/workflows/CI.yaml

+2-5
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@ on:
44
pull_request:
55

66
jobs:
7-
puppet-lint:
7+
lint:
88
# https://github.com/actions/virtual-environments/blob/ubuntu20/20220605.1/images/linux/Ubuntu2004-Readme.md
99
#
1010
# Includes Ruby 2.7 and RubyGems 3.1
11-
name: puppet-lint
1211
runs-on: ubuntu-latest
1312
steps:
1413
- uses: actions/checkout@v2
@@ -17,6 +16,4 @@ jobs:
1716
run: |
1817
sudo gem install puppet-lint -v '~> 2'
1918
20-
- name: Run puppet-lint
21-
run: |
22-
puppet-lint --fail-on-warnings .
19+
- run: make lint

Makefile

+8-3
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,18 @@ endif
1414

1515
export DEBUG=0
1616

17-
.PHONY: lint test
17+
.PHONY: doc/wordpress.md build lint test
1818

19-
all: lint
19+
all: build lint
20+
21+
build: doc/wordpress.md
22+
23+
doc/wordpress.md:
24+
./bin/build_wordpress_md.sh
2025

2126
lint:
2227
puppet-lint --fail-on-warnings .
28+
@ ./bin/build_wordpress_md.sh --verify
2329

2430
test: test-codeorigin-prod-http test-codeorigin-prod-https test-codeorigin-next-http test-codeorigin-next-https test-codeorigin-stage test-contentorigin-prod test-miscweb test-wpdocs test-releases
2531

@@ -43,7 +49,6 @@ test-codeorigin-stage:
4349
@ php test/CodeoriginTest.php "https://codeorigin-02.stage.ops.jquery.net"
4450
@ echo "$@"
4551

46-
4752
test-contentorigin-prod:
4853
@ php test/ContentoriginTest.php
4954
@ echo "$@"

bin/build_wordpress_md.sh

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
OPTION=${1:-}
6+
7+
newtable="$(php bin/doc_sites_info.php)"
8+
9+
current_content="$(cat doc/wordpress.md)"
10+
template="$(echo "$current_content" | tr '\n' '\r' | sed 's/<!-- .* END -->/__TABLE__/' | tr '\r' '\n')"
11+
new_content="${template//__TABLE__/$newtable}"
12+
13+
if [ "$current_content" != "$new_content" ]; then
14+
if [ "$OPTION" == "--verify" ]; then
15+
# signal for "make lint" to fail
16+
echo "Error: The table in doc/wordpress.md is out-of-date. Run 'make build' to update it." >&2
17+
exit 1
18+
else
19+
echo "$new_content" > doc/wordpress.md
20+
fi
21+
fi

bin/doc_sites_info.php

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?php
2+
3+
$yaml = file( __DIR__ . '/../hieradata/common.yaml' );
4+
5+
$sites = null;
6+
$current = null;
7+
8+
foreach ( $yaml as $line ) {
9+
// Top-level key
10+
if ( preg_match( '/^(\S+):$/', $line, $m ) ) {
11+
if ( $m[1] === 'docs_sites' ) {
12+
// Start of docs_sites
13+
$sites = [];
14+
} elseif ( $sites !== null ) {
15+
// End of docs_sites
16+
break;
17+
}
18+
// Keep searching
19+
continue;
20+
}
21+
22+
// First-level key
23+
if ( $sites === null ) {
24+
// Ignore nested data under other keys
25+
continue;
26+
}
27+
if ( preg_match( '/^ (\S+):$/', $line, $m ) ) {
28+
$sites[$m[1]] = [];
29+
$current =& $sites[$m[1]];
30+
$current['key'] = $m[1];
31+
continue;
32+
}
33+
34+
// Second- and third-level key
35+
if ( preg_match( '/^ (?: )?(\S+): "?(\S+)"?$/', $line, $m ) ) {
36+
switch ($m[1]) {
37+
case 'host':
38+
case 'path':
39+
// repository.name
40+
case 'name':
41+
// repository.branch
42+
case 'branch':
43+
// repository.tag_format
44+
case 'tag_format':
45+
$current[$m[1]] ??= $m[2];
46+
break;
47+
}
48+
}
49+
}
50+
51+
// Generate markdown
52+
print "<!-- Generated by /bin/doc_sites_info.php and configured by docs_sites in /hieradata/common.yaml -->\n\n";
53+
print sprintf( "| %-40s | %-14s | %s\n", 'URL', 'Deployment', 'Staging' );
54+
print sprintf( "| %'-40s | %'-14s | %'-40s\n", '', '', '' );
55+
foreach ( $sites as $site ) {
56+
$branch = $site['branch'] ?? 'main';
57+
$deploy = @$site['tag_format'] === '*semver_tag' ? 'semver tags' : "`$branch` branch";
58+
$link = @$site['name'] ? "https://github.com/{$site['name']}/tree/$branch/" : null;
59+
print sprintf( "| %-40s | %-14s | %s\n",
60+
'https://' . $site['host'] . ( $site['path'] ?? '/' ),
61+
$link ? "[$deploy]($link)" : $deploy,
62+
'https://stage.' . $site['host'] . ( $site['path'] ?? '/' )
63+
);
64+
}
65+
print "\n<!-- END -->\n";

doc/wordpress.md

+26
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,32 @@ older version had a different database schema.
3131
3232
## Doc sites
3333
34+
<!-- Generated by /bin/doc_sites_info.php and configured by docs_sites in /hieradata/common.yaml -->
35+
36+
| URL | Deployment | Staging
37+
| ---------------------------------------- | -------------- | ----------------------------------------
38+
| https://api.jquery.com/ | [semver tags](https://github.com/jquery/api.jquery.com/tree/main/) | https://stage.api.jquery.com/
39+
| https://api.jquerymobile.com/ | [`main` branch](https://github.com/jquery/api.jquerymobile.com/tree/main/) | https://stage.api.jquerymobile.com/
40+
| https://api.jquerymobile.com/1.3/ | [`1-3` branch](https://github.com/jquery/api.jquerymobile.com/tree/1-3/) | https://stage.api.jquerymobile.com/1.3/
41+
| https://api.jquerymobile.com/1.4/ | [`1-4` branch](https://github.com/jquery/api.jquerymobile.com/tree/1-4/) | https://stage.api.jquerymobile.com/1.4/
42+
| https://api.jqueryui.com/ | [`main` branch](https://github.com/jquery/api.jqueryui.com/tree/main/) | https://stage.api.jqueryui.com/
43+
| https://api.jqueryui.com/1.8/ | [`1-8` branch](https://github.com/jquery/api.jqueryui.com/tree/1-8/) | https://stage.api.jqueryui.com/1.8/
44+
| https://api.jqueryui.com/1.9/ | [`1-9` branch](https://github.com/jquery/api.jqueryui.com/tree/1-9/) | https://stage.api.jqueryui.com/1.9/
45+
| https://api.jqueryui.com/1.10/ | [`1-10` branch](https://github.com/jquery/api.jqueryui.com/tree/1-10/) | https://stage.api.jqueryui.com/1.10/
46+
| https://api.jqueryui.com/1.11/ | [`1-11` branch](https://github.com/jquery/api.jqueryui.com/tree/1-11/) | https://stage.api.jqueryui.com/1.11/
47+
| https://api.jqueryui.com/1.12/ | [`1-12` branch](https://github.com/jquery/api.jqueryui.com/tree/1-12/) | https://stage.api.jqueryui.com/1.12/
48+
| https://brand.jquery.org/ | [semver tags](https://github.com/jquery/brand.jquery.org/tree/main/) | https://stage.brand.jquery.org/
49+
| https://contribute.jquery.org/ | [semver tags](https://github.com/jquery/contribute.jquery.org/tree/main/) | https://stage.contribute.jquery.org/
50+
| https://jquery.com/ | [semver tags](https://github.com/jquery/jquery.com/tree/main/) | https://stage.jquery.com/
51+
| https://jquery.org/ | [semver tags](https://github.com/jquery/jquery.org/tree/main/) | https://stage.jquery.org/
52+
| https://jquerymobile.com/ | [semver tags](https://github.com/jquery/jquerymobile.com/tree/main/) | https://stage.jquerymobile.com/
53+
| https://jqueryui.com/ | [semver tags](https://github.com/jquery/jqueryui.com/tree/main/) | https://stage.jqueryui.com/
54+
| https://learn.jquery.com/ | [semver tags](https://github.com/jquery/learn.jquery.com/tree/main/) | https://stage.learn.jquery.com/
55+
| https://meetings.jquery.org/ | [`main` branch](https://github.com/jquery/meetings.jquery.org/tree/main/) | https://stage.meetings.jquery.org/
56+
| https://releases.jquery.com/ | [`main` branch](https://github.com/jquery/codeorigin.jquery.com/tree/main/) | https://stage.releases.jquery.com/
57+
58+
<!-- END -->
59+
3460
### Builder hosts
3561

3662
The docs sites are provisioned by the `builder` hosts. These run

0 commit comments

Comments
 (0)