Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass kwargs to literate #114

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
9 changes: 6 additions & 3 deletions src/generate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@ function makedemos(source::String, templates::Union{Dict, Nothing} = nothing;
branch::String = "gh-pages",
edit_branch::String = "master",
credit = true,
throw_error = false)

throw_error = false,
kwargs...
)
if !(basename(pwd()) == "docs" || basename(root) == "docs" || root == preview_build_dir())
# special cases that warnings are not printed:
# 1. called from `docs/make.jl`
Expand Down Expand Up @@ -194,7 +195,9 @@ function makedemos(source::String, templates::Union{Dict, Nothing} = nothing;
src = src,
credit = credit,
nbviewer_root_url = get_nbviewer_root_url(branch),
throw_error=throw_error)
throw_error=throw_error,
kwargs...
)
isnothing(templates) || save_cover(joinpath(absolute_root, "covers"), page)
isnothing(templates) || generate(joinpath(absolute_root, "index.md"), page, templates)

Expand Down
7 changes: 6 additions & 1 deletion src/types/julia.jl
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ function save_democards(card_dir::String,
src="src",
throw_error = false,
properties = Dict{String, Any}(),
literate_kwargs = (),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it be NamedTuple instead of Tuple?

Suggested change
literate_kwargs = (),
literate_kwargs::NamedTuple = (;),

kwargs...)
isdir(card_dir) || mkpath(card_dir)
@debug card.path
Expand Down Expand Up @@ -228,7 +229,11 @@ function save_democards(card_dir::String,
end

# 3. markdown
@suppress Literate.markdown(src_path, card_dir; credit=false) # manually add credit later
@suppress Literate.markdown(
src_path, card_dir;
credit=false, # manually add credit later
literate_kwargs...
)
# remove meta info generated by Literate.jl
contents = readlines(md_path)
offsets = findall(x->startswith(x, "```"), contents)
Expand Down