From 0ec5b74851ca25128e55cacd3e2f851ae98bbde3 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Sat, 23 Dec 2017 18:01:55 -0500 Subject: [PATCH] Start a Cargo workspace and generate documentation for it --- .gitignore | 1 + Cargo.toml | 9 ++++++ .../build/rustdoc-webpack-plugin/index.js | 25 +++++++++------- demo/client/css/pathfinder-doc.css | 29 +++++++++++++++++++ demo/client/css/pathfinder.css | 1 + demo/client/html/doc-before-content.html.hbs | 1 + demo/client/html/doc-header.html.hbs | 2 ++ demo/client/html/partials/navbar.html.hbs | 4 +-- demo/client/webpack.config.js | 9 +++++- demo/server/src/main.rs | 14 ++++----- partitioner/Cargo.toml | 2 +- 11 files changed, 75 insertions(+), 22 deletions(-) create mode 100644 Cargo.toml create mode 100644 demo/client/css/pathfinder-doc.css create mode 100644 demo/client/html/doc-before-content.html.hbs create mode 100644 demo/client/html/doc-header.html.hbs diff --git a/.gitignore b/.gitignore index 063df847..8d545de0 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ /demo/server/Rocket.toml Cargo.lock .DS_Store +target # Editors *.swp diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 00000000..ca3bda94 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,9 @@ +[workspace] +members = [ + "font-renderer", + "partitioner", + "path-utils", + "demo/server", + "utils/frontend", + "utils/gamma-lut", +] diff --git a/demo/client/build/rustdoc-webpack-plugin/index.js b/demo/client/build/rustdoc-webpack-plugin/index.js index 5fbece99..a34ed592 100644 --- a/demo/client/build/rustdoc-webpack-plugin/index.js +++ b/demo/client/build/rustdoc-webpack-plugin/index.js @@ -1,24 +1,27 @@ const {spawn} = require('child_process'); +const process = require('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); + this.options = Object.assign({directories: [], flags: {}}, options); } apply(compiler) { - compiler.plugin("make", (compilation, done) => { + let rustdocFlags = []; + for (let key in this.options.flags) { + if (this.options.flags.hasOwnProperty(key)) + rustdocFlags.push("--" + key + "=" + this.options.flags[key]); + } + rustdocFlags = rustdocFlags.join(" "); + + compiler.plugin('after-compile', (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}); + const cargo = spawn("cargo", ["doc", "--no-deps"], { + cwd: directory, + env: Object.assign({RUSTDOCFLAGS: rustdocFlags}, process.env), + }); cargo.stdout.setEncoding('utf8'); cargo.stderr.setEncoding('utf8'); cargo.stdout.on('data', data => console.log(data)); diff --git a/demo/client/css/pathfinder-doc.css b/demo/client/css/pathfinder-doc.css new file mode 100644 index 00000000..f95fd42c --- /dev/null +++ b/demo/client/css/pathfinder-doc.css @@ -0,0 +1,29 @@ +body { + padding: 0 !important; +} +h1, +h2, +h3 +h4, +.sidebar, +a.source, +.search-input, +.content table :not(code) > a, +.collapse-toggle, +ul.item-list > li > .out-of-band { + font-family: inherit !important; +} +.content { + padding: 0 15px 0 0 !important; +} +nav.navbar { + max-width: inherit !important; + border: none !important; + margin: 0 !important; +} +nav.sidebar { + top: auto !important; +} +img { + max-width: inherit !important; +} diff --git a/demo/client/css/pathfinder.css b/demo/client/css/pathfinder.css index 279e36be..8227034f 100644 --- a/demo/client/css/pathfinder.css +++ b/demo/client/css/pathfinder.css @@ -181,6 +181,7 @@ button > svg path { margin: 2px 0 0; } + /* * Arrow * diff --git a/demo/client/html/doc-before-content.html.hbs b/demo/client/html/doc-before-content.html.hbs new file mode 100644 index 00000000..b79d2080 --- /dev/null +++ b/demo/client/html/doc-before-content.html.hbs @@ -0,0 +1 @@ +{{>partials/navbar.html isDoc=true}} diff --git a/demo/client/html/doc-header.html.hbs b/demo/client/html/doc-header.html.hbs new file mode 100644 index 00000000..bc514e4d --- /dev/null +++ b/demo/client/html/doc-header.html.hbs @@ -0,0 +1,2 @@ +{{>partials/header.html}} + diff --git a/demo/client/html/partials/navbar.html.hbs b/demo/client/html/partials/navbar.html.hbs index 0585d7cc..8b61d3d0 100644 --- a/demo/client/html/partials/navbar.html.hbs +++ b/demo/client/html/partials/navbar.html.hbs @@ -1,4 +1,4 @@ -