Browse code

Moved documentation generation functions from common.sh

There is no reason to believe any script other than the generated-docs
scripts will ever use these functions, so we should not hold them in
our library.

Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>

Steve Kuznetsov authored on 2016/11/08 01:28:47
Showing 2 changed files
... ...
@@ -994,84 +994,6 @@ function os::build::gen-completions() {
994 994
 }
995 995
 readonly -f os::build::gen-completions
996 996
 
997
-function os::build::gen-man() {
998
-  local cmd="$1"
999
-  local dest="$2"
1000
-  local cmdName="$3"
1001
-  local filestore=".files_generated_$3"
1002
-  local skipprefix="${4:-}"
1003
-
1004
-  # We do this in a tmpdir in case the dest has other non-autogenned files
1005
-  # We don't want to include them in the list of gen'd files
1006
-  local tmpdir="${OS_ROOT}/_tmp/gen_man"
1007
-  mkdir -p "${tmpdir}"
1008
-  # generate the new files
1009
-  ${cmd} "${tmpdir}" "${cmdName}"
1010
-  # create the list of generated files
1011
-  ls "${tmpdir}" | LC_ALL=C sort > "${tmpdir}/${filestore}"
1012
-
1013
-  # remove all old generated file from the destination
1014
-  while read file; do
1015
-    if [[ -e "${tmpdir}/${file}" && -n "${skipprefix}" ]]; then
1016
-      local original generated
1017
-      original=$(grep -v "^${skipprefix}" "${dest}/${file}") || :
1018
-      generated=$(grep -v "^${skipprefix}" "${tmpdir}/${file}") || :
1019
-      if [[ "${original}" == "${generated}" ]]; then
1020
-        # overwrite generated with original.
1021
-        mv "${dest}/${file}" "${tmpdir}/${file}"
1022
-      fi
1023
-    else
1024
-      rm "${dest}/${file}" || true
1025
-    fi
1026
-  done <"${dest}/${filestore}"
1027
-
1028
-  # put the new generated file into the destination
1029
-  find "${tmpdir}" -exec rsync -pt {} "${dest}" \; >/dev/null
1030
-  #cleanup
1031
-  rm -rf "${tmpdir}"
1032
-
1033
-  echo "Assets generated in ${dest}"
1034
-}
1035
-readonly -f os::build::gen-man
1036
-
1037
-function os::build::gen-docs() {
1038
-  local cmd="$1"
1039
-  local dest="$2"
1040
-  local skipprefix="${3:-}"
1041
-
1042
-  # We do this in a tmpdir in case the dest has other non-autogenned files
1043
-  # We don't want to include them in the list of gen'd files
1044
-  local tmpdir="${OS_ROOT}/_tmp/gen_doc"
1045
-  mkdir -p "${tmpdir}"
1046
-  # generate the new files
1047
-  ${cmd} "${tmpdir}"
1048
-  # create the list of generated files
1049
-  ls "${tmpdir}" | LC_ALL=C sort > "${tmpdir}/.files_generated"
1050
-
1051
-  # remove all old generated file from the destination
1052
-  while read file; do
1053
-    if [[ -e "${tmpdir}/${file}" && -n "${skipprefix}" ]]; then
1054
-      local original generated
1055
-      original=$(grep -v "^${skipprefix}" "${dest}/${file}") || :
1056
-      generated=$(grep -v "^${skipprefix}" "${tmpdir}/${file}") || :
1057
-      if [[ "${original}" == "${generated}" ]]; then
1058
-        # overwrite generated with original.
1059
-        mv "${dest}/${file}" "${tmpdir}/${file}"
1060
-      fi
1061
-    else
1062
-      rm "${dest}/${file}" || true
1063
-    fi
1064
-  done <"${dest}/.files_generated"
1065
-
1066
-  # put the new generated file into the destination
1067
-  find "${tmpdir}" -exec rsync -pt {} "${dest}" \; >/dev/null
1068
-  #cleanup
1069
-  rm -rf "${tmpdir}"
1070
-
1071
-  echo "Assets generated in ${dest}"
1072
-}
1073
-readonly -f os::build::gen-docs
1074
-
1075 997
 function os::build::get-bin-output-path() {
1076 998
   local os_root="${1:-}"
1077 999
 
... ...
@@ -14,6 +14,84 @@ MAN_OUTPUT_DIR="${OS_ROOT}/${OUTPUT_DIR_REL}/docs/man/man1"
14 14
 mkdir -p "${OUTPUT_DIR}" || echo $? > /dev/null
15 15
 mkdir -p "${MAN_OUTPUT_DIR}" || echo $? > /dev/null
16 16
 
17
+function os::build::gen-man() {
18
+  local cmd="$1"
19
+  local dest="$2"
20
+  local cmdName="$3"
21
+  local filestore=".files_generated_$3"
22
+  local skipprefix="${4:-}"
23
+
24
+  # We do this in a tmpdir in case the dest has other non-autogenned files
25
+  # We don't want to include them in the list of gen'd files
26
+  local tmpdir="${OS_ROOT}/_tmp/gen_man"
27
+  mkdir -p "${tmpdir}"
28
+  # generate the new files
29
+  ${cmd} "${tmpdir}" "${cmdName}"
30
+  # create the list of generated files
31
+  ls "${tmpdir}" | LC_ALL=C sort > "${tmpdir}/${filestore}"
32
+
33
+  # remove all old generated file from the destination
34
+  while read file; do
35
+    if [[ -e "${tmpdir}/${file}" && -n "${skipprefix}" ]]; then
36
+      local original generated
37
+      original=$(grep -v "^${skipprefix}" "${dest}/${file}") || :
38
+      generated=$(grep -v "^${skipprefix}" "${tmpdir}/${file}") || :
39
+      if [[ "${original}" == "${generated}" ]]; then
40
+        # overwrite generated with original.
41
+        mv "${dest}/${file}" "${tmpdir}/${file}"
42
+      fi
43
+    else
44
+      rm "${dest}/${file}" || true
45
+    fi
46
+  done <"${dest}/${filestore}"
47
+
48
+  # put the new generated file into the destination
49
+  find "${tmpdir}" -exec rsync -pt {} "${dest}" \; >/dev/null
50
+  #cleanup
51
+  rm -rf "${tmpdir}"
52
+
53
+  echo "Assets generated in ${dest}"
54
+}
55
+readonly -f os::build::gen-man
56
+
57
+function os::build::gen-docs() {
58
+  local cmd="$1"
59
+  local dest="$2"
60
+  local skipprefix="${3:-}"
61
+
62
+  # We do this in a tmpdir in case the dest has other non-autogenned files
63
+  # We don't want to include them in the list of gen'd files
64
+  local tmpdir="${OS_ROOT}/_tmp/gen_doc"
65
+  mkdir -p "${tmpdir}"
66
+  # generate the new files
67
+  ${cmd} "${tmpdir}"
68
+  # create the list of generated files
69
+  ls "${tmpdir}" | LC_ALL=C sort > "${tmpdir}/.files_generated"
70
+
71
+  # remove all old generated file from the destination
72
+  while read file; do
73
+    if [[ -e "${tmpdir}/${file}" && -n "${skipprefix}" ]]; then
74
+      local original generated
75
+      original=$(grep -v "^${skipprefix}" "${dest}/${file}") || :
76
+      generated=$(grep -v "^${skipprefix}" "${tmpdir}/${file}") || :
77
+      if [[ "${original}" == "${generated}" ]]; then
78
+        # overwrite generated with original.
79
+        mv "${dest}/${file}" "${tmpdir}/${file}"
80
+      fi
81
+    else
82
+      rm "${dest}/${file}" || true
83
+    fi
84
+  done <"${dest}/.files_generated"
85
+
86
+  # put the new generated file into the destination
87
+  find "${tmpdir}" -exec rsync -pt {} "${dest}" \; >/dev/null
88
+  #cleanup
89
+  rm -rf "${tmpdir}"
90
+
91
+  echo "Assets generated in ${dest}"
92
+}
93
+readonly -f os::build::gen-docs
94
+
17 95
 os::build::gen-docs "${gendocs}" "${OUTPUT_DIR}"
18 96
 os::build::gen-man "${genman}" "${MAN_OUTPUT_DIR}" "oc"
19 97
 os::build::gen-man "${genman}" "${MAN_OUTPUT_DIR}" "openshift"