vituri / QuartoDocBuilder.jl

https://vituri.github.io/QuartoDocBuilder.jl/
MIT License
22 stars 1 forks source link

Generate book version #4

Open arnold-c opened 1 month ago

arnold-c commented 1 month ago

This may not be worthwhile (or particularly easy), but I wonder if it would be nice to provide a mechanism by which the user can specify if they want the docs to be served as a book or a website? The benefit of rendering a book is that you gain cross-referencing functionality, as well as producing a left sidebar that mirrors the predominant layout of most Julia documentation sites, making for potentially more familiar and easier user navigation.

It would likely be possible to keep much of the code as-is and use multiple dispatch to render the book/website specific pages with some custom structs.

# types.jl
abstract type QuartoDocument
struct QuartoWebsite <: QuartoDocument end
struct QuartoBook <: QuartoDocument end

# build.jl
function quarto_yaml(
  module_name, ::QuartoWebsite;
  ;freeze = "auto"
  ,cache = "true"
  ,warning = "false"
  ,project_type = "website"
  ,output_dir = "_site"

  ,comments = "true"
  ,repo = "USERNAME/REPOSITORY"

  ,theme = "flatly"
  )
...
end

function quarto_yaml(
  module_name, ::QuartoBook
  ;freeze = "auto"
  ,cache = "true"
  ,warning = "false"
  ,project_type = "book"
  ,output_dir = "_book"

  ,comments = "true"
  ,repo = "USERNAME/REPOSITORY"

  ,theme = "flatly"
  )
...
end

Feel free to ignore if this is out of scope/too much work, but wanted to suggest just in case it was helpful

vituri commented 1 month ago

Good point! I often use the book format when preparing workshops, and it is a good use for documentations. What other changes do I need to make at the _quarto.yaml besides changing the type of project?

I am asking because if all that is needed is to change type: website to type: book, then it is easier to edit the generated _quarto.yaml template "by hand" than to use another function and dispatch, as you suggest. In any case you have to edit this file to add more qmd files, so you already need to have some knowledge of Quarto. What do you think?