Skip to content

Commit

Permalink
Docs link back to root overview ref rune-rs#648
Browse files Browse the repository at this point in the history
  • Loading branch information
Roba1993 committed Mar 13, 2024
1 parent 6e8b6dd commit 6cc948f
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 6 deletions.
7 changes: 6 additions & 1 deletion crates/rune/src/doc/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,15 @@ pub(crate) fn build(
}

let search_index = RelativePath::new("index.js");
let root_index = RelativePath::new("index.html");

let mut cx = Ctxt {
state: State::default(),
index: Vec::new(),
name,
context: &context,
search_index: Some(search_index),
root_index: root_index,
fonts: &fonts,
css: &css,
js: &js,
Expand Down Expand Up @@ -262,6 +264,7 @@ fn build_search_index(cx: &Ctxt) -> Result<String> {
struct Shared<'a> {
data_path: Option<&'a RelativePath>,
search_index: Option<RelativePathBuf>,
root_index: RelativePathBuf,
fonts: Vec<RelativePathBuf>,
css: Vec<RelativePathBuf>,
js: Vec<RelativePathBuf>,
Expand Down Expand Up @@ -328,6 +331,7 @@ pub(crate) struct Ctxt<'a, 'm> {
name: &'a str,
context: &'a Context<'m>,
search_index: Option<&'a RelativePath>,
root_index: &'a RelativePath,
fonts: &'a [RelativePathBuf],
css: &'a [RelativePathBuf],
js: &'a [RelativePathBuf],
Expand Down Expand Up @@ -382,6 +386,7 @@ impl<'m> Ctxt<'_, 'm> {
Ok(Shared {
data_path: self.state.path.parent(),
search_index: self.search_index.map(|p| dir.relative(p)),
root_index: dir.relative(self.root_index),
fonts: self.fonts.iter().map(|f| dir.relative(f)).try_collect()?,
css: self.css.iter().map(|f| dir.relative(f)).try_collect()?,
js: self.js.iter().map(|f| dir.relative(f)).try_collect()?,
Expand Down Expand Up @@ -496,7 +501,7 @@ impl<'m> Ctxt<'_, 'm> {
Ok(self.dir().relative(path))
}

/// Build banklinks for the current item.
/// Build backlinks for the current item.
fn module_path_html(&self, meta: Meta<'_>, is_module: bool) -> Result<String> {
let mut module = Vec::new();
let item = meta.item.context("Missing module item")?;
Expand Down
2 changes: 1 addition & 1 deletion crates/rune/src/doc/static/enum.html.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{#> layout}}
<h3 class="title">Enum {{literal module}}::<span class="enum">{{name}}</span></h3>
<div class="title-wrapper"><h3 class="title">Enum {{literal module}}::<span class="enum">{{name}}</span></h3><a class="overview" href="{{literal root_index}}">Overview</a></div>
{{#if doc}}{{literal doc}}{{/if}}

{{#if variants}}
Expand Down
2 changes: 1 addition & 1 deletion crates/rune/src/doc/static/function.html.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{#> layout}}
<body>
<h3 class="title">Function {{literal module}}::<span class="fn">{{name}}</span></h3>
<div class="title-wrapper"><h3 class="title">Function {{literal module}}::<span class="fn">{{name}}</span></h3><a class="overview" href="{{literal root_index}}">Overview</a></div>
<div class="signature">
{{#if is_async}}<span class="keyword async">async</span> {{/if}} <span class="keyword fn">fn</span> <span class="fn">{{name}}</span>({{literal args}}){{#if this.return_type}} -&gt; {{literal this.return_type}}{{/if}}</h3>
</div>
Expand Down
2 changes: 1 addition & 1 deletion crates/rune/src/doc/static/macro.html.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{#> layout}}
<h3 class="title">Macro {{literal module}}::<span class="macro">{{name}}!</span>(..)</h3>
<div class="title-wrapper"><h3 class="title">Macro {{literal module}}::<span class="macro">{{name}}!</span>(..)</h3><a class="overview" href="{{literal root_index}}">Overview</a></div>
{{#if doc}}{{literal doc}}{{/if}}
{{/layout}}
2 changes: 1 addition & 1 deletion crates/rune/src/doc/static/module.html.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{#> layout}}
<h3 class="title">Module {{literal module}}</h3>
<div class="title-wrapper"><h3 class="title">Module {{literal module}}</h3><a class="overview" href="{{literal root_index}}">Overview</a></div>
{{#if doc}}{{literal doc}}{{/if}}

{{#if types}}
Expand Down
10 changes: 10 additions & 0 deletions crates/rune/src/doc/static/runedoc.css.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,16 @@ p > code {
padding: 0 0.125em;
}

.overview {
color: var(--link-color);
}

.title-wrapper {
display: flex;
justify-content: space-between;
align-items: center;
}

.title {
font-size: 1.5rem;
line-height: 1.25;
Expand Down
2 changes: 1 addition & 1 deletion crates/rune/src/doc/static/type.html.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{#> layout}}
<h3 class="title">{{what}} {{literal module}}::<span class="{{what_class}}">{{name}}</span></h3>
<div class="title-wrapper"><h3 class="title">{{what}} {{literal module}}::<span class="{{what_class}}">{{name}}</span></h3><a class="overview" href="{{literal root_index}}">Overview</a></div>
{{#if doc}}{{literal doc}}{{/if}}

{{#if methods}}
Expand Down

0 comments on commit 6cc948f

Please sign in to comment.