Skip to content

Commit

Permalink
add base classes
Browse files Browse the repository at this point in the history
  • Loading branch information
HJfod committed Feb 24, 2023
1 parent adcc306 commit 6217317
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 7 deletions.
38 changes: 33 additions & 5 deletions src/builder/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,12 +324,40 @@ pub fn fmt_header_link(entity: &Entity, config: Arc<Config>) -> Html {
}
}

pub fn fmt_base_classes<'e, T: ASTEntry<'e>>(entry: &T, kw: &str, config: Arc<Config>) -> Html {
pub fn fmt_base_classes<'e, T: ASTEntry<'e>>(entry: &T, kw: &str, builder: &Builder) -> Html {
let bases = entry.entity().get_children()
.into_iter()
.filter(|p| p.get_kind() == EntityKind::BaseSpecifier)
.collect::<Vec<_>>();

HtmlElement::new("div")
.with_class("entity-desc")
.with_classes(&["entity", "class"])
.with_child(Html::span(&["keyword", "space-after"], kw))
.with_child(Html::span(&["identifier", "space-after"], entry.name().as_str()))
.with_child(HtmlText::new(";"))
.with_child(Html::span(&["name"], entry.name().as_str()))
.with_child_opt((!bases.is_empty()).then_some(
Html::span(&["space-before", "space-after"], ":")
))
.with_children(bases.into_iter()
.map(|base| HtmlList::new([
base.get_accessibility().map(|a|
Html::span(
&["keyword", "space-after"],
match a {
Accessibility::Public => "public",
Accessibility::Private => "private",
Accessibility::Protected => "protected",
}
)
),
base.is_virtual_base().then_some(
Html::span(&["keyword", "space-after"], "virtual")
),
base.get_type().map(|ty| fmt_type(&ty, builder))
].into_iter().flatten().collect()).into())
.intersperse_with(|| Html::span(&["space-after"], ",").into())
.collect()
)
.with_child(Html::span(&["space-before"], "{ ... }"))
.into()
}

Expand Down Expand Up @@ -379,7 +407,7 @@ pub fn output_classlike<'e, T: ASTEntry<'e>>(
ent.extend(vec![
(
"base_classes",
fmt_base_classes(entry, entry.category(), builder.config.clone())
fmt_base_classes(entry, entry.category(), builder)
),
(
"public_static_functions",
Expand Down
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#![feature(is_some_and)]
#![feature(result_option_inspect)]
#![feature(iter_advance_by)]
#![feature(iter_intersperse)]

use crate::{analyze::create_docs, url::UrlPath, normalize::Normalize};
use clap::Parser;
Expand Down
2 changes: 2 additions & 0 deletions templates/class.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ <h1 class="entity-title">Class <i data-feather="box" class="icon"></i><a href="{
</div>
<div>
{description}
</div>
<div>
{examples}
{public_static_functions}
{public_member_functions}
Expand Down
4 changes: 3 additions & 1 deletion templates/content.css
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,8 @@ main .button.outlined:hover {
.header-link {
font-size: 1.1rem;
color: var(--flash-purple);
margin-top: .25rem;
margin-bottom: .25rem;
}

.header-link .url {
Expand Down Expand Up @@ -616,7 +618,7 @@ a code:not(pre > code) {
}

code.header-link {
padding: 1rem;
padding: .75rem;
}

a:hover > code.header-link {
Expand Down
2 changes: 1 addition & 1 deletion templates/function.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ <h1 class="entity-title">Function <i data-feather="code" class="icon"></i><a hre
</div>
<div>
{description}
{examples}
</div>
<div>
{examples}
</div>
2 changes: 2 additions & 0 deletions templates/struct.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ <h1 class="entity-title">Struct <i data-feather="box" class="icon variant"></i><
</div>
<div>
{description}
</div>
<div>
{public_members}
{examples}
{public_static_functions}
Expand Down

0 comments on commit 6217317

Please sign in to comment.