use crate::items::*;
use std::rc::Rc;
use yew::prelude::*;
pub struct Full;
pub struct Sidebar {}
impl Renderable for Sidebar {
fn render(&self) -> Html {
html! {
<aside class="sidebar">
<div class="sidebar-menu">{"☰"}</div>
<a href="#">
<div class="logo-container rust-logo">
<img src="https://docs.rs/rust-logo-20210119-1.51.0-nightly-c5a96fb79.png" alt="logo"/>
</div>
</a>
<p class="location">{"Struct Captures"}</p>
<div class="sidebar-elems">
<div class="block items"><a class="sidebar-title" href="#">{"Methods"}</a>
<div class="sidebar-links">
<a href="#">{"expand"}</a>
<a href="#">{"get"}</a>
<a href="#">{"iter"}</a>
</div>
<a class="sidebar-title" href="#">{"Trait Implementations"}</a>
<div class="sidebar-links">
<a href="#">{"Debug"}</a>
<a href="#">{"Index<&'str>"}</a>
<a href="#">{"Index<usize>"}</a>
</div>
<a class="sidebar-title" href="#">{"Auto Trait Implementations"}</a>
<div class="sidebar-links">
<a href="#">{"RefUnwindSafe"}</a>
<a href="#">{"Send"}</a>
<a href="#">{"Sync"}</a>
<a href="#">{"Unpin"}</a>
<a href="#">{"UnwindSafe"}</a>
</div>
<a class="sidebar-title" href="#">{"Blanket Implementations"}</a>
<div class="sidebar-links">
<a href="#">{"Any"}</a>
<a href="#">{"Borrow<T>"}</a>
</div>
</div>
<p class="location"><a href="#">{"regex"}</a>{"::"}<a href="#">{"bytes"}</a></p>
<div class="block struct">
<h3>{"Structs"}</h3>
<ul>
<li><a href="#" title="By-reference adaptor for a `Replacer`" class="struct">{"ReplacerRef"}</a></li>
<li><a href="#" title="A set of matches returned by a regex set." class="struct">{"SetMatches"}</a>
</li>
<li><a href="#" title="An owned iterator over the set of matches from a regex set."
class="struct">{"SetMatchesIntoIter"}</a></li>
<li><a href="#" title="A borrowed iterator over the set of matches from a regex set."
class="struct">{"SetMatchesIter"}</a></li>
<li><a href="#" title="Yields all substrings delimited by a regular expression match."
class="struct">{"Split"}</a>
</li>
<li><a href="#" title="Yields at most `N` substrings delimited by a regular expression match."
class="struct">{"SplitN"}</a></li>
<li><a href="#"
title="An iterator that yields all capturing matches in the order in which they appear in the regex."
class="struct">{"SubCaptureMatches"}</a></li>
</ul>
</div>
<div class="block trait">
<h3>{"Traits"}</h3>
<ul>
<li><a href="#" title="Replacer describes types that can be used to replace matches in a byte string."
class="trait">{"Replacer"}</a></li>
</ul>
</div>
</div>
</aside>
}
}
}
pub fn get_toc_title() -> TableOfContentsArray {
TableOfContentsArray(vec![
TableOfContentsItem(
html! {<a href="#heading-2" title="线程">{"线程"}</a>},
vec![html! {
<a href="#heading-3" title="并发 (concurrency) 和并行(Parallelism)">
{"并发 (concurrency) 和并行(Parallelism)"}
</a>
}],
),
TableOfContentsItem(html! {<a href="#heading-0" title="上下文切换">{"上下文切换"}</a>}, vec![]),
TableOfContentsItem(html! {<a href="#heading-1" title="进程">{"进程"}</a>}, vec![]),
TableOfContentsItem(
html! {<a href="#heading-2" title="线程">{"线程"}</a>},
vec![
html! {
<a href="#heading-3" title="并发 (concurrency) 和并行(Parallelism)">
{"并发 (concurrency) 和并行(Parallelism)"}
</a>
},
html! {
<a href="#heading-5" title="非阻塞 IO 和事件驱动">
{"非阻塞 IO 和事件驱动"}
</a>
},
],
),
TableOfContentsItem(
html! {<a href="#heading-6" title="协程 (coroutine)">{"协程 (coroutine)"}</a>},
vec![
html! {<a href="#heading-7">{"Generator: 半协程"}</a>},
html! {<a href="#heading-8">{"Async/Await: 协程 + 异步 = 支持异步任务调度的协程"}</a>},
html! {<a href="#heading-9">{"React Fiber: 框架层控制的支持同步任务和优先级的协程"}</a>},
],
),
])
}
pub fn example(input: &str) -> Html {
let class = Class {
name: String::from(input),
path: "AA".to_string(),
generic: vec![Typing::from("T"), Typing::from("U"), Typing::from("char")],
traits: vec![],
};
let class_traits =
RcList::from(
&["Debug", "Display", "Debug", "Display", "Debug", "Display", "Debug", "Display", "Debug", "Display"] as &[_]
);
let e = Extends {
id: 1,
generic: RcList::from(&["T", "U", "V", "R", "u8"] as &[_]),
version: String::new(),
class: Rc::new(class),
class_typing: RcList::from(&["X", "T", "Y", "char"] as &[_]),
class_traits: class_traits.clone(),
class_bounds: RcList(vec![
Rc::new(TraitBoundItem { left: Typing::from("T"), right: Trait::from("Display") }),
Rc::new(TraitBoundItem { left: Typing::from("U"), right: Trait::from("Debug") }),
]),
};
html! {
<>
{class_traits.build_table()}
<SignatureComponent::<Extends> data = e/>
</>
}
}
pub fn example2(input: &str) -> Html {
let class = Class {
name: String::from(input),
path: "AA".to_string(),
generic: vec![Typing::from("T"), Typing::from("U"), Typing::from("char")],
traits: vec![],
};
let e = Function {
name: String::from(input),
generic: RcList::from(&["u8", "u64", "char"] as &[_]),
version: String::new(),
class: Rc::new(class),
parameters: Parameter::Array(vec![
Parameter::Zelf(Some(true)),
Parameter::Zelf(Some(false)),
Parameter::PositionOnly,
Parameter::Zelf(None),
Parameter::KeyValueOnly,
]),
is_multiline: None,
};
html! {
<SignatureComponent::<Function> data = e/>
}
}
impl Renderable for Full {
fn render(&self) -> Html {
let sidebar = Sidebar {}.render();
let toc = get_toc_title().render();
html! {
<>
<header></header>
{toc}
<main>
{sidebar}
<section>
<article>
{example("Template")}
{example("Component")}
{example2("Tuple")}
{example("Class")}
{example2("Method")}
{example("Function")}
{example2("get")}
{example("Set")}
{example2("plus")}
{example2("times")}
{example("None")}
{example("Null")}
</article>
</section>
</main>
</>
}
}
}