Build Rust documentation as part of the demo client build process
This commit is contained in:
parent
b6236ac835
commit
934086ace8
|
@ -0,0 +1,43 @@
|
|||
const {spawn} = require('child_process');
|
||||
|
||||
class RustdocPlugin {
|
||||
constructor(options) {
|
||||
this.options = Object.assign({
|
||||
directories: [],
|
||||
onBeforeSetup: Function.prototype,
|
||||
onBeforeAddPartials: Function.prototype,
|
||||
onBeforeCompile: Function.prototype,
|
||||
onBeforeRender: Function.prototype,
|
||||
onBeforeSave: Function.prototype,
|
||||
onDone: Function.prototype
|
||||
}, options);
|
||||
}
|
||||
|
||||
apply(compiler) {
|
||||
compiler.plugin("make", (compilation, done) => {
|
||||
let directoriesLeft = this.options.directories.length;
|
||||
for (const directory of this.options.directories) {
|
||||
console.log("Building documentation for `" + directory + "`...");
|
||||
const cargo = spawn("cargo", ["doc"], {cwd: directory});
|
||||
cargo.stdout.setEncoding('utf8');
|
||||
cargo.stderr.setEncoding('utf8');
|
||||
cargo.stdout.on('data', data => console.log(data));
|
||||
cargo.stderr.on('data', data => console.log(data));
|
||||
cargo.on('close', code => {
|
||||
if (code !== 0) {
|
||||
const message = "Failed to build documentation for `" + directory + "`!";
|
||||
console.error(message);
|
||||
throw new Error(message);
|
||||
}
|
||||
|
||||
console.log("Built documentation for `" + directory + "`.");
|
||||
directoriesLeft--;
|
||||
if (directoriesLeft === 0)
|
||||
done();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = RustdocPlugin;
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"name": "rustdoc-webpack-plugin",
|
||||
"version": "0.1.0",
|
||||
"description": "Webpack plugin for building Rust package documentation",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "Patrick Walton",
|
||||
"license": "MIT OR Apache-2.0"
|
||||
}
|
|
@ -32,6 +32,7 @@
|
|||
"parse-color": "^1.0.0",
|
||||
"path-data-polyfill.js": "^1.0.2",
|
||||
"popper.js": "^1.12.5",
|
||||
"rustdoc-webpack-plugin": "file:./build/rustdoc-webpack-plugin",
|
||||
"ts-loader": "^2.3.7",
|
||||
"typescript": "^2.5.2",
|
||||
"webpack": "^3.5.6"
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
const Handlebars = require('handlebars');
|
||||
const HandlebarsPlugin = require('handlebars-webpack-plugin');
|
||||
const RustdocPlugin = require('rustdoc-webpack-plugin');
|
||||
const fs = require('fs');
|
||||
|
||||
module.exports = {
|
||||
|
@ -48,6 +49,9 @@ module.exports = {
|
|||
return new Handlebars.SafeString(svg);
|
||||
}
|
||||
},
|
||||
})
|
||||
}),
|
||||
new RustdocPlugin({
|
||||
directories: ["../../font-renderer"],
|
||||
}),
|
||||
]
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue