9 Commits

Author SHA1 Message Date
3c39a42562 Fix: correct README according to simple example
All checks were successful
continuous-integration/drone/push Build is passing
2022-08-06 20:29:02 +02:00
a911b98520 Feat: produce joined_example.pdf for the two examples
All checks were successful
continuous-integration/drone/push Build is passing
2022-08-06 18:04:46 +02:00
bf237d77e5 Feat: add make commands in README 2022-08-06 17:25:51 +02:00
a8d2fa2ed6 Feat: add dependencies in README 2022-08-06 17:18:09 +02:00
bde6c11a27 Fix: add latexmk
All checks were successful
continuous-integration/drone/push Build is passing
2022-07-29 15:20:30 +02:00
923cb16c66 Core: user 3.11 for drone pipeline
Some checks failed
continuous-integration/drone/push Build encountered an error
2022-07-28 19:10:32 +02:00
51d4d32849 Feat: add update package list first
Some checks failed
continuous-integration/drone/push Build is failing
2022-07-28 15:08:15 +02:00
251350f30e Feat: add install of textlive in pipelines
Some checks failed
continuous-integration/drone/push Build is failing
2022-07-28 15:07:17 +02:00
62253cb3ba Core: add pytest in dev-dependencies
Some checks failed
continuous-integration/drone/push Build is failing
2022-07-28 15:02:27 +02:00
10 changed files with 184 additions and 15 deletions

View File

@@ -8,6 +8,8 @@ steps:
environment:
PyPI_TOKEN: pypi_token
commands:
- apt-get update
- apt-get install -y texlive texlive-extra-utils latexmk
- python -m pip install --upgrade pip
- python -m pip install poetry
- poetry install

View File

@@ -2,10 +2,18 @@ docker-build-simple:
docker build -f Dockerfile.simple -t simple .
docker-simple: docker-build-simple
docker run simple sh -c "bopytex -q 2 tpl_example.tex && cat 1_example.tex"
docker run simple sh -c "bopytex -q 2 tpl_example.tex && ls"
docker-build-usecase:
docker build -f Dockerfile.usecase -t usecase .
docker-usecase: docker-build-usecase
docker run usecase sh -c "bopytex -s students.csv tpl_example.tex && cat 1_example.tex"
usecase-example: docker-build-usecase
docker run usecase sh -c "bopytex -s students.csv tpl_example.tex && cat joined_example.pdf" > example/usecase/joined_example.pdf
simple-example: docker-build-simple
docker run simple sh -c "bopytex -q 2 tpl_example.tex && cat joined_example.pdf" > example/simple/joined_example.pdf
examples: usecase-example simple-example

View File

@@ -6,6 +6,8 @@ Bopytex is a command line tool which embed python into latex. It uses jinja2 to
## Installing
Bopytex depends on `texlive` and `textlive-extra-utils` (for latexmk and pdfjoin)
Install and update using [pip](https://pip.pypa.io/en/stable/quickstart/)
pip install -U bopytex
@@ -29,19 +31,31 @@ We have two variables
\item n: \Var{n}
\end{itemize}
%# We can use blocks
\section{Variables}
\subsection{subject}
\begin{itemize}
%- for i in n
\item \Var{a}
%- for k,v in subject.items()
\item
\begin{verbatim}
\Var{k}: \Var{v}
\end{verbatim}
%- endfor
\end{itemize}
\subsection{options}
\begin{itemize}
%- for k,v in options.items()
\item
\begin{verbatim}
\Var{k}: \Var{v}
\end{verbatim}
%- endfor
\end{itemize}
\end{document}
```
To create a version a this document type this
The following command produces the [joined_example.pdf](./example/simple/joined_example.pdf) document
``` bash
$ bopytex tpl_simple.tex
@@ -56,11 +70,11 @@ To produce formulas and values, I use an another tool I an developing: `mapytex
``` python
# bopytex_config.py
from mapytex import Expression
from random import random
random.seed(0) # Controlling the seed allows to make subject reproductible
direct_access = {
"Expression": Expression,
"random": random
}
```
@@ -81,6 +95,27 @@ Every variables, objects or function inside this file will be available inside t
\Var{e.simplify()}
\section{Variables}
\subsection{subject}
\begin{itemize}
%- for k,v in subject.items()
\item
\begin{verbatim}
\Var{k}: \Var{v}
\end{verbatim}
%- endfor
\end{itemize}
\subsection{options}
\begin{itemize}
%- for k,v in options.items()
\item
\begin{verbatim}
\Var{k}: \Var{v}
\end{verbatim}
%- endfor
\end{itemize}
\end{document}
```
@@ -95,8 +130,21 @@ Information about my students are stored in a csv file (here `students.csv`)
"Nicholas Taylor","28","n.taylor@randatmail.com","3","3"
```
Then I can produce a subject for each of my student
Then I can produce a [subject for each of my student](./example/usecase/joined_example.pdf)
``` bash
$ bopytex tpl_simple.tex -s students.csv -c bopytex_config.py
```
## Running examples
I build two examples base of the simple example and how I use it. They are playable through dockerfiles with make commands.
For the simple example
make docker-simple
For how I use it
make docker-usecase

Binary file not shown.

View File

@@ -22,9 +22,23 @@ We have two variables
\section{Variables}
\subsection{subject}
\Var{subject}
\begin{itemize}
%- for k,v in subject.items()
\item
\begin{verbatim}
\Var{k}: \Var{v}
\end{verbatim}
%- endfor
\end{itemize}
\subsection{options}
\Var{options}
\begin{itemize}
%- for k,v in options.items()
\item
\begin{verbatim}
\Var{k}: \Var{v}
\end{verbatim}
%- endfor
\end{itemize}
\end{document}

View File

@@ -1,3 +1,7 @@
import random
from mapytex import Expression
direct_access = {"Expression": Expression}
random.seed(0)
direct_access = {"Expression": Expression, "random": random.random}

Binary file not shown.

View File

@@ -15,8 +15,22 @@
\section{Variables}
\subsection{subject}
\Var{subject}
\begin{itemize}
%- for k,v in subject.items()
\item
\begin{verbatim}
\Var{k}: \Var{v}
\end{verbatim}
%- endfor
\end{itemize}
\subsection{options}
\Var{options}
\begin{itemize}
%- for k,v in options.items()
\item
\begin{verbatim}
\Var{k}: \Var{v}
\end{verbatim}
%- endfor
\end{itemize}
\end{document}

80
poetry.lock generated
View File

@@ -1,3 +1,25 @@
[[package]]
name = "atomicwrites"
version = "1.4.1"
description = "Atomic file writes."
category = "dev"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
[[package]]
name = "attrs"
version = "21.4.0"
description = "Classes Without Boilerplate"
category = "dev"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
[package.extras]
dev = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "mypy", "pytest-mypy-plugins", "zope.interface", "furo", "sphinx", "sphinx-notfound-page", "pre-commit", "cloudpickle"]
docs = ["furo", "sphinx", "zope.interface", "sphinx-notfound-page"]
tests = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "mypy", "pytest-mypy-plugins", "zope.interface", "cloudpickle"]
tests_no_zope = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "mypy", "pytest-mypy-plugins", "cloudpickle"]
[[package]]
name = "cfgv"
version = "3.3.1"
@@ -56,6 +78,14 @@ python-versions = ">=3.7"
[package.extras]
license = ["ukkonen"]
[[package]]
name = "iniconfig"
version = "1.1.1"
description = "iniconfig: brain-dead simple config-ini parsing"
category = "dev"
optional = false
python-versions = "*"
[[package]]
name = "jinja2"
version = "3.1.2"
@@ -156,6 +186,27 @@ python-versions = ">=3.6.8"
[package.extras]
diagrams = ["railroad-diagrams", "jinja2"]
[[package]]
name = "pytest"
version = "7.1.2"
description = "pytest: simple powerful testing with Python"
category = "dev"
optional = false
python-versions = ">=3.7"
[package.dependencies]
atomicwrites = {version = ">=1.0", markers = "sys_platform == \"win32\""}
attrs = ">=19.2.0"
colorama = {version = "*", markers = "sys_platform == \"win32\""}
iniconfig = "*"
packaging = "*"
pluggy = ">=0.12,<2.0"
py = ">=1.8.2"
tomli = ">=1.0.0"
[package.extras]
testing = ["argcomplete", "hypothesis (>=3.56)", "mock", "nose", "pygments (>=2.7.2)", "requests", "xmlschema"]
[[package]]
name = "pyyaml"
version = "6.0"
@@ -180,6 +231,14 @@ category = "dev"
optional = false
python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*"
[[package]]
name = "tomli"
version = "2.0.1"
description = "A lil' TOML parser"
category = "dev"
optional = false
python-versions = ">=3.7"
[[package]]
name = "tox"
version = "3.25.1"
@@ -222,9 +281,16 @@ testing = ["coverage (>=4)", "coverage-enable-subprocess (>=1)", "flaky (>=3)",
[metadata]
lock-version = "1.1"
python-versions = "^3.10"
content-hash = "58b32d094c97c9e0032bf963f264e9eda5ae762f78df52fba910d1a37b3496e2"
content-hash = "2e8e9679154491f8e2d8611aa619ec3b2be4be7b48b6a654230459b076b51886"
[metadata.files]
atomicwrites = [
{file = "atomicwrites-1.4.1.tar.gz", hash = "sha256:81b2c9071a49367a7f770170e5eec8cb66567cfbbc8c73d20ce5ca4a8d71cf11"},
]
attrs = [
{file = "attrs-21.4.0-py2.py3-none-any.whl", hash = "sha256:2d27e3784d7a565d36ab851fe94887c5eccd6a463168875832a1be79c82828b4"},
{file = "attrs-21.4.0.tar.gz", hash = "sha256:626ba8234211db98e869df76230a137c4c40a12d72445c45d5f5b716f076e2fd"},
]
cfgv = [
{file = "cfgv-3.3.1-py2.py3-none-any.whl", hash = "sha256:c6a0883f3917a037485059700b9e75da2464e6c27051014ad85ba6aaa5884426"},
{file = "cfgv-3.3.1.tar.gz", hash = "sha256:f5a830efb9ce7a445376bb66ec94c638a9787422f96264c98edc6bdeed8ab736"},
@@ -249,6 +315,10 @@ identify = [
{file = "identify-2.5.2-py2.py3-none-any.whl", hash = "sha256:feaa9db2dc0ce333b453ce171c0cf1247bbfde2c55fc6bb785022d411a1b78b5"},
{file = "identify-2.5.2.tar.gz", hash = "sha256:a3d4c096b384d50d5e6dc5bc8b9bc44f1f61cefebd750a7b3e9f939b53fb214d"},
]
iniconfig = [
{file = "iniconfig-1.1.1-py2.py3-none-any.whl", hash = "sha256:011e24c64b7f47f6ebd835bb12a743f2fbe9a26d4cecaa7f53bc4f35ee9da8b3"},
{file = "iniconfig-1.1.1.tar.gz", hash = "sha256:bc3af051d7d14b2ee5ef9969666def0cd1a000e121eaea580d4a313df4b37f32"},
]
jinja2 = [
{file = "Jinja2-3.1.2-py3-none-any.whl", hash = "sha256:6088930bfe239f0e6710546ab9c19c9ef35e29792895fed6e6e31a023a182a61"},
{file = "Jinja2-3.1.2.tar.gz", hash = "sha256:31351a702a408a9e7595a8fc6150fc3f43bb6bf7e319770cbc0db9df9437e852"},
@@ -323,6 +393,10 @@ pyparsing = [
{file = "pyparsing-3.0.9-py3-none-any.whl", hash = "sha256:5026bae9a10eeaefb61dab2f09052b9f4307d44aee4eda64b309723d8d206bbc"},
{file = "pyparsing-3.0.9.tar.gz", hash = "sha256:2b020ecf7d21b687f219b71ecad3631f644a47f01403fa1d1036b0c6416d70fb"},
]
pytest = [
{file = "pytest-7.1.2-py3-none-any.whl", hash = "sha256:13d0e3ccfc2b6e26be000cb6568c832ba67ba32e719443bfe725814d3c42433c"},
{file = "pytest-7.1.2.tar.gz", hash = "sha256:a06a0425453864a270bc45e71f783330a7428defb4230fb5e6a731fde06ecd45"},
]
pyyaml = [
{file = "PyYAML-6.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:d4db7c7aef085872ef65a8fd7d6d09a14ae91f691dec3e87ee5ee0539d516f53"},
{file = "PyYAML-6.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:9df7ed3b3d2e0ecfe09e14741b857df43adb5a3ddadc919a2d94fbdf78fea53c"},
@@ -366,6 +440,10 @@ toml = [
{file = "toml-0.10.2-py2.py3-none-any.whl", hash = "sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b"},
{file = "toml-0.10.2.tar.gz", hash = "sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f"},
]
tomli = [
{file = "tomli-2.0.1-py3-none-any.whl", hash = "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc"},
{file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"},
]
tox = [
{file = "tox-3.25.1-py2.py3-none-any.whl", hash = "sha256:c38e15f4733683a9cc0129fba078633e07eb0961f550a010ada879e95fb32632"},
{file = "tox-3.25.1.tar.gz", hash = "sha256:c138327815f53bc6da4fe56baec5f25f00622ae69ef3fe4e1e385720e22486f9"},

View File

@@ -14,6 +14,7 @@ Jinja2 = "^3.1.2"
[tool.poetry.dev-dependencies]
pre-commit = "^2.20.0"
tox = "^3.25.1"
pytest = "^7.1.2"
[build-system]
requires = ["poetry-core>=1.0.0"]