Skip to content

Commit 01636d8

Browse files
authored
Merge pull request #548 from euslisp/add_rst
add rst target in doc/Makefile for sphinx-build
2 parents c1e604f + 57f6548 commit 01636d8

File tree

14 files changed

+445
-70
lines changed

14 files changed

+445
-70
lines changed

.circleci/config.yml

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
version: 2.1
2+
3+
executors:
4+
executor:
5+
docker:
6+
- image: buildpack-deps:18.04
7+
8+
references:
9+
setup-tex: &setup-tex
10+
run:
11+
name: Setup TeX
12+
command: apt-get update -qq && echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections && apt-get install -qq -y texlive-lang-japanese texlive-latex-extra latex2html nkf poppler-utils
13+
setup-jskeus: &setup-jskeus
14+
run:
15+
name: Setup Build tools
16+
command: apt-get update -qq && apt-get install -qq -y make gcc g++ libjpeg-dev libxext-dev libx11-dev libgl1-mesa-dev libglu1-mesa-dev libpq-dev libpng-dev xfonts-100dpi xfonts-75dpi
17+
compile-eus: &compile-jskeus
18+
run:
19+
name: Compile jskeus
20+
command: make eus && (cd eus; git pull --unshallow; git fetch --all) && make
21+
22+
jobs:
23+
html:
24+
executor: executor
25+
steps:
26+
- checkout
27+
- *setup-tex
28+
- *setup-jskeus
29+
- *compile-jskeus
30+
- run:
31+
name: Compile HTML
32+
command: source bashrc.eus && cd doc && make html
33+
- run:
34+
command: |
35+
mkdir -p /tmp/html
36+
cp doc/html/* /tmp/html/
37+
- store_artifacts:
38+
path: /tmp/html
39+
- persist_to_workspace:
40+
root: doc/
41+
paths:
42+
- html/jmanual*.html
43+
- html/jmanual*.png
44+
45+
pdf:
46+
executor: executor
47+
steps:
48+
- checkout
49+
- *setup-tex
50+
- *setup-jskeus
51+
- *compile-jskeus
52+
- run:
53+
name: Cleanup LaTeX
54+
command: cd doc && make distclean
55+
- run:
56+
name: Compile LaTeX and generate PDF
57+
command: source bashrc.eus && cd doc && make pdf
58+
- store_artifacts:
59+
path: doc/jmanual.pdf
60+
destination: jmanual.pdf
61+
- persist_to_workspace:
62+
root: doc/
63+
paths: jmanual.pdf
64+
rst:
65+
executor: executor
66+
steps:
67+
- checkout
68+
- *setup-tex
69+
- *setup-jskeus
70+
- *compile-jskeus
71+
- run:
72+
name: Install Python3
73+
command: apt-get install -y -qq python3-minimal python3-pip
74+
- run:
75+
name: Install Pandoc
76+
command: apt-get install -y -qq pandoc
77+
- run:
78+
name: Setup ja_JP.UTF-8
79+
command: |
80+
set -x
81+
apt-get install -y -qq language-pack-ja
82+
locale -a
83+
echo "export LC_ALL=ja_JP.UTF-8" >> bashrc.eus
84+
source bashrc.eus
85+
locale
86+
- run:
87+
name: Compile reStructuredText(reST)
88+
command: source bashrc.eus && cd doc && make rst
89+
- run:
90+
name: Install Sphinx
91+
command: |
92+
pip3 install --user sphinx
93+
pip3 install --user sphinx_rtd_theme
94+
- run:
95+
name: Build reStructuredText(reST)
96+
command: cd doc && ~/.local/bin/sphinx-build . html
97+
- run:
98+
command: |
99+
mkdir -p /tmp/rst/fig /tmp/rst/html
100+
cp doc/*.rst /tmp/rst
101+
cp doc/fig/*.png /tmp/rst/fig
102+
cp -r doc/html/* /tmp/rst/html
103+
- store_artifacts:
104+
path: /tmp/rst
105+
- persist_to_workspace:
106+
root: /tmp
107+
paths: rst
108+
109+
artifacts:
110+
docker:
111+
- image: circleci/node:8.10.0
112+
steps:
113+
- checkout
114+
- attach_workspace:
115+
at: artifacts
116+
- store_artifacts:
117+
path: artifacts
118+
- run:
119+
command: |
120+
echo "Check is PR commit : CIRCLE_BRANCH = $CIRCLE_BRANCH"
121+
if [ "${CIRCLE_BRANCH}" == master ]; then exit 0; fi
122+
echo "Check if there is commit in doc directory"
123+
git diff origin/master --name-only --relative doc
124+
if [ "`git diff origin/master --name-only --relative doc`" == "" ]; then echo "No update in doc directory found, exitting... "; circleci step halt; fi
125+
echo "Found new commit on doc directory"
126+
- run: cd .circleci/ && git clone https://github.com/themadcreator/circle-github-bot.git
127+
- run: cd .circleci/circle-github-bot && npm install
128+
- run: cd .circleci/circle-github-bot && npm run build
129+
- run: .circleci/github-pr-update.js
130+
131+
workflows:
132+
version: 2.1
133+
build:
134+
jobs:
135+
- pdf
136+
- html
137+
- rst
138+
- artifacts:
139+
requires:
140+
- pdf
141+
- html
142+
- rst
143+

.circleci/github-pr-update.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env node
2+
3+
const bot = require("./circle-github-bot/").create();
4+
5+
bot.comment(process.env.GH_AUTH_TOKEN, `
6+
Thank you for contributing jskeus documentation<br>
7+
Please check latest documents before merging<br>
8+
9+
PDF version of Japanese jmanual: <strong>${bot.artifactLink('artifacts/jmanual.pdf', 'jmanual.pdf')}</strong>
10+
HTML version of Japanese manual: <strong>${bot.artifactLink('artifacts/html/jmanual.html', 'jmanual.html')}</strong>
11+
Sphinx (ReST) version of Japanese manual: <strong>${bot.artifactLink('artifacts/rst/html/jmanual.html', 'jmanual.rst')}</strong>
12+
`);

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## [JSK EusLisp repository](http://jskeus.sourceforge.net) [![Build Status](https://travis-ci.org/euslisp/jskeus.png?branch=master)](https://travis-ci.org/euslisp/jskeus)
1+
## [JSK EusLisp repository](http://jskeus.sourceforge.net) [![Build Status](https://travis-ci.org/euslisp/jskeus.png?branch=master)](https://travis-ci.org/euslisp/jskeus) [![Documentation Status](https://readthedocs.org/projects/jskeus/badge/?version=latest)](https://jskeus.readthedocs.io/ja/latest/?badge=latest)
22

33
[![Join the chat at https://gitter.im/euslisp/jskeus](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/euslisp/jskeus?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
44

circle.yml

Lines changed: 0 additions & 32 deletions
This file was deleted.

doc/Makefile

Lines changed: 49 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,25 @@ all: pdf
1414
rm -fr ${TMPDIR}
1515

1616
copy_eus_tex:
17-
exit
1817
-mkdir -p ${TMPDIR}/fig
1918
cp ../eus/doc/jlatex/*.tex ${TMPDIR}
2019
cp ../eus/doc/jlatex/*.sty ${TMPDIR}
2120
cp -r ../eus/doc/jlatex/fig/* ./fig/* ${TMPDIR}/fig/
22-
for x in ${TMPDIR}/fig/*.jpg; do ebb -b $$x; extractbb $$x;done
21+
(cd ${TMPDIR};for x in fig/*.ps; do ps2ps $$x $$x.new; mv $$x.new $$x; done) ### ???? we need to run ps2ps to pass gs??
22+
(cd ${TMPDIR};for x in fig/*.jpg; do extractbb $$x; done) # workaround for https://github.com/backtracking/bibtex2html/issues/9
2323
cp *.tex ${TMPDIR}
2424
platex --version | grep utf8 || nkf --in-place -e ${TMPDIR}/*.tex
2525
for x in irtrobot irtmodel irtsensor irtscene irtdyna irtgeo irtgl irtutil irtviewer irtx irtmath irtbvh irtcollada irtgraph irtimage irtpointcloud png pqp; do\
2626
irteusgl ../eus/lib/llib/documentation.l "(make-document \"../irteus/$$x.l\" \"${TMPDIR}/$$x-func.tex\")" "(exit)"; \
2727
done
2828

29-
toc: copy_eus_tex
29+
current.tex:
30+
echo "% CURRENT_TAG" > ${TMPDIR}/current.tex
31+
echo "\\\\newcommand{\\\\eusversion}[0]{"`cd ../eus; git describe --tags $$(git rev-list --tags --max-count=1) | sed s/EusLisp-//`"}" >> ${TMPDIR}/current.tex
32+
echo "\\\\newcommand{\\\\irteusversion}[0]{"`git describe --tags $$(git rev-list --tags --max-count=1)`"}" >> ${TMPDIR}/current.tex
33+
cat ${TMPDIR}/current.tex
34+
35+
toc: copy_eus_tex current.tex
3036
(cd ${TMPDIR}; makeindex jmanual.tex)
3137

3238
dvi: toc
@@ -45,17 +51,46 @@ clean:
4551
distclean: clean
4652
rm -f *.dvi *.pdf
4753

48-
html: copy_eus_tex
49-
nkf --in-place -u ${TMPDIR}/*.tex
50-
mkdir ${TMPDIR}/html
51-
sed -i 's@^\(\\\usepackage.*{hyperref}\)@%\1@' ${TMPDIR}/jmanual.tex
52-
sed -i 's@\\\documentclass\[\]{jarticle}@\\\documentclass\[\]{article}@' ${TMPDIR}/jmanual.tex
53-
sed -i 's@^\\\ifnum 42146@%\\\ifnum 42146@' ${TMPDIR}/jmanual.tex
54-
(cd ${TMPDIR}; charset="UTF-8" latex2html -dir ${TMPDIR}/html -local_icons -auto_prefix -iso_language JP jmanual)
54+
html: dvi
55+
mkdir -p ${TMPDIR}/html
56+
(cd ${TMPDIR}; TRANSPARENT_COLOR="#ffffff" charset="UTF-8" latex2html -dir ${TMPDIR}/html -local_icons -split +3 -auto_prefix -init_file ${PWD}/../eus/doc/latex/.latex2html-init -iso_language JP -address "This document was generated using the LaTeX2HTML translator on `date` from <a href=\"http://github.com/euslisp/jskeus.git\">jskeus</a> version <a href=\"http://github.com/euslisp/jskeus/commit/`git -C ${PWD} rev-parse --verify HEAD`\">`git log -1 --oneline`</a>" -html_version="4.0,unicode" jmanual)
57+
(cd ${TMPDIR}/html; for imgfile in jmanual-img*.png; do pngtopnm $$imgfile > /tmp/$$imgfile.pnm; pnmtopng -transparent white /tmp/$$imgfile.pnm > $$imgfile || echo "Failed to convert $$imgfile"; done)
5558
(cd ${TMPDIR}/html; sed -i 's@</TITLE>@</TITLE>\n<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">@' j*.html index.html)
56-
sed -i 's@%\(\\\usepackage.*{hyperref}\)@\1@' ${TMPDIR}/jmanual.tex
57-
sed -i 's@\\\documentclass\[\]{article}@\\\documentclass\[\]{jarticle}@' ${TMPDIR}/jmanual.tex
58-
sed -i 's@^%\\\ifnum 42146@\\\ifnum 42146@' ${TMPDIR}/jmanual.tex
5959
cp -r ${TMPDIR}/html ./
60-
rm -fr ${TMPDIR}
60+
61+
latex.py:
62+
wget https://raw.githubusercontent.com/jobh/latex.py/master/latex.py
63+
64+
rst: current.tex copy_eus_tex latex.py
65+
cp latex.py ../eus/doc/latex/preamble.tex ${TMPDIR}
66+
for file in ${TMPDIR}/*.tex; do \
67+
name=`basename $$file .tex`; \
68+
if [ \"$$name\" = \"test\" -o \"$$name\" = \"jmanual\" ]; then continue; fi; \
69+
echo \"Converting $$name.tex to $$name.rst\"; \
70+
(cd ${TMPDIR}; python3 latex.py -2 -L preamble.tex $$name.tex > /tmp/tmp_$$name.tex); \
71+
pandoc /tmp/tmp_$$name.tex -o $$name.rst -V documentclass=ltjarticle --latex-engine=lualatex; \
72+
sed -i 's@.. figure:: \(.*\).ps@.. figure:: \1.png@g' $$name.rst; # use png for figures \
73+
done
74+
for file in ../eus/doc/jlatex/fig/*.ps; do \
75+
name=`basename $$file .ps`; \
76+
echo \"Converting $$name.ps to $$name.png\"; ### ???? we need to run ps2ps to pass gs?? does not happy with pstopnm \
77+
pstopnm -stdout ../eus/doc/jlatex/fig/$$name.ps | pnmflip -rotate270 | pnmtopng - > fig/$$name.png; \
78+
done
79+
cp jmanual.tex /tmp/jmanual.tex
80+
sed -i 's@\\input{\(.*\)}@..include:: \1\n@g' /tmp/jmanual.tex ### convert \input in tex to bypass pandoc EXCEPT current
81+
sed -i '/..include:: current/r ${TMPDIR}/current.tex' /tmp/jmanual.tex ### convert \input in tex to bypass pandoc EXCEPT current
82+
sed -i 's@\\part{\(.*\)}@.. toctree:: \1@' /tmp/jmanual.tex # convert \part in tex to bypass pandoc
83+
sed -i ':a;/^[^%].*\\\\$$/{N;s/\\\\\n//;ba}' /tmp/jmanual.tex # concatinate title/author multi lines
84+
sed -i '/^\\vspace{10mm}$$/d' /tmp/jmanual.tex # remove vspace{10mm} within title to pass pandoc
85+
pandoc --no-wrap -s /tmp/jmanual.tex -o jmanual.rst -V documentclass=ltjarticle --latex-engine=lualatex
86+
sed -i '[email protected]:: \(.*\)@ \1@' jmanual.rst # restore ..include for rst
87+
sed -i 's@.. toctree:: \(.*\)@.. toctree::\n :maxdepth: 2\n :caption: \1@' jmanual.rst # restore ..toctree for rst
88+
sed -i 's@\*\* \*\*@\*\*\n\*\*@g' jmanual.rst # add newline after ** ** in title
89+
sed -i 's@** -\(.*\)$$@**\n\n-\1\n@' jmanual.rst # add newline before -ロボットモデリングの拡張 in title
90+
sed -i -ne '3!{p;d;};h;n;p;g;p' jmanual.rst ## swap 2nd and 3rd line
91+
sed -i -ne '4!{p;d;};h;n;:1;7!{N;b1};G;h;n;p;g;p' jmanual.rst ## swap lines https://www.unix.com/shell-programming-and-scripting/85230-swapping-switching-2-lines-using-sed.html
92+
sed -i -ne '2h;2!H;$${g;s/\n/ /;p}' jmanual.rst ## concatenate EusLisp and Reference Manual (https://unix.stackexchange.com/questions/188264/want-to-substitute-only-first-occurence-with-sed)
93+
sed -i 's/^:Author:/:Authors: -/' jmanual.rst # use :authors: insteqad of :author:
94+
sed -ie '/^:Authors:/ {p;s/.*//;N; s/\n/\ \ \ \ \ \ \ \ \ \ -\ /;}' jmanual.rst # add authors after :authors:
95+
head -n 20 jmanual.rst
6196

0 commit comments

Comments
 (0)