Add make run_docs_local and update readme

Signed-off-by: Phil Prasek <prasek@gmail.com>
This commit is contained in:
Phil Prasek 2019-09-13 17:25:58 -07:00
parent dfcb6e932f
commit 32671fc3f3
3 changed files with 49 additions and 1 deletions

View File

@ -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)

View File

@ -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.

View File

@ -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"
];