Public Interface

Documentation for LiveServer.jl's exported functions

LiveServer.serveFunction
serve(filewatcher; ...)

Main function to start a server at http://host:port and render what is in the current directory. (See also example for an example folder).

Arguments

  • filewatcher: a file watcher implementing the API described for SimpleWatcher (which also is the default) messaging the viewers (via WebSockets) upon detecting file changes.
  • port: integer
  • dir: string specifying where to launch the server if not the current working directory.
  • debug: bolean switch to make the server print debug messages.
  • verbose: boolean switch to make the server print information about file changes and connections.
  • coreloopfun: function which can be run every 0.1 second while the server is running; it takes two arguments: the cycle counter and the filewatcher. By default the coreloop does nothing.
  • launch_browser: boolean specifying whether to launch the ambient browser at the localhost or not (default: false).

allow_cors: boolean allowing cross origin (CORS) requests to access the server via the "Access-Control-Allow-Origin" header. preprocess_request: function specifying the transformation of a request before it is returned; its only argument is the current request.

Example

julia LiveServer.example() serve(host="127.0.0.1", port=8080, dir="example", launch_browser=true)

You should then see the index.html page from the example folder being rendered. If you change the file, the browser will automatically reload the page and show the changes.

source
LiveServer.servedocsFunction
servedocs(; kwargs...)

Can be used when developing a package to run the docs/make.jl file from Documenter.jl and then serve the docs/build folder with LiveServer.jl. This function assumes you are in the directory [MyPackage].jl with a subfolder docs.

Keyword Arguments

  • verbose=false: boolean switch to make the server print information about file changes and connections.
  • doc_env=false: a boolean switch to make the server start by activating the

doc environment or not (i.e. the Project.toml in docs/).

  • literate=nothing: see literate_dir.
  • literate_dir=nothing: Path to a directory containing Literate scripts if these are not simply under docs/src. See also the docs for information about how to work with Literate.
  • skip_dir="": a path starting with docs/ where modifications should not trigger the generation of the docs, this is useful for instance if you're using Weave and Weave generates some files in docs/src/examples in which case you should set skip_dir=joinpath("docs","src","examples").
  • skip_dirs=[]: same as skip_dir but for a list of such dirs. Takes precedence over skip_dir.
  • skip_files=[]: a vector of files that should not trigger regeneration.
  • include_dirs=[]: extra source directories to watch (in addition to joinpath(foldername, "src")).
  • include_files=[]: extra source files to watch. Takes precedence over skip_dirs so can e.g. be used to track individual files in an otherwise skipped directory.
  • foldername="docs": specify a different path for the content.
  • buildfoldername="build": specify a different path for the build.
  • makejl="make.jl": path of the script generating the documentation relative to foldername.
  • host="127.0.0.1": where the server will start.
  • port=8000: port number.
  • launch_browser=false: specifies whether to launch a browser at the localhost URL or not.
source