2016-08-11 02:07:00 +00:00
#!/bin/bash
2017-04-19 21:35:10 +00:00
set -o errexit
2016-08-11 02:07:00 +00:00
2016-08-12 16:58:15 +00:00
# Uncomment this to see the commands as they are run
# set -x
2016-08-11 02:07:00 +00:00
2017-06-27 23:34:04 +00:00
VERSION = 1.7
OLDVERSION = 1.6
2016-08-11 02:07:00 +00:00
2016-09-15 01:24:18 +00:00
# Processes api reference docs.
function process_api_ref_docs {
# Replace html preview links by relative links to let k8s.io render them.
local html_preview_prefix = "https:\/\/htmlpreview.github.io\/?https:\/\/github.com\/kubernetes\/kubernetes\/blob\/"
find . -name '*.*' -type f -exec sed -i -e " s/ ${ html_preview_prefix } HEAD//g " { } \;
find . -name '*.*' -type f -exec sed -i -e " s/ ${ html_preview_prefix } release- $VERSION //g " { } \;
# Format html
find . -name '*.html' -type f -exec sed -i -e '/<style>/,/<\/style>/d' { } \;
find . -name '*.html' -type f -exec sed -i -e " s/http:\/\/kubernetes.io\/v $VERSION //g " { } \;
find . -name '*.html' -type f -exec sed -i -e ' 1 i\
---' { } \;
find . -name '*.html' -type f -exec sed -i -e ' 1 i\
---' { } \;
# Strip the munge comments
find . -name '*.md' -type f -exec sed -i -e '/<!-- BEGIN MUNGE: IS_VERSIONED -->/,/<!-- END MUNGE: IS_VERSIONED -->/d' { } \;
find . -name '*.md' -type f -exec sed -i -e '/<!-- BEGIN MUNGE: UNVERSIONED_WARNING -->/,/<!-- END MUNGE: UNVERSIONED_WARNING -->/d' { } \;
# Add the expected headers to md files
find . -name '*.md' -type f -exec sed -i -e ' 1 i\
---' { } \;
find . -name '*.md' -type f -exec sed -i -e ' 1 i\
---' { } \;
}
2017-03-22 17:10:36 +00:00
# save old version new style reference docs
APIREFPATH = docs/api-reference
KUBECTLPATH = docs/user-guide/kubectl
TMPDIR = /tmp/update_docs
2017-04-19 21:35:10 +00:00
TMPAPIREFDIR = " ${ TMPDIR } /api_ref "
TMPKUBECTLDIR = " ${ TMPDIR } /kubectl "
rm -rf -- " ${ TMPDIR } "
mkdir -p -- " ${ TMPAPIREFDIR } " " ${ TMPKUBECTLDIR } "
APIREFSRCDIR = " ${ APIREFPATH } /v ${ OLDVERSION } "
APIREFDESDIR = " ${ TMPAPIREFDIR } /v ${ OLDVERSION } "
mv -- " ${ APIREFSRCDIR } " " ${ APIREFDESDIR } "
KUBECTLSRCDIR = " ${ KUBECTLPATH } /v ${ OLDVERSION } "
KUBECTLDESDIR = " ${ TMPKUBECTLDIR } /v ${ OLDVERSION } "
mv -- " ${ KUBECTLSRCDIR } " " ${ KUBECTLDESDIR } "
K8SREPO = k8s
(
git clone --depth= 1 -b release-$VERSION https://github.com/kubernetes/kubernetes.git " ${ K8SREPO } "
cd " ${ K8SREPO } "
hack/generate-docs.sh
)
rm -rf " _includes/v $VERSION "
mkdir " _includes/v $VERSION "
2016-03-07 16:51:25 +00:00
2016-03-02 03:43:10 +00:00
# batch fetches
2016-02-14 22:08:16 +00:00
while read line || [ [ -n ${ line } ] ] ; do
2016-02-26 12:31:34 +00:00
IFS = ': ' read -a myarray <<< " ${ line } "
2016-08-12 16:58:15 +00:00
if [ " ${ myarray [1] } " = "path" ] ; then
2016-02-26 12:31:34 +00:00
TARGET = " ${ myarray [2] } "
CLEARPATH = " ${ TARGET } "
2017-04-19 21:35:10 +00:00
K8SSOURCE = " ${ K8SREPO } / ${ TARGET } "
2016-02-26 12:31:34 +00:00
DESTINATION = ${ TARGET %/* }
2017-04-19 21:35:10 +00:00
rm -rf -- " ${ CLEARPATH } "
yes | cp -rf -- " ${ K8SSOURCE } " " ${ DESTINATION } "
2016-08-12 16:58:15 +00:00
fi
2016-03-07 16:51:25 +00:00
if [ " ${ myarray [1] } " = "changedpath" ] ; then
SRC = " ${ myarray [2] } "
DESTINATION = " ${ myarray [3] } "
2017-04-19 21:35:10 +00:00
echo " cp -rf -- ${ SRC } ${ DESTINATION } "
yes | cp -rf -- " ${ SRC } " " ${ DESTINATION } "
2016-03-07 16:51:25 +00:00
fi
if [ " ${ myarray [1] } " = "copypath" ] ; then
K8SSOURCE = " ${ myarray [2] } "
DESTINATION = " ${ myarray [3] } "
2017-04-19 21:35:10 +00:00
echo " yes | cp -rf -- ${ K8SSOURCE } ${ DESTINATION } "
yes | cp -rf -- " ${ K8SSOURCE } " " ${ DESTINATION } "
2016-02-26 12:31:34 +00:00
fi
2016-02-26 11:54:48 +00:00
done <_data/overrides.yml
2016-02-14 22:08:16 +00:00
2016-03-07 16:51:25 +00:00
# refdoc munging
2017-04-19 21:35:10 +00:00
(
cd _includes/v$VERSION
2016-08-12 16:58:15 +00:00
# These are included in other files, so strip the DOCTYPE
find . -name '*.html' -type f -exec sed -i -e "s/<!DOCTYPE html>//g" { } \;
# Format html
find . -name '*.html' -type f -exec sed -i -e '/<style>/,/<\/style>/d' { } \;
find . -name '*.html' -type f -exec sed -i -e " s/http:\/\/kubernetes.io\/v $VERSION //g " { } \;
2017-04-19 21:35:10 +00:00
)
2016-08-12 16:58:15 +00:00
2017-04-19 21:35:10 +00:00
(
cd docs/api-reference
2016-09-15 01:24:18 +00:00
process_api_ref_docs
2016-08-12 16:58:15 +00:00
# Fix for bug in 1.3 release
find . -name '*.md' -type f -exec sed -i -e "s/vv1.3.0-beta.0/v1.3/g" { } \;
2017-04-19 21:35:10 +00:00
)
2016-08-12 16:58:15 +00:00
2017-04-19 21:35:10 +00:00
(
cd docs/federation/api-reference
2016-09-15 01:24:18 +00:00
process_api_ref_docs
2017-03-22 17:10:36 +00:00
# Rename README.md to index.md
mv README.md index.md
2016-09-15 01:24:18 +00:00
# Update the links from federation/docs/api-reference to
# docs/federation/api-reference
find . -name '*.*' -type f -exec sed -i -e "s/federation\/docs\/api-reference/docs\/federation\/api-reference/g" { } \;
2017-04-19 21:35:10 +00:00
)
2016-09-15 01:24:18 +00:00
2017-04-19 21:35:10 +00:00
(
cd docs/user-guide/kubectl
2016-08-12 16:58:15 +00:00
# Strip the munge comments
find . -name '*.md' -type f -exec sed -i -e '/<!-- BEGIN MUNGE: IS_VERSIONED -->/,/<!-- END MUNGE: IS_VERSIONED -->/d' { } \;
find . -name '*.md' -type f -exec sed -i -e '/<!-- BEGIN MUNGE: UNVERSIONED_WARNING -->/,/<!-- END MUNGE: UNVERSIONED_WARNING -->/d' { } \;
2017-03-22 17:10:36 +00:00
# Strip the "See Also" links.
2016-09-28 21:46:40 +00:00
# These links in raw .md files are relative to current file location, but the website see them as relative to current url instead, and will return 404.
2017-03-22 17:10:36 +00:00
find . -name 'kubectl*.md' -type f -exec sed -i -e '/### SEE ALSO/d' { } \;
find . -name 'kubectl*.md' -type f -exec sed -i -e '/\* \[kubectl/d' { } \;
2016-09-28 21:46:40 +00:00
2017-04-19 21:35:10 +00:00
# Add the expected headers to md files
2016-08-12 16:58:15 +00:00
find . -name '*.md' -type f -exec sed -i -e ' 1 i\
---' { } \;
find . -name '*.md' -type f -exec sed -i -e ' 1 i\
---' { } \;
2017-04-19 21:35:10 +00:00
)
2016-08-12 16:58:15 +00:00
BINARIES = "federation-apiserver.md federation-controller-manager.md kube-apiserver.md kube-controller-manager.md kube-proxy.md kube-scheduler.md kubelet.md"
2017-04-19 21:35:10 +00:00
(
cd docs/admin
2016-08-12 16:58:15 +00:00
for bin in $BINARIES ; do
2017-04-19 21:35:10 +00:00
sed -i -e '/<!-- BEGIN MUNGE: IS_VERSIONED -->/,/<!-- END MUNGE: IS_VERSIONED -->/d' " $bin "
2017-06-08 05:56:21 +00:00
sed -i -e '/<!-- BEGIN MUNGE: UNVERSIONED_WARNING -->/,/<!-- END MUNGE: UNVERSIONED_WARNING -->/d' " $bin "
2017-04-19 21:35:10 +00:00
sed -i -e ' 1 i\
---' " $bin "
sed -i -e ' 1 i\
---' " $bin "
2016-08-12 16:58:15 +00:00
done
2017-04-19 21:35:10 +00:00
)
mv -- " ${ APIREFDESDIR } " " ${ APIREFSRCDIR } "
mv -- " ${ KUBECTLDESDIR } " " ${ KUBECTLSRCDIR } "
rm -rf -- " ${ TMPDIR } " " ${ K8SREPO } "
2017-03-22 17:10:36 +00:00
2016-08-12 16:58:15 +00:00
echo "Docs imported! Run 'git add .' 'git commit -m <comment>' and 'git push' to upload them"