Skip to content

Commit 16e63ba

Browse files
authoredNov 19, 2021
Add mdbook skeleton (#426)
1 parent 6c334dc commit 16e63ba

25 files changed

+308
-65
lines changed
 

‎common.mk

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11

2+
include $(ROOT_DIR_RELATIVE)/versions.mk
23

34
TOOLS_DIR := $(ROOT_DIR_RELATIVE)/hack/tools
45
TOOLS_DIR_DEPS := $(TOOLS_DIR)/go.sum $(TOOLS_DIR)/go.mod $(TOOLS_DIR)/Makefile

‎docs/book/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
book

‎docs/book/Makefile

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Copyright 2021 The Kubernetes Authors.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
ROOT_DIR_RELATIVE := ../..
16+
include $(ROOT_DIR_RELATIVE)/common.mk
17+
18+
# Directories.
19+
MDBOOK := $(TOOLS_BIN_DIR)/mdbook
20+
MDBOOK_EMBED := $(TOOLS_BIN_DIR)/mdbook-embed
21+
MDBOOK_RELEASELINK := $(TOOLS_BIN_DIR)/mdbook-releaselink
22+
MDBOOK_TABULATE := $(TOOLS_BIN_DIR)/mdbook-tabulate
23+
GENCRDAPIREFERENCEDOCS := $(TOOLS_BIN_DIR)/gen-crd-api-reference-docs
24+
GENCRDAPIREFERENCEDOCS_SRCS := $(call rwildcard,.,gen-crd-api-reference-docs/*.*)
25+
CRD_DOCS := src/crd/cluster-api-aws.md src/crd/experimental.md src/crd/eks-control-plane.md
26+
BOOK_SRCS := $(filter-out $(CRD_DOCS), $(call rwildcard,.,*.*))
27+
28+
API_DIRS := cmd/clusterawsadm/api/bootstrap/v1beta1 api/v1beta1 exp/api/v1beta1 controlplane/eks/api/v1beta1 bootstrap/eks/api/v1beta1 iam/api/v1beta1
29+
API_SRCS := $(foreach dir, $(API_DIRS), $(call rwildcard,../../$(dir),*.go))
30+
GENERATED_SRCS := $(foreach dir, $(API_DIRS),../../$(dir)/zz_generated.deepcopy.go ../../$(dir)/zz_generated.conversion.go ../../$(dir)/zz_generated.defaults.go)
31+
API_FILTERED_SRCS := $(filter-out $(GENERATED_SRCS), $(API_SRCS))
32+
33+
OS := $(shell go env GOOS)
34+
ARCH := $(shell go env GOARCH)
35+
PATH := $(abspath $(TOOLS_BIN_DIR)):$(PATH)
36+
export PATH
37+
38+
src/crd:
39+
mkdir -p src/crd
40+
41+
src/crd/index.md: $(API_FILTERED_SRCS) src/crd
42+
$(MAKE) gen_crd_docs API_DIR="../.." OUT_FILE=$@
43+
44+
.PHONY: gen_crd_docs
45+
gen_crd_docs: $(GENCRDAPIREFERENCEDOCS) src/crd $(GENCRDAPIREFERENCEDOCS_SRCS)
46+
$(GENCRDAPIREFERENCEDOCS) -template-dir gen-crd-api-reference-docs/template -config "gen-crd-api-reference-docs/config.json" \
47+
-api-dir $(API_DIR) \
48+
-out-file $(OUT_FILE)
49+
50+
src/clusterawsadm:
51+
mkdir -p src/clusterawsadm
52+
53+
terraform/out:
54+
mkdir -p terraform/out
55+
56+
terraform/out/amilist: terraform/out
57+
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o $@ ./cmd/amilist && chmod 755 $@
58+
59+
.PHONY: generate
60+
generate: ## Generate any dependent files outside of a build
61+
$(MAKE) -C ../ diagrams
62+
63+
#src/SUMMARY_CLUSTERAWSADM.md: src/clusterawsadm $(CLUSTERAWSADMCMDREF_SRCS)
64+
# go run ./cmd/clusterawsadmdocs > src/SUMMARY_CLUSTERAWSADM.md
65+
#
66+
## SUMMARY.md doesn't support processor statements, so construct it using cat
67+
#src/SUMMARY.md: src/SUMMARY_PREFIX.md src/SUMMARY_SUFFIX.md
68+
# cat src/SUMMARY_PREFIX.md > src/SUMMARY.md
69+
# cat src/SUMMARY_CLUSTERAWSADM.md >> src/SUMMARY.md
70+
# cat src/SUMMARY_SUFFIX.md >> src/SUMMARY.md
71+
72+
verify: generate ## Verify that dependent artifacts are up to date
73+
@if !(git diff --quiet HEAD); then \
74+
git diff; \
75+
echo "generated files are out of date, run make generate"; exit 1; \
76+
fi
77+
78+
BOOK_DEPS := $(BOOK_SRCS) $(MDBOOK) $(MDBOOK_EMBED) $(MDBOOK_RELEASELINK) $(MDBOOK_TABULATE) #src/SUMMARY.md src/crd/index.md
79+
80+
.PHONY: build
81+
build: $(BOOK_DEPS) ## Build the book
82+
$(MDBOOK) build
83+
84+
.PHONY: serve
85+
serve: $(BOOK_DEPS) ## Run a local webserver with the compiled book
86+
$(MDBOOK) serve
87+
88+
.PHONY: clean
89+
clean:
90+
rm -rf book

‎docs/book/book.toml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[book]
2+
authors = ["The Cluster API Provider IBMCloud Maintainers"]
3+
language = "en"
4+
multilingual = false
5+
src = "src"
6+
title = "Kubernetes Cluster API Provider IBMCloud"
7+
8+
[output.html]
9+
curly-quotes = true
10+
git-repository-url = "https://sigs.k8s.io/cluster-api-provider-ibmcloud"
11+
12+
[preprocessor.tabulate]
13+
command = "mdbook-tabulate"
14+
15+
[preprocessor.embed]
16+
command = "mdbook-embed"
17+
18+
[preprocessor.releaselink]
19+
command = "mdbook-releaselink"

‎docs/book/src/SUMMARY.md

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Summary
2+
3+
- [Introduction](./introduction.md)
4+
- [Getting Started](./getting-started.md)
5+
- [Topics](./topics/index.md)
6+
- [VPC Cluster](./topics/vpc/index.md)
7+
- [Prerequisites](./topics/vpc/prerequisites.md)
8+
- [Creating a cluster](./topics/vpc/creating-a-cluster.md)
9+
- [Power VS Cluster](./topics/powervs/index.md)
10+
- [Prerequisites](./topics/powervs/prerequisites.md)
11+
- [Creating a cluster](./topics/powervs/creating-a-cluster.md)
12+
- [Developer Guide](./developer/index.md)
13+
- [Rapid iterative development with Tilt](./developer/tilt.md)
14+
- [Release Process](./developer/release.md)
15+
- [Troubleshooting](./user/troubleshooting.md)
16+
- [Reference](./reference/reference.md)

‎docs/book/src/developer/index.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Developer Guide

‎docs/book/src/developer/release.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Release Process

‎docs/book/src/developer/tilt.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Rapid iterative development with Tilt

‎docs/book/src/getting-started.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Getting Started

‎docs/book/src/introduction.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Introduction

‎docs/book/src/reference/reference.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Reference

‎docs/book/src/topics/index.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Topics
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Creating a cluster

‎docs/book/src/topics/powervs/index.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Power VS Cluster
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Prerequisites
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Creating a cluster

‎docs/book/src/topics/vpc/index.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# VPC Cluster
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Prerequisites

‎docs/book/src/user/troubleshooting.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Troubleshooting

‎hack/tools/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
bin
2+
share

‎hack/tools/Makefile

+45
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,35 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
ROOT_DIR_RELATIVE := ../..
16+
include $(ROOT_DIR_RELATIVE)/common.mk
17+
1518
# Directories.
1619
BIN_DIR := bin
20+
SHARE_DIR := share
21+
22+
OS := $(shell go env GOOS)
23+
RUST_TARGET := unknown-$(OS)-gnu
24+
25+
ifeq ($(OS), darwin)
26+
RUST_TARGET := apple-darwin
27+
endif
1728

1829
$(BIN_DIR):
1930
mkdir -p $@
2031

32+
$(SHARE_DIR):
33+
mkdir -p $@
34+
35+
MDBOOK_EXTRACT_COMMAND := tar xfvz $(SHARE_DIR)/mdbook.tar.gz -C bin
36+
MDBOOK_ARCHIVE_EXT := .tar.gz
37+
38+
ifeq ($(OS), windows)
39+
RUST_TARGET := pc-windows-msvc
40+
MDBOOK_ARCHIVE_EXT := .zip
41+
MDBOOK_EXTRACT_COMMAND := unzip -d /tmp
42+
endif
43+
2144
GOLANGCI_LINT := $(BIN_DIR)/golangci-lint
2245
$(GOLANGCI_LINT): $(BIN_DIR) go.mod go.sum # Build golangci-lint from tools folder.
2346
go build -tags=tools -o $@ github.com/golangci/golangci-lint/cmd/golangci-lint
@@ -26,6 +49,28 @@ KUSTOMIZE := $(BIN_DIR)/kustomize
2649
$(KUSTOMIZE): $(BIN_DIR) go.mod go.sum # Build kustomize from tools folder.
2750
CGO_ENABLED=0 go build -tags=tools -o $@ sigs.k8s.io/kustomize/kustomize/v3
2851

52+
MDBOOK_SHARE := $(SHARE_DIR)/mdbook$(MDBOOK_ARCHIVE_EXT)
53+
$(MDBOOK_SHARE): ../../versions.mk $(SHARE_DIR)
54+
curl -sL -o $(MDBOOK_SHARE) "https://github.com/rust-lang/mdBook/releases/download/$(MDBOOK_VERSION)/mdBook-$(MDBOOK_VERSION)-x86_64-$(RUST_TARGET)$(MDBOOK_ARCHIVE_EXT)"
55+
56+
MDBOOK := $(BIN_DIR)/mdbook
57+
$(MDBOOK): $(BIN_DIR) $(MDBOOK_SHARE)
58+
$(MDBOOK_EXTRACT_COMMAND)
59+
chmod +x $@
60+
touch -m $@
61+
62+
MDBOOK_EMBED := $(BIN_DIR)/mdbook-embed
63+
$(MDBOOK_EMBED): $(BIN_DIR) go.mod go.sum
64+
go build -tags=tools -o $(BIN_DIR)/mdbook-embed sigs.k8s.io/cluster-api/hack/tools/mdbook/embed
65+
66+
MDBOOK_RELEASELINK := $(BIN_DIR)/mdbook-releaselink
67+
$(MDBOOK_RELEASELINK): $(BIN_DIR) go.mod go.sum
68+
go build -tags=tools -o $(BIN_DIR)/mdbook-releaselink sigs.k8s.io/cluster-api/hack/tools/mdbook/releaselink
69+
70+
MDBOOK_TABULATE := $(BIN_DIR)/mdbook-tabulate
71+
$(MDBOOK_TABULATE): $(BIN_DIR) go.mod go.sum
72+
go build -tags=tools -o $(BIN_DIR)/mdbook-tabulate sigs.k8s.io/cluster-api/hack/tools/mdbook/tabulate
73+
2974
GOJQ := $(BIN_DIR)/gojq
3075
$(GOJQ): $(BIN_DIR) go.mod go.sum
3176
go build -tags=tools -o $@ github.com/itchyny/gojq/cmd/gojq

‎hack/tools/go.mod

+9-10
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,20 @@ go 1.16
44

55
require (
66
github.com/blang/semver v3.5.1+incompatible
7-
github.com/drone/envsubst/v2 v2.0.0-20210615175204-7bf45dbf5372
7+
github.com/drone/envsubst/v2 v2.0.0-20210730161058-179042472c46
88
github.com/golangci/golangci-lint v1.41.1
99
github.com/hashicorp/go-multierror v1.1.1
1010
github.com/itchyny/gojq v0.12.5
1111
github.com/joelanford/go-apidiff v0.1.0
12-
github.com/onsi/ginkgo v1.16.4
12+
github.com/onsi/ginkgo v1.16.5
1313
github.com/pkg/errors v0.9.1
14-
github.com/sergi/go-diff v1.2.0 // indirect
15-
golang.org/x/exp v0.0.0-20210625193404-fa9d1d177d71 // indirect
16-
golang.org/x/tools v0.1.5
14+
golang.org/x/tools v0.1.8-0.20211029000441-d6a9af8af023
1715
gotest.tools/gotestsum v1.6.4
18-
k8s.io/code-generator v0.22.2
19-
k8s.io/klog/v2 v2.9.0
20-
sigs.k8s.io/controller-runtime/tools/setup-envtest v0.0.0-20210827150604-1730628f118b
21-
sigs.k8s.io/controller-tools v0.7.0
22-
sigs.k8s.io/kubebuilder/docs/book/utils v0.0.0-20210702145813-742983631190
16+
k8s.io/code-generator v0.23.0-alpha.4
17+
k8s.io/klog/v2 v2.30.0
18+
sigs.k8s.io/cluster-api/hack/tools v0.0.0-20211118171502-aafa086da595
19+
sigs.k8s.io/controller-runtime/tools/setup-envtest v0.0.0-20211110210527-619e6b92dab9
20+
sigs.k8s.io/controller-tools v0.7.1-0.20211110210727-ab52f76cc7d1
21+
sigs.k8s.io/kubebuilder/docs/book/utils v0.0.0-20211028165026-57688c578b5d
2322
sigs.k8s.io/kustomize/kustomize/v3 v3.10.0
2423
)

‎hack/tools/go.sum

+95-55
Large diffs are not rendered by default.

‎hack/tools/tools.go

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
_ "github.com/onsi/ginkgo/ginkgo"
2828
_ "gotest.tools/gotestsum"
2929
_ "k8s.io/code-generator/cmd/conversion-gen"
30+
_ "sigs.k8s.io/cluster-api/hack/tools/mdbook/embed"
3031
_ "sigs.k8s.io/controller-runtime/tools/setup-envtest"
3132
_ "sigs.k8s.io/controller-tools/cmd/controller-gen"
3233
_ "sigs.k8s.io/kustomize/kustomize/v3"

‎versions.mk

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright 2021 The Kubernetes Authors.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
MDBOOK_VERSION := v0.4.5

0 commit comments

Comments
 (0)
Please sign in to comment.