Browse Source

Switch to translated docs build by openstackdocstheme

Change-Id: Ic10b4bfa469ac11e278bd0ecd8088418d61c4fd5
changes/29/623329/4
Frank Kloeker 6 months ago
parent
commit
f91deab8fe
6 changed files with 11 additions and 215 deletions
  1. 1
    1
      lower-constraints.txt
  2. 4
    4
      requirements.txt
  3. 4
    4
      test-requirements.txt
  4. 0
    178
      tools/build-docs.sh
  5. 0
    24
      tools/get-lang-display-name.py
  6. 2
    4
      tox.ini

+ 1
- 1
lower-constraints.txt View File

@@ -20,7 +20,7 @@ monotonic==1.4
20 20
 msgpack==0.5.6
21 21
 netaddr==0.7.19
22 22
 netifaces==0.10.6
23
-openstackdocstheme==1.20.0
23
+openstackdocstheme==1.28
24 24
 oslo.config==5.2.0
25 25
 oslo.context==2.20.0
26 26
 oslo.i18n==3.20.0

+ 4
- 4
requirements.txt View File

@@ -2,8 +2,8 @@
2 2
 # of appearance. Changing the order has an impact on the overall integration
3 3
 # process, which may cause wedges in the gate later.
4 4
 beautifulsoup4>=4.6.0 # MIT
5
-lxml!=3.7.0,>=3.4.1 # BSD
6
-oslo.log>=3.36.0 # Apache-2.0
7
-requests>=2.14.2 # Apache-2.0
8
-six>=1.10.0 # MIT
5
+lxml!=3.7.0,>=4.1.1 # BSD
6
+oslo.log>=3.37.0 # Apache-2.0
7
+requests>=2.18.4 # Apache-2.0
8
+six>=1.11.0 # MIT
9 9
 PyYAML>=3.12 # MIT

+ 4
- 4
test-requirements.txt View File

@@ -4,7 +4,7 @@
4 4
 
5 5
 hacking<0.11,>=0.10.2 # Apache-2.0
6 6
 
7
-Babel!=2.4.0,>=2.3.4 # BSD
8
-sphinx!=1.6.6,!=1.6.7,>=1.6.2 # BSD
9
-openstackdocstheme>=1.18.1 # Apache-2.0
10
-doc8>=0.6.0 # Apache-2.0
7
+Babel!=2.4.0,>=2.5.3 # BSD
8
+sphinx!=1.6.6,!=1.6.7,>=1.6.5 # BSD
9
+openstackdocstheme>=1.28 # Apache-2.0
10
+doc8>=0.8.0 # Apache-2.0

+ 0
- 178
tools/build-docs.sh View File

@@ -1,178 +0,0 @@
1
-#!/bin/bash
2
-
3
-#
4
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
5
-# not use this file except in compliance with the License. You may obtain
6
-# a copy of the License at
7
-#
8
-#      http://www.apache.org/licenses/LICENSE-2.0
9
-#
10
-# Unless required by applicable law or agreed to in writing, software
11
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
-# License for the specific language governing permissions and limitations
14
-# under the License.
15
-
16
-# Build English and translated version of the I18n guide.
17
-
18
-set -e
19
-set -x
20
-
21
-DOCNAME=doc
22
-DIRECTORY=doc
23
-
24
-# build i18n contributor guide page
25
-sphinx-build -a -W -b html \
26
-    -d ${DIRECTORY}/build/doctrees \
27
-    ${DIRECTORY}/source ${DIRECTORY}/build/html/
28
-
29
-if [ "${NO_LANG_BUILD:-0}" = "1" ]; then
30
-    exit 0
31
-fi
32
-
33
-# This function sets the following global variables
34
-# - LANG_INDEX : filename which contains the language index
35
-# - HAS_LANG : 1 (there are languages other than English), 0 (English only)
36
-function prepare_language_index {
37
-    # Global variables
38
-    HAS_LANG=0
39
-    LANG_INDEX=`mktemp`
40
-    trap "rm -f -- $LANG_INDEX" EXIT
41
-
42
-    cat <<EOF >> $LANG_INDEX
43
-[
44
-\`English <__BASE__/__INDEX__>\`__
45
-EOF
46
-
47
-    # Generate language index file
48
-    for locale in `find ${DIRECTORY}/source/locale/ -maxdepth 1 -type d` ; do
49
-        # skip if it is not a valid language translation resource.
50
-        if [ ! -e ${locale}/LC_MESSAGES/${DOCNAME}.po ]; then
51
-            continue
52
-        fi
53
-        language=$(basename $locale)
54
-
55
-        # Reference translated document from index file
56
-        echo -n "| " >> $LANG_INDEX
57
-        HAS_LANG=1
58
-        get_lang_name_prog=$(dirname $0)/get-lang-display-name.py
59
-        name=`python3 $get_lang_name_prog $language`
60
-        echo "\`$name <__BASE__/${language}/__INDEX__>\`__" >> $LANG_INDEX
61
-    done
62
-
63
-    cat <<EOF >> $LANG_INDEX
64
-]
65
-
66
-EOF
67
-}
68
-
69
-function _add_language_index {
70
-    local target_file=$1
71
-    local basepath=$2
72
-
73
-    local basename
74
-    basename=$(echo $target_file | sed -e "s|$DIRECTORY/source/||" -e "s|\.rst$||")
75
-    path_to_top_level=$(dirname $basename | sed -e 's|[^./]\+|..|g')
76
-
77
-    local _basepath
78
-    if [ "$basepath" = "." -a "$path_to_top_level" = "." ]; then
79
-        _basepath="."
80
-    elif [ "$basepath" = "." ]; then
81
-        _basepath=$path_to_top_level
82
-    elif [ "$path_to_top_level" = "." ]; then
83
-        _basepath=$basepath
84
-    else
85
-        _basepath="$basepath/$path_to_top_level"
86
-    fi
87
-
88
-    cp -p $target_file $target_file.backup
89
-    sed -e "s|__BASE__|$_basepath|" -e "s|__INDEX__|$basename.html|" $LANG_INDEX > $target_file
90
-    cat $target_file.backup >> $target_file
91
-}
92
-
93
-function add_language_index_to_localized {
94
-    for f in `find $DIRECTORY/source -name '*.rst'`; do
95
-        _add_language_index $f ..
96
-    done
97
-}
98
-
99
-function add_language_index_to_original {
100
-    for f in `find $DIRECTORY/source -name '*.rst'`; do
101
-        cp -p $f.backup $f
102
-        _add_language_index $REFERENCES $f .
103
-    done
104
-}
105
-
106
-function recover_rst_files {
107
-    for f in `find $DIRECTORY/source -name '*.rst'`; do
108
-        mv $f.backup $f
109
-    done
110
-}
111
-
112
-sphinx-build -a -W -b gettext \
113
-    -d ${DIRECTORY}/build/doctrees.gettext \
114
-    ${DIRECTORY}/source ${DIRECTORY}/source/locale/
115
-
116
-prepare_language_index
117
-if [ "$HAS_LANG" = "0" ]; then
118
-    exit 0
119
-fi
120
-# Now add our references to the beginning of the index file. We cannot do this
121
-# earlier since the sphinx commands will read this file.
122
-# Ensure to revert any changes to the index file.
123
-add_language_index_to_localized
124
-
125
-# check all language translation resource
126
-for locale in `find ${DIRECTORY}/source/locale/ -maxdepth 1 -type d` ; do
127
-    # skip if it is not a valid language translation resource.
128
-    if [ ! -e ${locale}/LC_MESSAGES/${DOCNAME}.po ]; then
129
-        continue
130
-    fi
131
-    language=$(basename $locale)
132
-
133
-    echo "===== Building $language translation ====="
134
-
135
-    # prepare all translation resources
136
-    for pot in ${DIRECTORY}/source/locale/*.pot ; do
137
-        # get filename
138
-        potname=$(basename $pot)
139
-        resname=${potname%.pot}
140
-        echo $resname
141
-        # merge all translation resources
142
-        msgmerge --silent -o \
143
-            ${DIRECTORY}/source/locale/${language}/LC_MESSAGES/${resname}.po \
144
-            ${DIRECTORY}/source/locale/${language}/LC_MESSAGES/${DOCNAME}.po \
145
-            ${DIRECTORY}/source/locale/${potname}
146
-        # compile all translation resources
147
-        msgfmt -o \
148
-            ${DIRECTORY}/source/locale/${language}/LC_MESSAGES/${resname}.mo \
149
-            ${DIRECTORY}/source/locale/${language}/LC_MESSAGES/${resname}.po
150
-    done
151
-
152
-    # build translated guide
153
-    # build i18n contributor guide page
154
-    # TODO(amotoki): Enable -W option in translated version
155
-    sphinx-build -a -b html -D language=${language} \
156
-        -d ${DIRECTORY}/build/doctrees.languages/${language} \
157
-        ${DIRECTORY}/source ${DIRECTORY}/build/html/${language}
158
-
159
-    # remove newly created files
160
-    git clean -f -q ${DIRECTORY}/source/locale/${language}/LC_MESSAGES/*.po
161
-    git clean -f -x -q ${DIRECTORY}/source/locale/${language}/LC_MESSAGES/*.mo
162
-    git clean -f -x -q ${DIRECTORY}/source/locale/.doctrees
163
-    # revert changes to po file
164
-    git reset -q ${DIRECTORY}/source/locale/${language}/LC_MESSAGES/${DOCNAME}.po
165
-    git checkout -q -- ${DIRECTORY}/source/locale/${language}/LC_MESSAGES/${DOCNAME}.po
166
-done
167
-
168
-# remove newly created pot files
169
-rm -f ${DIRECTORY}/source/locale/*.pot
170
-
171
-add_language_index_to_original
172
-
173
-# build i18n contributor guide page
174
-sphinx-build -a -W -b html \
175
-    -d ${DIRECTORY}/build/doctrees \
176
-    ${DIRECTORY}/source ${DIRECTORY}/build/html/
177
-
178
-recover_rst_files

+ 0
- 24
tools/get-lang-display-name.py View File

@@ -1,24 +0,0 @@
1
-# Licensed under the Apache License, Version 2.0 (the "License");
2
-# you may not use this file except in compliance with the License.
3
-# You may obtain a copy of the License at
4
-#
5
-#   http://www.apache.org/licenses/LICENSE-2.0
6
-#
7
-# Unless required by applicable law or agreed to in writing, software
8
-# distributed under the License is distributed on an "AS IS" BASIS,
9
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
10
-# implied.
11
-# See the License for the specific language governing permissions and
12
-# limitations under the License.
13
-
14
-import sys
15
-
16
-import babel
17
-
18
-
19
-lang_code = sys.argv[1]
20
-try:
21
-    l = babel.Locale.parse(lang_code)
22
-    print(l.get_display_name())
23
-except Exception:
24
-    print(lang_code)

+ 2
- 4
tox.ini View File

@@ -5,7 +5,7 @@ skipsdist = True
5 5
 
6 6
 [testenv]
7 7
 basepython=python3
8
-install_command = pip install -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt} {opts} {packages}
8
+#install_command = pip install -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt} {opts} {packages}
9 9
 usedevelop = True
10 10
 setenv = VIRTUAL_ENV={envdir}
11 11
 deps = -r{toxinidir}/requirements.txt
@@ -27,12 +27,10 @@ commands = {posargs}
27 27
 passenv =
28 28
   # Required by add-marker.sh
29 29
   ZUUL*
30
-  # Pass NO_LANG_BUILD=1 if you would like to build English version only
31
-  NO_LANG_BUILD
32 30
 commands =
33 31
   doc8 doc/source
34 32
   # Build translated guides
35
-  {toxinidir}/tools/build-docs.sh
33
+  docstheme-build-translated.sh
36 34
 
37 35
 [testenv:pep8]
38 36
 commands =

Loading…
Cancel
Save