@@ -9,7 +9,7 @@ remote_name=${1:-origin}
99# target branch where changes will be applied (master, rel/0.7, ...)
1010target_branch=${2:- master}
1111# Number of the versions to persist. Older ones are accesible only from GitHub.
12- num_versions=${4 :- 4}
12+ num_versions=${3 :- 4}
1313
1414echo " Validating target branch '$target_branch '"
1515case " $target_branch " in
4242
4343git fetch " $remote_name "
4444
45+
4546latest_branches=()
4647# Get all relevant rel/* branches, sort them, and pick the latest num_versions
4748while IFS= read -r vers; do
4849 latest_branches+=(" $remote_name /rel/$vers " )
4950done < <( git branch -rl " $remote_name /rel/*" | sed ' s|.*/rel/||' | sort -t. -k1,1n -k2,2n | tail -n" $num_versions " )
5051
5152# Add special branches to the array (only rel/dev and master for now)
52- special_branches=(" $remote_name /rel/dev" )
53+ special_branches=(" $remote_name /rel/dev" " $remote_name /master " )
5354
5455branches_to_process=(" ${latest_branches[@]} " " ${special_branches[@]} " )
5556
@@ -63,9 +64,17 @@ for branch in "${branches_to_process[@]}" ; do
6364 target_section=${branch# " $remote_name " / }
6465 target_section=${target_section# rel/ }
6566 target_section=${target_section% .* }
66- # number of path segments to throw away by tar: content/en/x.y => 3
67- strip_count=3
68- src_section=docs
67+ if [ " $target_section " == " master" ] ; then
68+ # handle master branch specially, all contents is copied, not just docs
69+ target_section=" "
70+ # number of path segments to throw away by tar: content/en => 2
71+ strip_count=2
72+ src_section=" "
73+ else
74+ # number of path segments to throw away by tar: content/en/x.y => 3
75+ strip_count=3
76+ src_section=docs
77+ fi
6978 if [ " $target_section " == " $current_section " ] ; then
7079 # copy the current docs to proper section
7180 echo " Getting data from workdir for $branch "
@@ -81,15 +90,19 @@ for branch in "${branches_to_process[@]}" ; do
8190 if git cat-file -e $API_GEN_FILE ; then
8291 echo " $API_GEN_FILE exists."
8392 echo " Generating API ref..."
84- if git ls-tree --name-only " $branch " | grep -q " ^api_spec.toml$ " ; then
85- git checkout " $branch " -- api_spec.toml
93+ if [ " $target_section " == " " ] ; then
94+ echo " Skipping master api ref "
8695 else
87- echo " removing the API_spec"
88- rm -rf api_spec.toml
96+ if git ls-tree --name-only " $branch " | grep -q " ^api_spec.toml$" ; then
97+ git checkout " $branch " -- api_spec.toml
98+ else
99+ echo " removing the API_spec"
100+ rm -rf api_spec.toml
101+ fi
102+ python3 ../scripts/docs/json_builder.py
103+ mv -f data.json ./versioned_docs/" $target_section " /
104+ python3 ../scripts/docs/python_ref_builder.py api_spec.toml ./versioned_docs/" $target_section " /data.json " $target_section " versioned_docs
89105 fi
90- python3 ../scripts/docs/json_builder.py
91- mv -f data.json ./versioned_docs/" $target_section " /
92- python3 ../scripts/docs/python_ref_builder.py api_spec.toml ./versioned_docs/" $target_section " /data.json " $target_section " versioned_docs
93106 fi
94107done
95108
@@ -104,4 +117,6 @@ sed "s|${highest_version}|latest|g" ./versioned_docs/latest/links.json > temp.js
104117
105118mv temp.json ./versioned_docs/latest/links.json
106119
120+ echo " master docs will not be published, removing"
121+ rm -rf " ${content_dir} /docs"
107122popd
0 commit comments