jaredly / redoc

A clean & easy documentation generator for reason/bucklescript/ocaml
https://jaredforsyth.com/redoc/index.html
116 stars 11 forks source link

add a "watch mode" #6

Open jaredly opened 6 years ago

jaredly commented 6 years ago

So when you're editing documentation, you can see the results quickly

chenglou commented 6 years ago

bsb will have a post-full-build hook for this soon

wires commented 6 years ago

FWIW, you don't need it, I use this trick:

First create a file called build-docs.js that executes the docs script from package.json:

const exec = require("child_process").exec
const packageJson = require("./package.json")
exec(packageJson.scripts.docs, function(err,stdout,stderr) {
  console.log(stdout)
  if(err) console.error(stderr)
})

then use nodemon to run that script when there are changes in the src/ folder, so you can add the following scripts to package.json.

{ "scripts": {
    "docs": "redoc --name BlaBla",
    "docs:watch": "nodemon --watch src/ build-docs.js",
} }
wires commented 6 years ago

You don't actually need this script, I just realised, lol 🤣

nodemon -w src/ --exec npm run docs does the trick