liveBook · Manning

Revise

As explained in Julia as a Second Language

Revise is a Julia package that detects changes to loaded source code and updates the corresponding definitions during development.

Package development is iterative: edit a definition, try it in the Julia REPL, then edit it again. Revise helps keep that loop moving. It monitors changes to packages loaded after Revise and updates their definitions in the REPL. section 16.3 section 16.6

Set up a working environment for the loop:

  • Add Revise to your working environment rather than making it a dependency of the package you are building. section 16.3
  • Use the package manager’s `dev` command with the local package directory instead of `add`. The working environment then knows where to find the developing package. section 16.3
  • Load Revise before the package whose changes you want it to monitor. section 16.6

Working on a local package

In a hobby environment, add Revise and run `dev ./ToyGeometry` for a local package. After loading Revise and then ToyGeometry, edits to the loaded package can be reflected in the REPL as you test its functions. The `dev` step and Revise serve different purposes: one makes the local package available to the environment; the other monitors changes after loading. section 16.3 section 16.6

shell> pwd
~/dev/hobby

shell> ls
Manifest.toml    Project.toml    ToyGeometry

(hobby) pkg> dev ./ToyGeometry
  Resolving package versions...
   Updating `~/dev/hobby/Project.toml`
 [bbcec4ee] + ToyGeometry v0.1.0 `ToyGeometry`
   Updating `~/dev/hobby/Manifest.toml`
 [bbcec4ee] + ToyGeometry v0.1.0 `ToyGeometry`

The package-manager transcript shows how `dev ./ToyGeometry` registers a local package in the working environment. section 16.3

How Julia as a Second Language covers it

How deep it goes
Explains where Revise fits in package development and its load-order requirement, without detailing its change-detection internals.
Examples
Uses a hobby environment and a local ToyGeometry package to show installing Revise and registering the package with `dev`.
What it assumes
Assumes a local Julia package with a working package structure and uses the REPL and package environments to set up development.
What you can do after
Operate Revise during local package development by loading it before the package being edited.
How it connects
Connects Revise to the Julia REPL, package environments, local package development, and the package manager’s `dev` command.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Julia as a Second Language. The section links point to the parts of the book it draws on.