Skip to content

Commit bb8b188

Browse files
committed
render man pages as PNGs from evergreen
1 parent 9b2dd04 commit bb8b188

File tree

2 files changed

+74
-2
lines changed

2 files changed

+74
-2
lines changed

.evergreen/config.yml

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,43 @@ functions:
114114
content_type: text/html
115115
display_name: "Rendered docs"
116116

117+
"upload man pages" :
118+
- command: shell.exec
119+
params:
120+
silent: true
121+
working_dir: "mongoc"
122+
script: |
123+
. venv/bin/activate
124+
125+
# "man" with redirection writes plain ASCII, use lower-level groff to
126+
# force formatted output. -t lays out tables, -T utf8 sets the output
127+
# type, -man loads the manpage TROFF macros.
128+
for doc in doc/man/*.3; do
129+
echo $doc
130+
fullpath=`pwd`/$doc
131+
groff -man -t -T utf8 $fullpath | term2image -o $fullpath.png
132+
done
133+
134+
mkdir -p man-page-images
135+
mv doc/man/*.png man-page-images
136+
137+
export AWS_ACCESS_KEY_ID=${aws_key}
138+
export AWS_SECRET_ACCESS_KEY=${aws_secret}
139+
sudo apt-get install -y awscli
140+
aws s3 cp man-page-images s3://mciuploads/${project}/man-page-images/${CURRENT_VERSION} --recursive --acl public-read --region us-east-1
141+
142+
sh .evergreen/man-page-image-list.sh man-page-images > man-page-images/index.html
143+
- command: s3.put
144+
params:
145+
aws_key: ${aws_key}
146+
aws_secret: ${aws_secret}
147+
local_file: ${workdir}/mongoc/man-page-images/index.html
148+
remote_file: ${project}/man-page-images/${CURRENT_VERSION}/index.html
149+
bucket: mciuploads
150+
permissions: public-read
151+
content_type: text/html
152+
display_name: "Rendered man pages"
153+
117154
"upload coverage" :
118155
- command: shell.exec
119156
params:
@@ -354,11 +391,12 @@ tasks:
354391
params:
355392
working_dir: "mongoc"
356393
script: |
357-
# Need modern Sphinx for :caption: in literal includes
394+
# Need modern Sphinx for :caption: in literal includes.
395+
# Install term2image for man page rendering.
358396
python -m virtualenv venv
359397
cd venv
360398
. bin/activate
361-
./bin/pip install sphinx
399+
./bin/pip install sphinx git+https://github.com/ajdavis/term2image.git
362400
cd ..
363401
364402
- command: shell.exec
@@ -379,6 +417,7 @@ tasks:
379417
380418
./autogen.sh --enable-html-docs --enable-man-pages && make distcheck
381419
- func: "upload docs"
420+
- func: "upload man pages"
382421
- func: "upload release"
383422
- func: "upload build"
384423

.evergreen/man-page-image-list.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/sh
2+
3+
# Make index.html of all man page images so we can see them in Evergreen.
4+
5+
echo "<html>
6+
<head>
7+
<title>Man Page Images</title>
8+
<style type="text/css">
9+
img { border: 1px solid darkred; }
10+
p.img-name { margin-left: 5em; }
11+
</style>
12+
</head>
13+
<body>"
14+
15+
for path in $1/*.png; do
16+
png=$(basename $path)
17+
case "$png" in
18+
# These pages include all others, CDRIVER-2035
19+
bson_api.3.png)
20+
continue
21+
;;
22+
bson_index.3.png)
23+
continue
24+
;;
25+
*)
26+
echo "
27+
<p class="img-name"><a href=\"${png}\">${png}</a></p>
28+
<p><a href=\"${png}\"><img src=\"${png}\"></a></p>"
29+
;;
30+
esac
31+
done
32+
33+
echo "</body></html>"

0 commit comments

Comments
 (0)