Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update build_docs.sh script to support dev-guide #4873

Merged
merged 1 commit into from
Aug 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
BUILD_DIR=build
BUILD_DIR=$(CURDIR)/build
COVERAGE_DIR=$(BUILD_DIR)/coverage
BEATS=packetbeat filebeat winlogbeat metricbeat heartbeat auditbeat
PROJECTS=libbeat $(BEATS)
Expand Down Expand Up @@ -94,23 +94,24 @@ beats-dashboards:
# Builds the documents for each beat
.PHONY: docs
docs:
@sh libbeat/scripts/build_docs.sh $(PROJECTS)
@$(foreach var,$(PROJECTS),BUILD_DIR=${BUILD_DIR} $(MAKE) -C $(var) docs || exit 1;)
sh ./script/build_docs.sh dev-guide github.com/elastic/beats/docs/dev-guide ${BUILD_DIR}

.PHONY: package
package: update beats-dashboards
@$(foreach var,$(BEATS),SNAPSHOT=$(SNAPSHOT) $(MAKE) -C $(var) package || exit 1;)

@echo "Start building the dashboards package"
@mkdir -p build/upload/
@BUILD_DIR=$(CURDIR)/build SNAPSHOT=$(SNAPSHOT) $(MAKE) -C dev-tools/packer package-dashboards $(CURDIR)/build/upload/build_id.txt
@BUILD_DIR=${BUILD_DIR} SNAPSHOT=$(SNAPSHOT) $(MAKE) -C dev-tools/packer package-dashboards ${BUILD_DIR}/upload/build_id.txt
@mv build/upload build/dashboards-upload

@# Copy build files over to top build directory
@mkdir -p build/upload/
@$(foreach var,$(BEATS),cp -r $(var)/build/upload/ build/upload/$(var) || exit 1;)
@cp -r build/dashboards-upload build/upload/dashboards
@# Run tests on the generated packages.
@go test ./dev-tools/package_test.go -files "$(CURDIR)/build/upload/*/*"
@go test ./dev-tools/package_test.go -files "${BUILD_DIR}/upload/*/*"

# Upload nightly builds to S3
.PHONY: upload-nightlies-s3
Expand Down
5 changes: 2 additions & 3 deletions libbeat/scripts/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -290,13 +290,12 @@ endif

.PHONY: docs
docs: ## @build Builds the documents for the beat
sh ${ES_BEATS}/libbeat/scripts/build_docs.sh ${BEAT_NAME}
sh ${ES_BEATS}/script/build_docs.sh ${BEAT_NAME} ${BEAT_PATH}/docs ${BUILD_DIR}


.PHONY: docs-preview
docs-preview: ## @build Preview the documents for the beat in the browser
if [ ! -d "build/docs" ]; then $(MAKE) docs; fi;
${BUILD_DIR}/docs/build_docs.pl --chunk=1 -open chunk=1 -open --doc ${BEAT_GOPATH}/src/github.com/elastic/beats/${BEAT_NAME}/docs/index.asciidoc -out ${BUILD_DIR}/html_docs
PREVIEW=1 $(MAKE) docs

.PHONY: index-template
index-template: ## @build Generate index templates for the given $VERSION. This is for manual testing.
Expand Down
24 changes: 0 additions & 24 deletions libbeat/scripts/build_docs.sh

This file was deleted.

32 changes: 32 additions & 0 deletions script/build_docs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash

set -e

name=$1
path=$2
build_dir=$3

docs_dir=$build_dir/docs
html_dir=$build_dir/html_docs

# Checks if docs clone already exists
if [ ! -d $docs_dir ]; then
# Only head is cloned
git clone --depth=1 https://github.com/elastic/docs.git $docs_dir
else
echo "$docs_dir already exists. Not cloning."
fi


index="${GOPATH%%:*}/src/${path}/index.asciidoc"

if [ -f "$index" ]; then
echo "Building docs for ${name}..."
dest_dir="$html_dir/${name}"
mkdir -p "$dest_dir"
params=""
if [ "$PREVIEW" = "1" ]; then
params="--chunk=1 -open chunk=1 -open"
fi
$docs_dir/build_docs.pl $params --doc "$index" -out "$dest_dir"
fi