Skip to content

Commit 62b6403

Browse files
Merge pull request #108 from alanconway/readme-dev
Readme dev
2 parents 2459547 + d962569 commit 62b6403

2 files changed

Lines changed: 65 additions & 29 deletions

File tree

README-DEV.adoc

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
Modifying the tutorial
2+
======================
3+
4+
The tutorial is written in asciidoc and can be updated using any text editor.
5+
You can preview changes as you make them as follows:
6+
7+
1. Install the `antora` website generator and `gulp` build system
8+
+
9+
....
10+
npm install -g @antora/cli @antora/site-generator-default gulp gulp-connect gulp-open yaml-js
11+
....
12+
13+
2. Create a `dev-site.yml` file (the `site.yml` file is for the public website)
14+
+
15+
.dev-site.yml
16+
....
17+
runtime:
18+
cache_dir: ./.cache/antora
19+
20+
site:
21+
title: Knative Tutorial
22+
url: https://redhat-developer-demos.github.io/knative-tutorial
23+
start_page: knative-tutorial::index.adoc
24+
25+
content:
26+
sources:
27+
- url: .
28+
branches: HEAD
29+
start_path: documentation
30+
31+
ui:
32+
bundle:
33+
url: https://gitlab.com/antora/antora-ui-default/-/jobs/artifacts/master/raw/build/ui-bundle.zip?job=bundle-stable
34+
snapshot: true
35+
supplemental_files: ./supplemental-ui
36+
37+
output:
38+
dir: ./gh-pages
39+
....
40+
41+
3. Run `node_modules/.bin/gulp`
42+
43+
This will generate HTML, start a local web server at `localhost:5373`, open the server index in a browser, and automatically update the HTML when the asciidoc source changes.

gulpfile.js

Lines changed: 22 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ const connect = require("gulp-connect");
44
const fs = require("fs");
55
const generator = require("@antora/site-generator-default");
66
const gulp = require("gulp");
7+
const open = require("gulp-open");
78
const yaml = require("yaml-js");
89

910
let filename = "dev-site.yml";
1011
let args = ["--playbook", filename];
1112

12-
gulp.task("build", function(cb) {
13+
function build(cb) {
1314
/**
1415
* Use the '@antora/site-generator-default' node module to build.
1516
* It's analogous to `$ antora --playbook local-antora-playbook.yml`.
@@ -19,44 +20,36 @@ gulp.task("build", function(cb) {
1920
* a separate process for each run. So if a build error occurs with the `gulp`
2021
* command it can be useful to check if it also happens with the CLI command.
2122
*/
22-
generator(args, process.env)
23-
.then(() => {
24-
cb();
25-
})
26-
.catch(err => {
27-
console.log(err);
28-
cb();
29-
});
30-
});
23+
generator(args, process.env).catch(err => { console.log(err); })
24+
connect.reload()
25+
cb();
26+
}
3127

32-
gulp.task("preview", ["build"], function() {
33-
/**
34-
* Remove the line gulp.src('README.adoc')
35-
* This is placeholder code to follow the gulp-connect
36-
* example. Could not make it work any other way.
37-
*/
38-
gulp.src("README.adoc").pipe(connect.reload());
39-
});
40-
41-
gulp.task("watch", function() {
28+
function watch() {
4229
let json_content = fs.readFileSync(`${__dirname}/${filename}`, "UTF-8");
4330
let yaml_content = yaml.load(json_content);
44-
let dirs = yaml_content.content.sources.map(source => [
45-
`${source.url}/**/**.yml`,
46-
`${source.url}/**/**.adoc`,
31+
let sources = yaml_content.content.sources.map(source => [
32+
`${source.url}/**/*.yml`,
33+
`${source.url}/**/*.adoc`,
4734
`${source.url}/**/**.hbs`
4835
]);
49-
dirs.push(["dev-site.yml"]);
50-
gulp.watch(dirs, ["preview"]);
51-
});
36+
sources.push(["dev-site.yml"]);
37+
sources = [].concat.apply([], sources) // Flatten the array
38+
gulp.watch(sources, build)
39+
}
5240

53-
gulp.task("connect", function() {
41+
function serve() {
5442
connect.server({
5543
port: 5353,
5644
name: "Dev Server",
5745
livereload: true,
5846
root: "gh-pages"
5947
});
60-
});
48+
}
49+
50+
function browse() {
51+
gulp.src("gh-pages/index.html").pipe(open({uri: 'http://localhost:5353'}))
52+
}
6153

62-
gulp.task("default", ["connect", "watch", "build"]);
54+
exports.build = build;
55+
exports.default = gulp.parallel(serve, watch, browse)

0 commit comments

Comments
 (0)