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

Support Pluto.jl notebooks for demos? #120

Closed
Dsantra92 opened this issue Jul 13, 2022 · 4 comments · Fixed by #121
Closed

Support Pluto.jl notebooks for demos? #120

Dsantra92 opened this issue Jul 13, 2022 · 4 comments · Fixed by #121

Comments

@Dsantra92
Copy link
Collaborator

It would be nice to have DemoCards working with Pluto.jl. I was planning to use it for demos in GraphNeuralNetworks.jl.

ps: I will be happy to contribute to the feature (if approved).

@johnnychen94
Copy link
Member

johnnychen94 commented Jul 13, 2022

There are two ways to bring Pluto into this package:

  • starting from a normal Julia script, then generating the pluto Julia script, and finally provides the pluto Julia script as an alternative to the current ipynb notebook version?
  • export HTML from source pluto Julia script and insert into the generated index page

The first solution requires Litearte support (fredrikekre/Literate.jl#120). For the second solution, is there a stable Pluto API to export HTML (or markdown files) here? I don't use Pluto much so don't know if this is doable.

Edit: my Julia service time is starting to be more limited so I'll be more focused on JuliaImages-related stuff. Thus it would be fantastic if you find out a way to support this and open a PR.

@Dsantra92
Copy link
Collaborator Author

The 2nd option looks doable, rendering in Pluto is doable but I need to know about this package more. Let's see if I can find a solution.

@johnnychen94
Copy link
Member

johnnychen94 commented Jul 14, 2022

You can maybe start with a runtime dispatch to generate a new type PlutoCard:

function democard(path::String)::AbstractDemoCard
validate_file(path)
_, ext = splitext(path)
if ext in markdown_exts
return MarkdownDemoCard(path)
elseif ext in julia_exts
return JuliaDemoCard(path)
else
return UnmatchedCard(path)
end
end
Then add the necessary save_democards function
function save_democards(card_dir::String,
card::JuliaDemoCard;
credit,
nbviewer_root_url,
project_dir=Base.source_dir(),
src="src",
throw_error = false,
properties = Dict{String, Any}(),
kwargs...)

Some special handling might be needed to directly insert the HTML into the template without passing it to Documenter's HTML generation. For instance, DemoCards uses Documenter's [](@ref id) syntax to generate the reflink. For Pluto notebook, we might need a conditional check to insert the relative path instead. (The id property is useless as well)

@Dsantra92
Copy link
Collaborator Author

Thanks for the headstart!!

@Dsantra92 Dsantra92 linked a pull request Sep 30, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants