From 32671fc3f3d78decfb8c61e5001fced26f97de75 Mon Sep 17 00:00:00 2001 From: Phil Prasek Date: Fri, 13 Sep 2019 17:25:58 -0700 Subject: [PATCH] Add make run_docs_local and update readme Signed-off-by: Phil Prasek --- Makefile | 18 ++++++++++++++++++ README.md | 15 +++++++++++++++ preprocess.js | 17 ++++++++++++++++- 3 files changed, 49 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 82277f77..747be84e 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,7 @@ # Run jekyll in development mode + +LOCAL_DOCS_DIR := docs/local + run: _data/versions.json docker run --rm -it \ -p 4000:4000 -p 4001:4001 \ @@ -7,6 +10,16 @@ run: _data/versions.json jekyll/jekyll -- \ jekyll serve --livereload --livereload-port 4001 +run_docs_local: local_docs_dir _data/versions.json + docker run --rm -it \ + -p 4000:4000 -p 4001:4001 \ + -v="$(PWD)/vendor/bundle:/usr/local/bundle" \ + -v "$(PWD):/srv/jekyll" \ + -v "$(GOPATH)/src/github.com/crossplaneio/crossplane/docs:/srv/jekyll/$(LOCAL_DOCS_DIR)" \ + jekyll/jekyll -- \ + jekyll serve --livereload --livereload-port 4001 + rm -d $(LOCAL_DOCS_DIR) + # Build (output is in _site) build: _data/versions.json docker run --rm -it \ @@ -38,3 +51,8 @@ _data/versions.json: node_modules docs node_modules: package.json package-lock.json npm install @touch node_modules + +# Create the local docs dir needed before _data/versions.json in some cases +local_docs_dir: + mkdir -p $(LOCAL_DOCS_DIR) + diff --git a/README.md b/README.md index 76232b6f..c6a00564 100644 --- a/README.md +++ b/README.md @@ -7,5 +7,20 @@ This is the the source for http://crossplane.io. It is rendered using [Jekyll](h This runs locally watching for changes and live reloading. ``` +brew install npm + make run ``` + +Open http://localhost:4000 in your browser. + +## To run locally with local crossplane docs +Ensure `$(GOPATH)/src/github.com/crossplaneio/crossplane/docs` is present. + +``` +brew install npm + +make run_docs_local +``` + +Open http://localhost:4000 in your browser. diff --git a/preprocess.js b/preprocess.js index 79d26f2c..42419402 100755 --- a/preprocess.js +++ b/preprocess.js @@ -16,13 +16,28 @@ function getDirectories(srcpath) { const ROOT_DIR = `${__dirname}`; +// This version map and version function allow versions that do not follow semver syntax to also +// be included in the version selection sorting for the site. "local" is the developer version +// used when testing docs changes in a local development environment. We set this "local" +// version as 7.7.7 (a high value) so that it will show up as the "latest" version in the site's +// version selection dropdown. +const versionMap = new Map([ + ["local", "7.7.7"] +]) +function version(v) { + if (versionMap.has(v)){ + return versionMap.get(v) + } + return semver.coerce(v).version +} + // collect all docs versions (forcing master to the end) const data = []; const versions = [ ...getDirectories(`${ROOT_DIR}/docs`) .filter(v => v !== "master") .sort((a, b) => - semver.rcompare(semver.coerce(a).version, semver.coerce(b).version) + semver.rcompare(version(a), version(b)) ), "master" ];