Skip to content

Commit

Permalink
Strip more stuff out for eng only build
Browse files Browse the repository at this point in the history
  • Loading branch information
timlinux committed Dec 16, 2023
1 parent 633ca08 commit 1a1c129
Show file tree
Hide file tree
Showing 12 changed files with 95 additions and 890 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/nix-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,4 @@ jobs:
with:
nix_path: nixpkgs=channel:nixos-unstable
- uses: DeterminateSystems/magic-nix-cache-action@v2
- run: nix-shell --run "scripts/pre_translate.sh"
- run: nix-shell --run "scripts/post_translate.sh"
- run: nix-shell --run "scripts/english_build.sh"
92 changes: 4 additions & 88 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,112 +88,28 @@ pip freeze
You should see a list of packages similar to those listed below:

```
pystac==1.9.0
python-dateutil==2.8.2
six==1.16.0
```


## Building the docs

We are now going to use that inasafe-doc directory as source and output directory for the
We are now going to use that inasafe-doc directory as source and output directory for the HTML


```
scripts/pre_translate.sh
scripts/post_translate.sh
scripts/english_build.sh
```

You can also build the docs for a single language:

```
scripts/post_translate.sh id html
```

## Viewing the docs

After building the docs, you can run a lightweight web server to view the
generated web pages:

```
httplz docs/output/html/
```


Translating the english InaSAFE Documentation
=============================================

Every language has it's own maintainer, please contact them,
if you want to help. You find a list of current language maintainers at the
end of this document. If your language is not listed, join our community by
sending a mail to <[email protected]> and ask for
help.

HowTo for language maintainers
------------------------------

* get an account on github.com
* install required tools on your computer
* login to github and create a fork of the inasafe-doc repository that other
translators can work with.

Translators now can create their own fork from the forked repository of the
maintainer, commit their translations to their own forked repository and send
pull request to the language maintainer's repository. Once the maintainer
receives a pull request, he should check the changes, accept the pull request
and merge the changes with the official inasafe-doc repository.

Workflow for adding a new language
----------------------------------

* add your locale code in the pre_translate.sh script in the line with 'LOCALE='
* run 'scripts/pre_translate.sh'. There will be a new directory in the i18n
directory for your language, containing the po-files for all source files
* create an empty(!) directory in the resources directory for your language. The
idea is to ONLY put images in exact the same directory structure if you
want an image to be 'translated'. As default the english one will be used
from the 'en' directory, and only if there is an translated one it will be
found and used.
* add your locale code in the post_translate.sh script in the line with
'LOCALE='

HowTo for translators
---------------------

* get an account on github.com
* install required tools on your computer
* login to github and create a fork of the inasafe-doc repository from your
language maintainer.
* git clone your forked inasafe-doc repository to your computer
* run './scripts/pre_translate.sh &lt;language&gt;' locally to build the
translation files
* translate the .po files locally and use an offline editor.
[QtLinguist](https://code.google.com/p/qtlinguistdownload/)
being the highly recommended choice.
* with the english documentation from ./docs/source/ run '
./scripts/post_translate.sh languagecode' locally again to check your
translation
* files translated need to be "synchronized" with the ones in the directory of
the forked repo. Commit your changes to your private forked repository and
create a pull request on github. It means that you send a request to the
owners of the repository you forked (language maintainer) asking him to
accept your translations and move them to the "original repository". For
doing that go on github.com, browse on the directory of your repository and
click pull request (https://help.github.com/articles/using-pull-requests).
* your language maintainer will take care that every significant translation go
into the master repository.
* Generally, as soon as you finish editing one or more .po files, you should
commit as soon as possible the edits to the git repository,
in order to minimize the possibility of conflicts.

The maintainer and translator should update and check the translations
regularly. Therefore you should 'git pull' when you start to work and run the
'scripts/pre_translate.sh &lt;language&gt;' and 'scripts/post_translate.sh
&lt;language&gt;' script after every significant change in the documentation.
This will generate and update the .po files needed for translations. If all
is fine, take care, that the translation go into the repository of your
language maintainer.
httplz docs/output/html/en/
```


[InaSAFEImage]: http://inasafe.org/en/_static/img/logo.png
[website]: http://inasafe.org/
2 changes: 0 additions & 2 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,8 @@ in pkgs.mkShell rec {
pythonPackages.twitter

pinnedPkgs.sphinx
pinnedPkgs.transifex-client
pinnedPkgs.argparse
pinnedPkgs.rpl
pinnedPkgs.gettext
# Simple http server to test the built docs
pinnedPkgs.httplz

Expand Down
91 changes: 91 additions & 0 deletions english_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#!/usr/bin/env bash
# Based off the script from QGIS by Tim Sutton and Richard Duivenvoorde

# Name of the dir containing static files
STATIC=_static
# Path to the documentation root relative to script execution dir
DOCROOT=docs
# Path from execution dir of this script to docs sources (could be just
# '' depending on how your sphinx project is set up).
SOURCE=source

pushd .
cd $DOCROOT

SPHINXBUILD=`which sphinx-build`
TEXI2PDF=`which texi2pdf`
BUILDDIR=build
# be sure to remove an old build dir
rm -rf ${BUILDDIR}
mkdir -p ${BUILDDIR}

# output dirs
PDFDIR=`pwd`/output/pdf
HTMLDIR=`pwd`/output/html
mkdir -p ${PDFDIR}
mkdir -p ${HTMLDIR}

VERSION=`cat source/conf.py | grep "version = '.*'" | grep -o "[0-9]\.[0-9]"`

# We need to flush the build dir or the translations don't come through
rm -rf ${BUILDDIR}
mkdir ${BUILDDIR}

# cleanup all images for the other locale
rm -rf source/static
mkdir -p source/static
# copy english (base) resources to the static dir
cp -r resources/en/* source/static
# now overwrite possible available (localised) resources over the english ones
cp -r resources/${LOCALE}/* source/static

#################################
#
# HTML Generation
#
#################################
# Now prepare the index/irchat-[locale] template which is a manually translated,
# unique per locale page that gets copied to index.html/irchat.html for the doc
# generation process.
cp templates/index-en.html templates/index.html
cp templates/irchat-en.html templates/irchat.html

echo "Building HTML for locale 'en'..."
LOG=/tmp/sphinx$$.log
# -n Run in nit-picky mode. Currently, this generates warnings for all missing references.
# -W Turn warnings into errors. This means that the build stops at the first warning and sphinx-build exits with exit status 1.
#${SPHINXBUILD} -nW -d ${BUILDDIR}/doctrees -D language=${LOCALE} -b html source ${HTMLDIR}/${LOCALE} > $LOG
${SPHINXBUILD} -d ${BUILDDIR}/doctrees -D language=en -b html source ${HTMLDIR}/en/ > $LOG
WARNINGS=`cat $LOG | grep warning`
ERRORS=`cat $LOG | grep ERROR`
if [[ $WARNINGS ]]
then
echo "***********************************************"
echo "* Sphinx build produces warnings - Please fix *"
echo $WARNINGS
echo "***********************************************"
exit 1
fi
if [[ $ERRORS ]]
then
echo "*********************************************"
echo "* Sphinx build produces errors - Please fix *"
echo $ERRORS
echo "*********************************************"
exit 1
fi

# Remove the static html copy again
rm templates/index.html
rm templates/irchat.html

# hack to avoid error when using Search in contents.html
rpl -q '#/../search.html' 'search.html' ./output/html/en/index.html
# same applies for having the IRC-Chat Navigation Link
rpl -q '#/../irchat.html' 'irchat.html' ./output/html/en/index.html


rm -rf source/static
rm -rf ${BUILDDIR}

popd
6 changes: 0 additions & 6 deletions scripts/.htaccess

This file was deleted.

6 changes: 0 additions & 6 deletions scripts/compress-images.sh

This file was deleted.

77 changes: 0 additions & 77 deletions scripts/create_transifex_resources.sh

This file was deleted.

Loading

0 comments on commit 1a1c129

Please sign in to comment.