Skip to content

servedocs-equivalent without file watch and manual trigger #200

@hexaeder

Description

@hexaeder

Hello,

before I even discovered servedocs, I was using LiveServer in a more "manual way". Something like:

using Revise, LiveServer, REPL.TerminalMenus

@async serve(; dir=joinpath(@__DIR__, "build"), 8000)

menu = RadioMenu(["Run again!", "Quit!"])
while true
    revise()
    @info "Start building docs..."
    try
        include("make.jl")
    catch e
        @info "make.jl error" e
    end

    println("\nDocs are served at http://localhost:$port")
    if request("What now?", menu) != 1
        break
    end
end

Which essentially starts a server, builds the docs and ends with a prompt to rebuild, so the users can just hit enter to revise and start the whole build again (reusing the same Julia process for performance). For me this is great if you have:

  • long running @example blocks and don't want to trigger build whenever you accidentally hit save (which I often do mindlessly after every character 😅)
  • fiddle around with doc strings (as it calls revise and rebuilds) (ref Watch docstrings #140 )

On the other hand, servedocs is just great when using draft=true, focusing on equations, formatting and stuff like that. Since I find myself switching between the two modes constantly, I was wondering whether it would make sense to include such a manually triggered, full rerun of make.jl execution mode in servedocs. So one could call

servedocs(...; watch_files=true) # default
servedocs(...; watch_files=false) # asks users for rebuild and includes make again

This would simplify the localmake.jl scripts in have in nearly all of my packages.

Would something like that be a usefull contribution? Or do you consider it out of scope for this package as it can be already achieved with a few lines of user code?

Now that I think about, this feature would essentially require two parts:

  • add an option to switch rebuild trigger between file watch and manual prompt
  • add a package extension for Revise and add a revise=true/false keyword. If Revise is loaded and revise==true, it could trigger revise() within the servedocs_callback! (this would probably also solve Watch docstrings #140

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions