Skip to content

Commit 928809b

Browse files
committed
Merge branch '4.4' into 5.1
* 4.4: Add the new doc build system
2 parents 6be3b0e + 9db8126 commit 928809b

File tree

7 files changed

+2153
-15
lines changed

7 files changed

+2153
-15
lines changed

.github/workflows/ci.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,44 @@ jobs:
4343
- name: "Build documentation"
4444
run: make -C _build SPHINXOPTS="-nqW -j auto" html
4545

46+
build-php:
47+
name: Symfony doc builder
48+
49+
runs-on: ubuntu-latest
50+
51+
continue-on-error: true
52+
53+
steps:
54+
- name: "Checkout"
55+
uses: actions/checkout@v2
56+
57+
- name: "Set-up PHP"
58+
uses: shivammathur/setup-php@v2
59+
with:
60+
php-version: 7.2
61+
coverage: none
62+
tools: "composer:v2"
63+
64+
- name: Get composer cache directory
65+
id: composercache
66+
working-directory: _build
67+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
68+
69+
- name: Cache dependencies
70+
uses: actions/cache@v2
71+
with:
72+
path: ${{ steps.composercache.outputs.dir }}
73+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
74+
restore-keys: ${{ runner.os }}-composer-
75+
76+
- name: "Install dependencies"
77+
working-directory: _build
78+
run: composer install --prefer-dist --no-progress
79+
80+
- name: "Build the docs"
81+
working-directory: _build
82+
run: php build.php -vvv
83+
4684
doctor-rst:
4785
name: DOCtor-RST
4886

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
/_build/doctrees
22
/_build/spelling
33
/_build/html
4+
/_build/logs.txt
5+
/_build/vendor
6+
/_build/output
47
*.pyc

.symfony.cloud.yaml

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
name: symfonydocs
66

77
# The toolstack used to build the application.
8-
type: "python:3.7"
8+
type: "php:7.2"
99

1010
# The configuration of app when it is exposed to the web.
1111
web:
1212
# The public directory of the app, relative to its root.
13-
document_root: "/_build/html"
13+
document_root: "/_build/output"
1414
index_files:
1515
- index.html
1616
whitelist:
@@ -40,19 +40,9 @@ web:
4040
# The size of the persistent disk of the application (in MB).
4141
disk: 512
4242

43-
# Build time dependencies.
44-
dependencies:
45-
python:
46-
virtualenv: 15.1.0
47-
4843
# The hooks that will be performed when the package is deployed.
4944
hooks:
5045
build: |
51-
virtualenv .virtualenv
52-
. .virtualenv/bin/activate
53-
# SymfonyCloud currently sets PIP_USER=1.
54-
export PIP_USER=
55-
pip install pip==9.0.1 wheel==0.29.0
56-
pip install -r _build/.requirements.txt
57-
find .virtualenv -type f -name "*.rst" -delete
58-
make -C _build html
46+
cd _build
47+
composer install --prefer-dist --no-progress
48+
php build.php

_build/build.php

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env php
2+
<?php
3+
require __DIR__.'/vendor/autoload.php';
4+
5+
use Symfony\Component\Console\Application;
6+
use Symfony\Component\Console\Input\InputInterface;
7+
use Symfony\Component\Console\Output\OutputInterface;
8+
use Symfony\Component\Process\Process;
9+
use Symfony\Component\Process\Exception\ProcessFailedException;
10+
use Symfony\Component\Console\Input\InputOption;
11+
12+
(new Application('Symfony Docs Builder', '1.0'))
13+
->register('build-docs')
14+
->addOption('generate-fjson-files', null, InputOption::VALUE_NONE, 'Use this option to generate docs both in HTML and JSON formats')
15+
->addOption('disable-cache', null, InputOption::VALUE_NONE, 'Use this option to force a full regeneration of all doc contents')
16+
->setCode(function(InputInterface $input, OutputInterface $output) {
17+
$command = [
18+
'php',
19+
'vendor/symfony/docs-builder/bin/console',
20+
'build:docs',
21+
sprintf('--save-errors=%s', __DIR__.'/logs.txt'),
22+
__DIR__.'/../',
23+
__DIR__.'/output/',
24+
];
25+
26+
if ($input->getOption('generate-fjson-files')) {
27+
$command[] = '--output-json';
28+
}
29+
30+
if ($input->getOption('disable-cache')) {
31+
$command[] = '--disable-cache';
32+
}
33+
34+
$process = new Process($command);
35+
$process->setTimeout(3600);
36+
37+
$this->getHelper('process')->run($output, $process);
38+
39+
if (!$process->isSuccessful()) {
40+
throw new ProcessFailedException($process);
41+
}
42+
})
43+
->getApplication()
44+
->setDefaultCommand('build-docs', true)
45+
->run();

_build/composer.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"minimum-stability": "dev",
3+
"prefer-stable": true,
4+
"repositories": [
5+
{ "type": "git", "url": "https://github.com/weaverryan/docs-builder" }
6+
],
7+
"config": {
8+
"platform": {
9+
"php": "7.2.9"
10+
},
11+
"preferred-install": {
12+
"*": "dist"
13+
},
14+
"sort-packages": true
15+
},
16+
"require": {
17+
"php": ">=7.2.9",
18+
"symfony/console": "^4.1",
19+
"symfony/docs-builder": "dev-master",
20+
"symfony/process": "9999999-dev"
21+
}
22+
}

0 commit comments

Comments
 (0)