Skip to content

Commit

Permalink
move rendering of collapsable div to own function
Browse files Browse the repository at this point in the history
  • Loading branch information
laborg committed Mar 9, 2024
1 parent cca21de commit 78e4d15
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions src/html/HTMLWriter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -862,22 +862,13 @@ end
Constructs and writes the page referred to by the `navnode` to `.build`.
"""
function render_page(ctx, navnode)
@tags div
head = render_head(ctx, navnode)
sidebar = render_sidebar(ctx, navnode)
navbar = render_navbar(ctx, navnode, true)
article = render_article(ctx, navnode)
footer = render_footer(ctx, navnode)
meta_divs = DOM.Node[]
if get(getpage(ctx, navnode).globals.meta, :CollapsedDocStrings, false)
# if DocStringsCollapse = true in `@meta`, we let JavaScript click the
# collapse button after that page has loaded.
push!(
meta_divs,
div[Symbol("data-docstringscollapsed") => "true"]()
)
end
htmldoc = render_html(ctx, head, sidebar, navbar, article, footer, meta_divs)
extras = render_extras(ctx, navnode)
htmldoc = render_html(ctx, head, sidebar, navbar, article, footer, extras)
write_html(ctx, navnode, htmldoc)
end

Expand All @@ -887,7 +878,7 @@ end
"""
Renders the main `<html>` tag.
"""
function render_html(ctx, head, sidebar, navbar, article, footer, scripts::Vector{DOM.Node}=DOM.Node[])
function render_html(ctx, head, sidebar, navbar, article, footer, extras)
@tags html body div
DOM.HTMLDocument(
html[:lang=>ctx.settings.lang](
Expand All @@ -899,7 +890,7 @@ function render_html(ctx, head, sidebar, navbar, article, footer, scripts::Vecto
render_settings(),
),
),
scripts...
extras...
)
)
end
Expand Down Expand Up @@ -1431,6 +1422,17 @@ function render_footer(ctx, navnode)
return nav[".docs-footer"](nav_children...)
end

function render_extras(ctx, navnode)
@tags div
meta_divs = DOM.Node[]
if get(getpage(ctx, navnode).globals.meta, :CollapsedDocStrings, false)
# if DocStringsCollapse = true in `@meta`, we let JavaScript click the
# collapse button after that page has loaded.
push!(meta_divs, div[Symbol("data-docstringscollapsed") => "true"]())
end
meta_divs

Check warning on line 1433 in src/html/HTMLWriter.jl

View check run for this annotation

Codecov / codecov/patch

src/html/HTMLWriter.jl#L1433

Added line #L1433 was not covered by tests
end

# Article (page contents)
# ------------------------------------------------------------------------------

Expand Down

0 comments on commit 78e4d15

Please sign in to comment.