Expose the Rust API documentation via the server
This commit is contained in:
parent
982c97771c
commit
a1013de5ba
|
@ -11,6 +11,9 @@
|
||||||
<a class="dropdown-item" href="/demo/3d">3D</a>
|
<a class="dropdown-item" href="/demo/3d">3D</a>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="/doc/api">Documentation</a>
|
||||||
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="https://github.com/pcwalton/pathfinder">Code</a>
|
<a class="nav-link" href="https://github.com/pcwalton/pathfinder">Code</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -29,7 +29,7 @@ use pathfinder_partitioner::partitioner::Partitioner;
|
||||||
use pathfinder_partitioner::{Endpoint, Subpath};
|
use pathfinder_partitioner::{Endpoint, Subpath};
|
||||||
use rocket::http::{ContentType, Status};
|
use rocket::http::{ContentType, Status};
|
||||||
use rocket::request::Request;
|
use rocket::request::Request;
|
||||||
use rocket::response::{NamedFile, Responder, Response};
|
use rocket::response::{NamedFile, Redirect, Responder, Response};
|
||||||
use rocket_contrib::json::Json;
|
use rocket_contrib::json::Json;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
|
@ -42,6 +42,7 @@ static STATIC_INDEX_PATH: &'static str = "../client/index.html";
|
||||||
static STATIC_TEXT_DEMO_PATH: &'static str = "../client/text-demo.html";
|
static STATIC_TEXT_DEMO_PATH: &'static str = "../client/text-demo.html";
|
||||||
static STATIC_SVG_DEMO_PATH: &'static str = "../client/svg-demo.html";
|
static STATIC_SVG_DEMO_PATH: &'static str = "../client/svg-demo.html";
|
||||||
static STATIC_3D_DEMO_PATH: &'static str = "../client/3d-demo.html";
|
static STATIC_3D_DEMO_PATH: &'static str = "../client/3d-demo.html";
|
||||||
|
static STATIC_DOC_API_PATH: &'static str = "../../font-renderer/target/doc";
|
||||||
static STATIC_CSS_BOOTSTRAP_PATH: &'static str = "../client/node_modules/bootstrap/dist/css";
|
static STATIC_CSS_BOOTSTRAP_PATH: &'static str = "../client/node_modules/bootstrap/dist/css";
|
||||||
static STATIC_CSS_OCTICONS_PATH: &'static str = "../client/node_modules/octicons/build";
|
static STATIC_CSS_OCTICONS_PATH: &'static str = "../client/node_modules/octicons/build";
|
||||||
static STATIC_CSS_PATHFINDER_PATH: &'static str = "../client/css/pathfinder.css";
|
static STATIC_CSS_PATHFINDER_PATH: &'static str = "../client/css/pathfinder.css";
|
||||||
|
@ -52,6 +53,8 @@ static STATIC_JS_PATHFINDER_PATH: &'static str = "../client";
|
||||||
static STATIC_SVG_OCTICONS_PATH: &'static str = "../client/node_modules/octicons/build/svg";
|
static STATIC_SVG_OCTICONS_PATH: &'static str = "../client/node_modules/octicons/build/svg";
|
||||||
static STATIC_GLSL_PATH: &'static str = "../../shaders";
|
static STATIC_GLSL_PATH: &'static str = "../../shaders";
|
||||||
|
|
||||||
|
static STATIC_DOC_API_INDEX_URI: &'static str = "/doc/api/pathfinder_font_renderer/index.html";
|
||||||
|
|
||||||
static BUILTIN_FONTS: [(&'static str, &'static str); 3] = [
|
static BUILTIN_FONTS: [(&'static str, &'static str); 3] = [
|
||||||
("open-sans", "../../resources/fonts/open-sans/OpenSans-Regular.ttf"),
|
("open-sans", "../../resources/fonts/open-sans/OpenSans-Regular.ttf"),
|
||||||
("nimbus-sans", "../../resources/fonts/nimbus-sans/NimbusSanL-Regu.ttf"),
|
("nimbus-sans", "../../resources/fonts/nimbus-sans/NimbusSanL-Regu.ttf"),
|
||||||
|
@ -529,6 +532,14 @@ fn static_demo_svg() -> io::Result<NamedFile> {
|
||||||
fn static_demo_3d() -> io::Result<NamedFile> {
|
fn static_demo_3d() -> io::Result<NamedFile> {
|
||||||
NamedFile::open(STATIC_3D_DEMO_PATH)
|
NamedFile::open(STATIC_3D_DEMO_PATH)
|
||||||
}
|
}
|
||||||
|
#[get("/doc/api")]
|
||||||
|
fn static_doc_api_index() -> Redirect {
|
||||||
|
Redirect::to(STATIC_DOC_API_INDEX_URI)
|
||||||
|
}
|
||||||
|
#[get("/doc/api/<file..>")]
|
||||||
|
fn static_doc_api(file: PathBuf) -> Option<NamedFile> {
|
||||||
|
NamedFile::open(Path::new(STATIC_DOC_API_PATH).join(file)).ok()
|
||||||
|
}
|
||||||
#[get("/css/bootstrap/<file..>")]
|
#[get("/css/bootstrap/<file..>")]
|
||||||
fn static_css_bootstrap(file: PathBuf) -> Option<NamedFile> {
|
fn static_css_bootstrap(file: PathBuf) -> Option<NamedFile> {
|
||||||
NamedFile::open(Path::new(STATIC_CSS_BOOTSTRAP_PATH).join(file)).ok()
|
NamedFile::open(Path::new(STATIC_CSS_BOOTSTRAP_PATH).join(file)).ok()
|
||||||
|
@ -606,6 +617,8 @@ fn main() {
|
||||||
static_demo_text,
|
static_demo_text,
|
||||||
static_demo_svg,
|
static_demo_svg,
|
||||||
static_demo_3d,
|
static_demo_3d,
|
||||||
|
static_doc_api_index,
|
||||||
|
static_doc_api,
|
||||||
static_css_bootstrap,
|
static_css_bootstrap,
|
||||||
static_css_octicons,
|
static_css_octicons,
|
||||||
static_css_pathfinder_css,
|
static_css_pathfinder_css,
|
||||||
|
|
Loading…
Reference in New Issue