Skip to content

Commit b3aa9c4

Browse files
committed
Build tools
Adds build tools that: - Download required assets in order to build the site. - Creates the component list to include in the landing page. - Cleans up when done.
1 parent f90ccd4 commit b3aa9c4

File tree

4 files changed

+115
-0
lines changed

4 files changed

+115
-0
lines changed

Makefile

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Makefile for ZF documentation landing page
2+
#
3+
# General usage:
4+
#
5+
# make all
6+
#
7+
# Once done, run:
8+
#
9+
# git add -A .
10+
# git commit
11+
# git push origin
12+
#
13+
# After running the `make all` command, you might want to preview the
14+
# results before committing:
15+
#
16+
# php -S 0:8000 -t .
17+
18+
.PHONY : all ready clean mkdocs build
19+
20+
all: build
21+
22+
zf-mkdoc-theme:
23+
- git clone git://github.com/zendframework/zf-mkdoc-theme.git
24+
25+
ready:
26+
- rm -Rf css img index.html js search sitemap.xml docs/html
27+
- mkdir -p docs/html
28+
29+
zf-component-list.json:
30+
- wget https://zendframework.github.io/zf-mkdoc-theme/scripts/zf-component-list.json
31+
32+
docs/book/index.html:
33+
- php docs/scripts/prepare_component_list.php
34+
35+
mkdocs: zf-mkdoc-theme zf-component-list.json docs/book/index.html
36+
- ./zf-mkdoc-theme/build.sh
37+
- cp -a docs/html/* .
38+
- rm index.html.dist
39+
40+
build: ready mkdocs clean
41+
42+
clean:
43+
- rm -Rf zf-mkdoc-theme
44+
- rm zf-component-list.json
45+
- rm docs/book/index.html

docs/book/css/site.css

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,15 @@
77
color: white;
88
border-bottom: 0;
99
}
10+
11+
.component h4 {
12+
color: #018D74;
13+
font-size: 1.5em;
14+
}
15+
16+
.package {
17+
margin-top: -0.5em;
18+
padding-top: 0;
19+
font-size: 0.8em;
20+
color: #666666;
21+
}
File renamed without changes.
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
3+
const TEMPLATE = <<< 'EOT'
4+
<div class="row">
5+
<h2>Components</h2>
6+
7+
%components%
8+
</div>
9+
10+
EOT;
11+
12+
const PACKAGE_TEMPLATE = <<< 'EOT'
13+
<div class="component col-xs-12 col-md-6">
14+
<h4><a href="%href%">%name%</a></h4>
15+
<p class="package">%package%</p>
16+
<p>%description%</p>
17+
</div>
18+
19+
EOT;
20+
21+
$root = realpath(getcwd());
22+
$listFile = sprintf('%s/zf-component-list.json', $root);
23+
$srcPath = sprintf('%s/docs/book', $root);
24+
$distPath = sprintf('%s/index.html.dist', $srcPath);
25+
$indexPath = sprintf('%s/index.html', $srcPath);
26+
27+
if (! is_readable($listFile)) {
28+
fwrite(STDERR, "Unable to locate zf-component-list.json in root directory; did you run 'make'?\n");
29+
exit(1);
30+
}
31+
32+
if (! is_readable($distPath)) {
33+
fwrite(STDERR, "Unable to locate docs/book/index.html.dist; did you run this script from the correct directory?\n");
34+
exit(1);
35+
}
36+
37+
$json = file_get_contents($listFile);
38+
$packages = json_decode($json, true);
39+
40+
$componentMarkup = [];
41+
foreach ($packages as $package) {
42+
// @codingStandardsIgnoreStart
43+
$componentMarkup []= str_replace(
44+
[ '%href%', '%name%', '%package%', '%description%'],
45+
[$package['url'], $package['name'], $package['package'], $package['description']],
46+
PACKAGE_TEMPLATE
47+
);
48+
}
49+
$componentMarkup = implode("\n\n", $componentMarkup);
50+
51+
$markup = str_replace('%components%', $componentMarkup, TEMPLATE);
52+
53+
copy($distPath, $indexPath);
54+
$fh = fopen($indexPath, 'a');
55+
fwrite($fh, $markup);
56+
fclose($fh);
57+
58+
printf("Generated %s\n", $indexPath);

0 commit comments

Comments
 (0)