1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
#!/bin/sh
set -e
set -u
rm -rf otherdocs/sasmodels othermodels/bumps
mkdir -p otherdocs/sasmodels/build/lib otherdocs/bumps
SASDOC=/usr/share/doc/python-sasmodels-doc/html
cp -r $SASDOC/_sources otherdocs/sasmodels/doc
cp -r $SASDOC/_images otherdocs/sasmodels/doc/images
ln -s /usr/lib/python3/dist-packages/sasmodels otherdocs/sasmodels/build/lib/
BUMPDOC=/usr/share/doc/python-bumps-doc/html
cp -r $BUMPDOC/_sources otherdocs/bumps/doc
cp -r $BUMPDOC/_images otherdocs/bumps/doc/images
# fix up the extensions
find otherdocs -name \*.rst.txt -exec \
file-rename 's/.rst.txt/.rst/' {} +
# horrible hacks to find the missing images and copy them back in
fixmultilinefigure() {
dir=$(dirname $1)
file=$(basename $1)
(
cd "$dir"
awk '/\.\. figure::$/{printf $0; next}; {print}' "$file" > "$file".tmp
mv "$file.tmp" "$file"
)
}
fetchimages() {
srcdir=$1/doc
imgcache=$1/doc/images
for src in $(grep -r -e'^\.\. figure::' -e'\.\. image::' -l $srcdir); do
echo "# Inspecting $src"
base=$(dirname $src)
for img in $(sed -rn 's@\.\. (figure|image):: (.*)@\2@p' $src); do
echo "## Image $img"
path=$base/$(dirname $img)
fname=$(basename $img)
echo " path=$path fname=$fname"
mkdir -p $path
if ! cp $imgcache/$fname $path; then
echo "ERROR: couldn't find $img in $path"
fi
done
done
}
fixmultilinefigure otherdocs/sasmodels/doc/guide/magnetism/magnetism.rst
fixmultilinefigure otherdocs/sasmodels/doc/guide/orientation/orientation.rst
fetchimages otherdocs/sasmodels
fetchimages otherdocs/bumps
|