Skip to content

Commit

Permalink
Added versioning to website (#2802)
Browse files Browse the repository at this point in the history
* Added versioning to website and created script for cloning docs

Signed-off-by: thisisobate <[email protected]>

* improved banner.html and modified some css classes

Signed-off-by: thisisobate <[email protected]>

* changed docs file name from release to versions (v)

Signed-off-by: thisisobate <[email protected]>

* improved banner.html to include the actually past version we are looking on

Signed-off-by: thisisobate <[email protected]>

* Capitalized sidemenu header sections

Signed-off-by: thisisobate <[email protected]>

* Improved release regex to catch missing release docs

Signed-off-by: thisisobate <[email protected]>

* Fixed linking in version picker to accomodate more levels of dirsstructure

Signed-off-by: thisisobate <[email protected]>

* added semver sorting capability in version picker

Signed-off-by: thisisobate <[email protected]>

* clearly formatted the scripts and fixed linking in docs/how-to-contribute.md

Signed-off-by: thisisobate <[email protected]>

* fixed linking connectivity in docs/getting-started.md

Signed-off-by: thisisobate <[email protected]>

* made plugin to clone only major.minor release branches

Signed-off-by: thisisobate <[email protected]>

* fixed explicit bash call in makefile and renamed branch variable to tags in websitepreprocess

Signed-off-by: thisisobate <[email protected]>

* cleaned up websitepreprocess by removing irrelevant comments

Signed-off-by: thisisobate <[email protected]>

* fixed proposal, components, and operating dirs to render content on website

Signed-off-by: thisisobate <[email protected]>

* formatted scripts appropriately

Signed-off-by: thisisobate <[email protected]>

* cleaned up code

Signed-off-by: thisisobate <[email protected]>

* disable search for now until we fix it to understand new dir structure

Signed-off-by: thisisobate <[email protected]>

* updated Hugo version to utilise new Hugo variables and functions

Signed-off-by: thisisobate <[email protected]>

* made Proposal, components, and operating to render without deleting _index.md

Signed-off-by: thisisobate <[email protected]>

* disabled searchbox until we fix it to understand new dir structure

Signed-off-by: thisisobate <[email protected]>
  • Loading branch information
thisisobate authored Aug 24, 2020
1 parent ee855dc commit 0b8507c
Show file tree
Hide file tree
Showing 16 changed files with 172 additions and 135 deletions.
6 changes: 3 additions & 3 deletions .bingo/Variables.mk
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ $(GOLANGCI_LINT): .bingo/golangci-lint.mod
@echo "(re)installing $(GOBIN)/golangci-lint-v1.29.0"
@cd .bingo && $(GO) build -modfile=golangci-lint.mod -o=$(GOBIN)/golangci-lint-v1.29.0 "github.com/golangci/golangci-lint/cmd/golangci-lint"

HUGO := $(GOBIN)/hugo-v0.55.3
HUGO := $(GOBIN)/hugo-v0.74.3
$(HUGO): .bingo/hugo.mod
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.
@echo "(re)installing $(GOBIN)/hugo-v0.55.3"
@cd .bingo && $(GO) build -modfile=hugo.mod -o=$(GOBIN)/hugo-v0.55.3 "github.com/gohugoio/hugo"
@echo "(re)installing $(GOBIN)/hugo-v0.74.3"
@cd .bingo && $(GO) build -modfile=hugo.mod -o=$(GOBIN)/hugo-v0.74.3 "github.com/gohugoio/hugo"

JB := $(GOBIN)/jb-v0.4.0
$(JB): .bingo/jb.mod
Expand Down
4 changes: 2 additions & 2 deletions .bingo/hugo.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ go 1.14

require (
github.com/gobuffalo/envy v1.9.0 // indirect
// v0.55.3 This needs to match with version in netlify.toml
github.com/gohugoio/hugo v0.55.3
// v0.74.3 This needs to match with version in netlify.toml
github.com/gohugoio/hugo v0.74.3
)
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -253,13 +253,14 @@ endif
.PHONY: web-pre-process
web-pre-process:
@echo ">> running documentation website pre processing"
@bash scripts/websitepreprocess.sh
scripts/website/websitepreprocess.sh

.PHONY: web
web: ## Builds our website.
web: web-pre-process $(HUGO)
@echo ">> building documentation website"
# TODO(bwplotka): Make it --gc
@rm -rf "$(WEB_DIR)/public"
@cd $(WEB_DIR) && HUGO_ENV=production $(HUGO) --config hugo.yaml --minify -v -b $(WEBSITE_BASE_URL)

.PHONY:lint
Expand Down
2 changes: 1 addition & 1 deletion docs/contributing/how-to-contribute-to-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Then everywhere use native markdown absolute path to the project repository if y
[title](/Makefile)
```

Small [post processing script](/scripts/websitepreprocess.sh) adjusts link for Hugo rendering.
Small [post processing script](/scripts/website/websitepreprocess.sh) adjusts link for Hugo rendering.

NOTE: Spaces matters so: `[xxx]( link` and `[xxx] (link` will not work.

Expand Down
2 changes: 1 addition & 1 deletion docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ We also have example Grafana dashboards [here](/examples/dashboards/dashboards.m
* [Monzo user story](https://monzo.com/blog/2018/07/27/how-we-monitor-monzo)
* [Banzai Cloud hand's on](https://banzaicloud.com/blog/hands-on-thanos/)
* [uSwitch user story](https://medium.com/uswitch-labs/making-prometheus-more-awesome-with-thanos-fbec8c6c28ad)
* [Thanos usage](https://www.infracloud.io/thanos-ha-scalable-prometheus/)
* [Thanos usage](https://www.infracloud.io/blogs/thanos-ha-scalable-prometheus/)

## Integrations

Expand Down
2 changes: 1 addition & 1 deletion netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ publish = "website/public"

# Our Makefile builds Hugo, but it's faster if Netlify grabs the correct version on their own
# via a simple cURL.
environment = { HUGO_VERSION="0.55.3" }
environment = { HUGO_VERSION="0.74.3" }

# NOTE: the sleep at the end is to make sure logs are not truncated on error.
command = "(env && make web HUGO=$(which hugo)) || (sleep 30; false)"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,96 +1,99 @@
#!/usr/bin/env bash

if ! [[ "scripts/websitepreprocess.sh" =~ $0 ]]; then
echo "must be run from repository root"
exit 255
fi

WEBSITE_DIR="website"
ORIGINAL_CONTENT_DIR="docs"
OUTPUT_CONTENT_DIR="${WEBSITE_DIR}/docs-pre-processed"
OUTPUT_CONTENT_DIR=$1
TOP_WEIGHT=$2
COMMIT_SHA=$(git rev-parse HEAD)

rm -rf ${OUTPUT_CONTENT_DIR}
mkdir -p ${OUTPUT_CONTENT_DIR}

# Copy original content.
cp -r ${ORIGINAL_CONTENT_DIR}/* ${OUTPUT_CONTENT_DIR}

# Add edit footer to `docs/` md items.
ALL_DOC_CONTENT_FILES=$(echo "${OUTPUT_CONTENT_DIR}/**/*.md ${OUTPUT_CONTENT_DIR}/*.md")
for file in ${ALL_DOC_CONTENT_FILES}; do
relFile=${file##${OUTPUT_CONTENT_DIR}/}
echo "$(
cat <<EOT
---
Found a typo, inconsistency or missing information in our docs?
Help us to improve [Thanos](https://thanos.io) documentation by proposing a fix [on GitHub here](https://github.com/thanos-io/thanos/edit/master/docs/${relFile}) :heart:
EOT
)" >>${file}

done
echo ">> preprocessing content of dir ${OUTPUT_CONTENT_DIR}"

# Add headers to special CODE_OF_CONDUCT.md, CONTRIBUTING.md and CHANGELOG.md files.
echo "$(
cat <<EOT
cat <<EOF
---
title: Code of Conduct
type: docs
menu: contributing
---
EOT
EOF
)" >${OUTPUT_CONTENT_DIR}/CODE_OF_CONDUCT.md
cat CODE_OF_CONDUCT.md >>${OUTPUT_CONTENT_DIR}/CODE_OF_CONDUCT.md

echo "$(
cat <<EOT
cat <<EOF
---
title: Contributing
type: docs
menu: contributing
---
EOT
EOF
)" >${OUTPUT_CONTENT_DIR}/CONTRIBUTING.md
cat CONTRIBUTING.md >>${OUTPUT_CONTENT_DIR}/CONTRIBUTING.md

echo "$(
cat <<EOT
cat <<EOF
---
title: Changelog
type: docs
menu: thanos
---
EOT
EOF
)" >${OUTPUT_CONTENT_DIR}/CHANGELOG.md
cat CHANGELOG.md >>${OUTPUT_CONTENT_DIR}/CHANGELOG.md

echo "$(
cat <<EOT
cat <<EOF
---
title: Maintainers
type: docs
menu: thanos
---
EOT
EOF
)" >${OUTPUT_CONTENT_DIR}/MAINTAINERS.md
cat MAINTAINERS.md >>${OUTPUT_CONTENT_DIR}/MAINTAINERS.md

echo "$(
cat <<EOT
cat <<EOF
---
title: Security
type: docs
menu: thanos
---
EOT
EOF
)" >${OUTPUT_CONTENT_DIR}/SECURITY.md
cat SECURITY.md >>${OUTPUT_CONTENT_DIR}/SECURITY.md

# Glob again to include new docs.
ALL_DOC_CONTENT_FILES=$(echo "${OUTPUT_CONTENT_DIR}/**/*.md ${OUTPUT_CONTENT_DIR}/*.md")
# Move root things to "thanos" and "contributing" dir for easy organizing.
mkdir -p ${OUTPUT_CONTENT_DIR}/thanos/
mv ${OUTPUT_CONTENT_DIR}/*.md ${OUTPUT_CONTENT_DIR}/thanos/
mv ${OUTPUT_CONTENT_DIR}/thanos/CONTRIBUTING.md ${OUTPUT_CONTENT_DIR}/contributing/CONTRIBUTING.md
mv ${OUTPUT_CONTENT_DIR}/thanos/CODE_OF_CONDUCT.md ${OUTPUT_CONTENT_DIR}/contributing/CODE_OF_CONDUCT.md
mv ${OUTPUT_CONTENT_DIR}/thanos/community.md ${OUTPUT_CONTENT_DIR}/contributing/community.md

#Create an _index.md in all dirs to enable sorting capabilities and make "tip" appear top in version picker
echo "$(
cat <<EOF
---
weight: ${TOP_WEIGHT}
---
EOF
)" >${OUTPUT_CONTENT_DIR}/_index.md

# Add edit footer to all markdown files assumed as content.
ALL_DOC_CONTENT_FILES=$(echo "${OUTPUT_CONTENT_DIR}/**/*.md")
for file in ${ALL_DOC_CONTENT_FILES}; do
relFile=${file##${OUTPUT_CONTENT_DIR}/}
echo "$(
cat <<EOF
---
Found a typo, inconsistency or missing information in our docs?
Help us to improve [Thanos](https://thanos.io) documentation by proposing a fix [on GitHub here](https://github.com/thanos-io/thanos/edit/master/docs/${relFile}) :heart:
EOF
)" >>${file}

done

# All the absolute links are replaced with a direct link to the file on github, including the current commit SHA.
perl -pi -e 's/]\(\//]\(https:\/\/github.com\/thanos-io\/thanos\/tree\/'${COMMIT_SHA}'\//g' ${ALL_DOC_CONTENT_FILES}
Expand All @@ -99,6 +102,10 @@ perl -pi -e 's/]\(\//]\(https:\/\/github.com\/thanos-io\/thanos\/tree\/'${COMMIT
perl -pi -e 's/]\((?!http)/]\(..\//g' ${ALL_DOC_CONTENT_FILES}
# All the relative links in src= needs to have ../ as well.
perl -pi -e 's/src=\"(?!http)/src=\"..\//g' ${ALL_DOC_CONTENT_FILES}

CODING_STYLE_FILE=${OUTPUT_CONTENT_DIR}/contributing/coding-style-guide.md
# "Mask" bug in blackfriday that does not generate code snippets in tables.
perl -pi -e 's/```([a-z]+)/{{< highlight $1 >}}/g' ${OUTPUT_CONTENT_DIR}/contributing/coding-style-guide.md
perl -pi -e 's/```/{{< \/highlight >}}/g' ${OUTPUT_CONTENT_DIR}/contributing/coding-style-guide.md
if [[ -f ${CODING_STYLE_FILE} ]]; then
perl -pi -e 's/```([a-z]+)/{{< highlight $1 >}}/g' ${CODING_STYLE_FILE}
perl -pi -e 's/```/{{< \/highlight >}}/g' ${CODING_STYLE_FILE}
fi
37 changes: 37 additions & 0 deletions scripts/website/websitepreprocess.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env bash

# Regexp take from https://semver.org/
# If we want to limit those we can sort, and have only head -n X of them etc
RELEASE_FILTER_RE="release-(0|[1-9]\d*)\.(0|[1-9]\d*)$"
WEBSITE_DIR="website"
ORIGINAL_CONTENT_DIR="docs"
OUTPUT_CONTENT_DIR="${WEBSITE_DIR}/docs-pre-processed"
FILES="${WEBSITE_DIR}/docs-pre-processed/*"

git remote add upstream https://github.com/thanos-io/thanos.git
git remote add origin https://github.com/thanos-io/thanos.git
git remote -v
git fetch origin

RELEASE_BRANCHES=$(git branch --all | grep -P "remotes/origin/${RELEASE_FILTER_RE}" | egrep --invert-match '(:?HEAD|master)$' | sort -V)
echo ">> chosen $(echo ${RELEASE_BRANCHES}) releases to deploy docs from"

rm -rf ${OUTPUT_CONTENT_DIR}
mkdir -p "${OUTPUT_CONTENT_DIR}/tip"

# Copy original content from current state first.
cp -r ${ORIGINAL_CONTENT_DIR}/* "${OUTPUT_CONTENT_DIR}/tip"
scripts/website/contentpreprocess.sh "${OUTPUT_CONTENT_DIR}/tip" 100000

#create variable for weight value
WEIGHT_VALUE=0

for branchRef in ${RELEASE_BRANCHES}; do
WEIGHT_VALUE=$((WEIGHT_VALUE + 1))
branchName=${branchRef##*/}
tags=${branchName/release-/v}
echo ">> cloning docs for versioning ${tags}"
mkdir -p "${OUTPUT_CONTENT_DIR}/${tags}"
git archive --format=tar "refs/${branchRef}" | tar -C${OUTPUT_CONTENT_DIR}/${tags} -x "docs/" --strip-components=1
scripts/website/contentpreprocess.sh "${OUTPUT_CONTENT_DIR}/${tags}" ${WEIGHT_VALUE}
done
2 changes: 1 addition & 1 deletion website/hugo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ params:
DockerHubUser: "thanosio"
DockerHubRepository: "thanos"
TwitterHandle: "ThanosMetrics"
Description: "Highly available Prometheus setup with long term storage capabilities."
Description: "Highly available Prometheus setup with long term storage capabilities."
26 changes: 14 additions & 12 deletions website/layouts/_default/baseof.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,18 @@
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<!-- disable searchbox until we fix -->
<!-- <li class="nav-item">
<div class="searchBox">
<input type="search" name="" id="searchInput" placeholder="Search">
<button type="submit" class="searchbtn"><i class="fas fa-search"></i></button>
</div>
</li>
</li> -->
<li class="nav-item">
<a class="nav-link" href="{{ "/getting-started.md" | relURL }}">Documentation</a>
<a class="nav-link" href="https://github.com/{{ .Site.Params.GithubUser }}/{{ .Site.Params.GithubProject }}/releases">Download</a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://github.com/{{ .Site.Params.GithubUser }}/{{ .Site.Params.GithubProject }}/releases">Download</a>
{{ partial "versioning/version-picker.html" . }}
</li>
<li class="nav-item">
<a href="https://github.com/{{ .Site.Params.GithubUser }}/{{ .Site.Params.GithubProject }}" class="nav-link"><i class="fab fa-fw fa-github"></i> GitHub</a>
Expand All @@ -68,12 +69,12 @@
<div class="col-12 col-md-6 col-lg">
<h6 class="font-weight-bold">Documentation</h6>
<ul class="list-unstyled">
<li><a class="text-reset" href="{{ "/getting-started.md" | relURL }}">Getting Started</a></li>
<li><a class="text-reset" href="{{ "/design.md" | relURL }}">Design</a></li>
<li><a class="text-reset" href="{{ "/storage.md" | relURL }}">Storage</a></li>
<li><a class="text-reset" href="{{ "/service-discovery.md" | relURL }}">Service Discovery</a></li>
<li><a class="text-reset" href="{{ "/maintainers" | relURL }}">Maintainers</a></li>
<li><a class="text-reset" href="{{ "/contributing" | relURL }}">Contributing</a></li>
<li><a class="text-reset" href="{{ "/tip/thanos/getting-started.md" | relURL }}">Getting Started</a></li>
<li><a class="text-reset" href="{{ "/tip/thanos/design.md" | relURL }}">Design</a></li>
<li><a class="text-reset" href="{{ "/tip/thanos/storage.md" | relURL }}">Storage</a></li>
<li><a class="text-reset" href="{{ "/tip/thanos/service-discovery.md" | relURL }}">Service Discovery</a></li>
<li><a class="text-reset" href="{{ "/tip/thanos/maintainers" | relURL }}">Maintainers</a></li>
<li><a class="text-reset" href="{{ "/tip/contributing/contributing" | relURL }}">Contributing</a></li>
</ul>
</div>
<div class="col-12 col-md-6 col-lg">
Expand Down Expand Up @@ -111,14 +112,15 @@ <h6 class="font-weight-bold">About</h6>
{{ template "_internal/google_analytics_async.html" . }}
{{ end }}

<script nonce="93HDK8392dfjh4Gb" type="text/javascript" src="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js"></script>
<!-- Disable search for now until we fix search to understand new dir structure -->
<!-- <script nonce="93HDK8392dfjh4Gb" type="text/javascript" src="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js"></script>
<script nonce="93HDK8392dfjh4Gb" type="text/javascript"> docsearch({
apiKey: '649aaeb84811844d97cb5aa0398b94d9',
indexName: 'thanos',
inputSelector: '#searchInput',
debug: false // Set debug to true if you want to inspect the dropdown
});
</script>
</script> -->
</body>

</html>
1 change: 1 addition & 0 deletions website/layouts/_default/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
{{ partial "_default/sidemenu.html" . }}
</div>
<div class="col-12 col-lg-9">
{{ partial "versioning/banner.html" . }}
{{ if or (eq .Params.toc true) (and (gt .WordCount 400) (ne .Params.toc false)) }}
<h1>Table of Content</h1>
{{ .TableOfContents }}
Expand Down
10 changes: 5 additions & 5 deletions website/layouts/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
<h3 class="mb-3">Open source, highly available Prometheus setup with long term storage capabilities.</h3>
<ul class="list-inline mb-0">
<li class="list-inline-item my-3">
<a href="{{ "getting-started.md" | relURL }}" class="btn btn-outline-secondary">
<a href="{{ "/tip/thanos/getting-started.md" | relURL }}" class="btn btn-outline-secondary">
<i class="fas fa-fw fa-book"></i> Getting Started
</a>
</li>
<li class="list-inline-item my-3">
<a href="{{ "community.md" | relURL }}" class="btn btn-outline-secondary">
<a href="{{ "/tip/contributing/community.md" | relURL }}" class="btn btn-outline-secondary">
<i class="fas fa-fw fa-comments"></i> Community
</a>
</li>
Expand Down Expand Up @@ -89,7 +89,7 @@ <h2 class="heading-big text-center">Used By</h2>
{{ end }}
<div class="col-6 col-sm-6 col-md-3">
<div class="img-adopter">
<a class="text-center text-muted" href="{{ "contributing/how-to-contribute-to-docs.md#adopters-logos" | relURL }}">Your Company</a>
<a class="text-center text-muted" href="{{ "/tip/contributing/how-to-contribute-to-docs.md#adopters-logos" | relURL }}">Your Company</a>
</div>
</div>
</div>
Expand All @@ -107,11 +107,11 @@ <h2 class="heading-big text-center">Used By</h2>
<div class="container-fluid bg-light">
<div class="row py-5">
<div class="col text-center">
<h3 class="color-purple"><a href="{{ "community.md" | relURL }}">Join the community !</a></h3>
<h3 class="color-purple"><a href="{{ "/tip/contributing/community.md" | relURL }}">Join the community !</a></h3>
<p>Join users and companies that are using Thanos in production.</p>
<ul class="list-inline">
<li class="list-inline-item">
<a href="{{ "community.md" | relURL }}" class="btn btn-outline-secondary">
<a href="{{ "/tip/contributing/community.md" | relURL }}" class="btn btn-outline-secondary">
<i class="fas fa-fw fa-comments"></i> Community Meetings
</a>
</li>
Expand Down
Loading

0 comments on commit 0b8507c

Please sign in to comment.