-
Notifications
You must be signed in to change notification settings - Fork 169
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Antora in charge of single-sourcing and validating content, ge…
…nerating and validating the website (#2455)
- Loading branch information
Showing
37 changed files
with
364 additions
and
2,255 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright (c) 2022 Red Hat, Inc. | ||
// This program and the accompanying materials are made | ||
// available under the terms of the Eclipse Public License 2.0 | ||
// which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
// | ||
// SPDX-License-Identifier: EPL-2.0 | ||
// | ||
|
||
// Validate the docs asynchronously. | ||
'use strict' | ||
module.exports.register = function () { | ||
this.on('sitePublished', () => { | ||
require('child_process').execFile('./tools/antora-to-plain-asciidoc.sh', (error, stdout, stderr) => { | ||
if (error) { | ||
console.log(stdout + stderr); | ||
return; | ||
} | ||
console.log(stdout); | ||
}) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright (c) 2022 Red Hat, Inc. | ||
// This program and the accompanying materials are made | ||
// available under the terms of the Eclipse Public License 2.0 | ||
// which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
// | ||
// SPDX-License-Identifier: EPL-2.0 | ||
// | ||
|
||
// Validate the docs asynchronously. | ||
'use strict' | ||
module.exports.register = function () { | ||
this.on('sitePublished', () => { | ||
require('child_process').execFile('htmltest', (error, stdout, stderr) => { | ||
if (error) { | ||
console.log(stdout + stderr); | ||
return; | ||
} | ||
console.log(stdout); | ||
}) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,119 +1,31 @@ | ||
'use strict' | ||
|
||
const antora = require('@antora/site-generator') | ||
const connect = require('gulp-connect') | ||
const util = require('util'); | ||
const exec = util.promisify(require('child_process').exec); | ||
const fs = require('fs') | ||
const generator = require('@antora/site-generator') | ||
const { reload: livereload } = process.env.LIVERELOAD === 'true' ? require('gulp-connect') : {} | ||
const { parallel, series, src, watch } = require('gulp') | ||
const yaml = require('js-yaml') | ||
|
||
const playbookFilename = 'antora-playbook-for-development.yml' | ||
const playbook = yaml.load(fs.readFileSync(playbookFilename, 'utf8')) | ||
const outputDir = (playbook.output || {}).dir || './build/site' | ||
const serverConfig = { name: 'Preview Site', livereload, host: '0.0.0.0', port: 4000, root: outputDir } | ||
const antoraArgs = ['--playbook', playbookFilename] | ||
const watchPatterns = playbook.content.sources.filter((source) => !source.url.includes(':')).reduce((accum, source) => { | ||
accum.push(`./antora.yml`) | ||
accum.push(`./modules/**/*`) | ||
return accum | ||
}, []) | ||
const gulp = require('gulp') | ||
|
||
function generate(done) { | ||
generator(antoraArgs, process.env) | ||
.then(() => done()) | ||
.catch((err) => { | ||
console.log(err) | ||
done() | ||
antora(['--playbook', 'antora-playbook-for-development.yml'], process.env) | ||
.then(() => done()) | ||
.catch((err) => { | ||
console.log(err) | ||
done() | ||
}) | ||
connect.reload() | ||
} | ||
|
||
async function serve(done) { | ||
connect.server(serverConfig, function () { | ||
this.server.on('close', done) | ||
watch(watchPatterns, series(generate, testlang, testhtml, detect_unused_content, antora_to_plain_asciidoc)) | ||
if (livereload) watch(this.root).on('change', (filepath) => src(filepath, { read: false }).pipe(livereload())) | ||
}) | ||
} | ||
|
||
async function checluster_docs_gen() { | ||
// Report script errors but don't make gulp fail. | ||
try { | ||
const { stdout, stderr } = await exec('tools/checluster_docs_gen.sh') | ||
console.log(stdout); | ||
console.error(stderr); | ||
} | ||
catch (error) { | ||
console.log(error.stdout); | ||
console.log(error.stderr); | ||
return; | ||
} | ||
} | ||
|
||
async function environment_docs_gen() { | ||
// Report script errors but don't make gulp fail. | ||
try { | ||
const { stdout, stderr } = await exec('tools/environment_docs_gen.sh') | ||
console.log(stdout, stderr); | ||
} | ||
catch (error) { | ||
console.log(error.stdout, error.stderr); | ||
return; | ||
} | ||
} | ||
|
||
async function testhtml() { | ||
// Report links errors but don't make gulp fail. | ||
try { | ||
const { stdout, stderr } = await exec('htmltest') | ||
console.log(stdout, stderr); | ||
} | ||
catch (error) { | ||
console.log(error.stdout, error.stderr); | ||
return; | ||
} | ||
} | ||
|
||
async function testlang() { | ||
// Report language errors but don't make gulp fail. | ||
try { | ||
const { stdout, stderr } = await exec('./tools/validate_language_changes.sh') | ||
console.log(stdout, stderr); | ||
} | ||
catch (error) { | ||
console.log(error.stdout, error.stderr); | ||
return; | ||
} | ||
} | ||
|
||
async function detect_unused_content() { | ||
// Report unused images but don't make gulp fail. | ||
try { | ||
const { stdout, stderr } = await exec('./tools/detect-unused-content.sh') | ||
console.log(stdout, stderr); | ||
} | ||
catch (error) { | ||
console.log(error.stdout, error.stderr); | ||
return; | ||
} | ||
} | ||
|
||
async function antora_to_plain_asciidoc() { | ||
// Report unused images but don't make gulp fail. | ||
try { | ||
const { stdout, stderr } = await exec('./tools/antora-to-plain-asciidoc.sh') | ||
console.log(stdout, stderr); | ||
} | ||
catch (error) { | ||
console.log(error.stdout, error.stderr); | ||
return; | ||
} | ||
} | ||
|
||
exports.default = series( | ||
parallel(checluster_docs_gen, environment_docs_gen), | ||
generate, | ||
serve, | ||
parallel(testlang, testhtml, detect_unused_content, antora_to_plain_asciidoc) | ||
connect.server({ | ||
name: 'Preview Site', | ||
livereload: true, | ||
host: '0.0.0.0', | ||
port: 4000, | ||
root: './build/site' | ||
}); | ||
gulp.watch(['./modules/**/*'], generate) | ||
} | ||
|
||
exports.default = gulp.series( | ||
generate, | ||
serve, | ||
); |
Oops, something went wrong.