Start a Cargo workspace and generate documentation for it

This commit is contained in:
Patrick Walton 2017-12-23 18:01:55 -05:00
parent 429e4a3063
commit 0ec5b74851
11 changed files with 75 additions and 22 deletions

1
.gitignore vendored
View File

@ -14,6 +14,7 @@
/demo/server/Rocket.toml
Cargo.lock
.DS_Store
target
# Editors
*.swp

9
Cargo.toml Normal file
View File

@ -0,0 +1,9 @@
[workspace]
members = [
"font-renderer",
"partitioner",
"path-utils",
"demo/server",
"utils/frontend",
"utils/gamma-lut",
]

View File

@ -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));

View File

@ -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;
}

View File

@ -181,6 +181,7 @@ button > svg path {
margin: 2px 0 0;
}
/*
* Arrow
*

View File

@ -0,0 +1 @@
{{>partials/navbar.html isDoc=true}}

View File

@ -0,0 +1,2 @@
{{>partials/header.html}}
<link rel="stylesheet" href="/css/pathfinder-doc.css">

View File

@ -1,4 +1,4 @@
<nav class="navbar navbar-expand-sm navbar-dark bg-dark">
<nav class="navbar sticky-top navbar-expand-sm navbar-dark bg-dark">
<a class="navbar-brand" href="/">
<img id="pf-navbar-logo" alt="" src="/svg/demo/logo" width="30" class="mr-2">
Pathfinder
@ -14,7 +14,7 @@
<a class="dropdown-item" href="/demo/3d">3D</a>
</div>
</li>
<li class="nav-item">
<li class="nav-item {{#if isDoc}}active{{/if}}">
<a class="nav-link" href="/doc/api">Documentation</a>
</li>
<li class="nav-item dropdown {{#if isTool}}active{{/if}}">

View File

@ -2,6 +2,9 @@ const Handlebars = require('handlebars');
const HandlebarsPlugin = require('handlebars-webpack-plugin');
const RustdocPlugin = require('rustdoc-webpack-plugin');
const fs = require('fs');
const path = require('path');
const cwd = fs.realpathSync(".");
module.exports = {
devtool: 'inline-source-map',
@ -51,7 +54,11 @@ module.exports = {
},
}),
new RustdocPlugin({
directories: ["../../font-renderer"],
directories: [fs.realpathSync("../..")],
flags: {
'html-in-header': path.join(cwd, "doc-header.html"),
'html-before-content': path.join(cwd, "doc-before-content.html"),
},
}),
]
}

View File

@ -80,9 +80,9 @@ static STATIC_3D_DEMO_PATH: &'static str = "../client/3d-demo.html";
static STATIC_TOOLS_BENCHMARK_PATH: &'static str = "../client/benchmark.html";
static STATIC_TOOLS_REFERENCE_TEST_PATH: &'static str = "../client/reference-test.html";
static STATIC_TOOLS_MESH_DEBUGGER_PATH: &'static str = "../client/mesh-debugger.html";
static STATIC_DOC_API_PATH: &'static str = "../../font-renderer/target/doc";
static STATIC_DOC_API_PATH: &'static str = "../../target/doc";
static STATIC_CSS_BOOTSTRAP_PATH: &'static str = "../client/node_modules/bootstrap/dist/css";
static STATIC_CSS_PATHFINDER_PATH: &'static str = "../client/css/pathfinder.css";
static STATIC_CSS_PATH: &'static str = "../client/css";
static STATIC_JS_BOOTSTRAP_PATH: &'static str = "../client/node_modules/bootstrap/dist/js";
static STATIC_JS_JQUERY_PATH: &'static str = "../client/node_modules/jquery/dist";
static STATIC_JS_POPPER_JS_PATH: &'static str = "../client/node_modules/popper.js/dist/umd";
@ -94,7 +94,7 @@ static STATIC_DATA_PATH: &'static str = "../../resources/data";
static STATIC_TEST_DATA_PATH: &'static str = "../../resources/tests";
static STATIC_TEXTURES_PATH: &'static str = "../../resources/textures";
static STATIC_DOC_API_INDEX_URI: &'static str = "/doc/api/pathfinder_font_renderer/index.html";
static STATIC_DOC_API_INDEX_URI: &'static str = "/doc/api/pathfinder/index.html";
static BUILTIN_FONTS: [(&'static str, &'static str); 4] = [
("open-sans", "../../resources/fonts/open-sans/OpenSans-Regular.ttf"),
@ -694,9 +694,9 @@ fn static_doc_api(file: PathBuf) -> Option<NamedFile> {
fn static_css_bootstrap(file: PathBuf) -> Option<NamedFile> {
NamedFile::open(Path::new(STATIC_CSS_BOOTSTRAP_PATH).join(file)).ok()
}
#[get("/css/pathfinder.css")]
fn static_css_pathfinder_css() -> io::Result<NamedFile> {
NamedFile::open(STATIC_CSS_PATHFINDER_PATH)
#[get("/css/<file>")]
fn static_css(file: String) -> Option<NamedFile> {
NamedFile::open(Path::new(STATIC_CSS_PATH).join(file)).ok()
}
#[get("/js/bootstrap/<file..>")]
fn static_js_bootstrap(file: PathBuf) -> Option<NamedFile> {
@ -800,8 +800,8 @@ fn main() {
static_tools_mesh_debugger,
static_doc_api_index,
static_doc_api,
static_css,
static_css_bootstrap,
static_css_pathfinder_css,
static_js_bootstrap,
static_js_jquery,
static_js_popper_js,

View File

@ -9,7 +9,7 @@ name = "pathfinder_partitioner"
[dependencies]
bincode = "0.8"
bit-vec = "0.4"
byteorder = "1.1"
byteorder = "1.2"
env_logger = "0.4"
euclid = "0.15"
half = "1.0"