Skip to content

Commit

Permalink
rebase on master
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnychen94 committed Aug 14, 2021
1 parent dd28e10 commit 06ce59f
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 31 deletions.
5 changes: 5 additions & 0 deletions src/generate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@ function makedemos(source::String, templates::Union{Dict, Nothing} = nothing;
out_path = joinpath(relative_root, "index.md")
end

# Ensure every path exists before we actually do the work
walkpage(page) do dir, item
@assert isfile(item.path) || isdir(item.path)
end

@info "SetupDemoCardsDirectory: setting up \"$(source)\" directory."
if isdir(absolute_root)
# a typical and probably safe case -- that we're still in docs/ folder
Expand Down
4 changes: 2 additions & 2 deletions src/remote.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ function Base.show(io::IO, card::LocalRemoteCard)
print(io, basename(card), " => ", card.path)
end

function generate(card::LocalRemoteCard, template)
function generate(card::LocalRemoteCard, template; kwargs...)
with_tempcard(card) do tempcard
generate(tempcard, template)
generate(tempcard, template; kwargs...)
end
end
function save_democards(card_dir::String, card::LocalRemoteCard; kwargs...)
Expand Down
18 changes: 1 addition & 17 deletions src/types/section.jl
Original file line number Diff line number Diff line change
Expand Up @@ -119,22 +119,6 @@ function DemoSection(root::String)::DemoSection
!(x isa UnmatchedCard)
end

section = DemoSection(root,
cards,
map(DemoSection, section_paths),
"",
"",
Dict{String, Any}())

ordered_paths = joinpath.(root, load_config(section, "order"; config=config))
if !isempty(section.cards)
cards = map(democard, ordered_paths)
subsections = []
else
cards = []
subsections = map(DemoSection, ordered_paths)
end

if haskey(config, "remote")
remote_cards = LocalRemoteCard[]
for (cardname, cardpath) in config["remote"]
Expand All @@ -146,7 +130,7 @@ function DemoSection(root::String)::DemoSection
end

subsections = map(DemoSection, section_paths)
section = DemoSection(root, cards, subsections, "", "")
section = DemoSection(root, cards, subsections, "", "", Dict{String, Any}())
cards, subsections = sort_by_order(section, config)

title = load_config(section, "title"; config=config)
Expand Down
Empty file.
4 changes: 2 additions & 2 deletions test/assets/remote/remote_card_mixed/config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"remote": {
"julia_card": "../../card/julia/title_1.jl",
"markdown_card": "../../card/markdown/title_3.md"
"julia_card1": "../../card/julia/cover_1.jl",
"markdown_card1": "../../card/markdown/cover_3.md"
}
}
10 changes: 5 additions & 5 deletions test/assets/remote/remote_card_mixed_order/config.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"remote": {
"julia_card.jl": "../../card/julia/title_1.jl",
"markdown_card.md": "../../card/markdown/title_3.md"
"julia_card2.jl": "../../card/julia/version_1.jl",
"markdown_card2.md": "../../card/markdown/description_1.md"
},
"order": [
"julia_card.jl",
"markdown_card.md",
"title_2.md"
"julia_card2.jl",
"markdown_card2.md",
"card2.md"
]
}
3 changes: 0 additions & 3 deletions test/assets/remote/remote_card_mixed_order/title_2.md

This file was deleted.

4 changes: 2 additions & 2 deletions test/assets/remote/remote_card_simplest/config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"remote": {
"julia_card": "../../card/julia/title_2.jl",
"markdown_card": "../../card/markdown/title_4.md"
"julia_card3": "../../card/julia/simplest.jl",
"markdown_card3": "../../card/markdown/simplest.md"
}
}
1 change: 1 addition & 0 deletions test/remote.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
(5, "remote_card_mixed"),
(4, "remote_card_simplest")
]
# there will be warnings due to lack of cover images, but we can just safely ignore them
@suppress_err preview_demos(joinpath(abs_root, dir); theme="grid")
page_dir = @suppress_err preview_demos(joinpath(abs_root, dir); require_html=false)
files = readdir(joinpath(page_dir, dir))
Expand Down

0 comments on commit 06ce59f

Please sign in to comment.