Skip to content

Commit 662fb09

Browse files
authored
Release 0.0.4 and step into source directory before compiling a document. (#4)
1 parent 3927e90 commit 662fb09

File tree

9 files changed

+67
-10
lines changed

9 files changed

+67
-10
lines changed

Diff for: .pre-commit-config.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ repos:
5555
rev: v1.17.1
5656
hooks:
5757
- id: codespell
58+
args: [-L=als]
5859
- repo: meta
5960
hooks:
6061
- id: check-hooks-apply

Diff for: CHANGES.rst

+7
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ all releases are available on `Anaconda.org
77
<https://anaconda.org/pytask/pytask-latex>`_.
88

99

10+
0.0.4 - 2020-08-21
11+
------------------
12+
13+
- :gh:`4` changes the default options. latexmk will step into the source directory
14+
before compiling the document. Releases 0.0.4.
15+
16+
1017
0.0.3 - 2020-08-12
1118
------------------
1219

Diff for: README.rst

+4-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ via the ``@pytask.mark.latex`` marker. The default is the following.
7878

7979
.. code-block:: python
8080
81-
@pytask.mark.latex(["--pdf", "--interaction=nonstopmode", "--synctex=1"])
81+
@pytask.mark.latex(["--pdf", "--interaction=nonstopmode", "--synctex=1", "--cd"])
8282
def task_compile_latex_document():
8383
pass
8484
@@ -94,6 +94,9 @@ The options ``jobname``, ``output-directory`` and the ``.tex`` file which will b
9494
compiled are handled by the ``@pytask.mark.depends_on`` and ``@pytask.mark.produces``
9595
markers and cannot be changed.
9696

97+
For more options and their explanations, visit the `manual for latexmk
98+
<https://man.cx/latexmk>`_.
99+
97100
You can either pass a string or a list of strings to the ``@pytask.mark.latex``
98101
decorator.
99102

Diff for: setup.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 0.0.3
2+
current_version = 0.0.4
33
parse = (?P<major>\d+)\.(?P<minor>\d+)(\.(?P<patch>\d+))(\-?((dev)?(?P<dev>\d+))?)
44
serialize =
55
{major}.{minor}.{patch}dev{dev}

Diff for: setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
setup(
55
name="pytask-latex",
6-
version="0.0.3",
6+
version="0.0.4",
77
packages=find_packages(where="src"),
88
package_dir={"": "src"},
99
entry_points={"pytask": ["pytask_latex = pytask_latex.plugin"]},

Diff for: src/pytask_latex/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.0.3"
1+
__version__ = "0.0.4"

Diff for: src/pytask_latex/collect.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
from _pytask.shared import to_list
1414

1515

16+
DEFAULT_OPTIONS = ["--pdf", "--interaction=nonstopmode", "--synctex=1", "--cd"]
17+
18+
1619
def latex(options: Optional[Union[str, Iterable[str]]] = None):
1720
"""Specify command line options for latexmk.
1821
@@ -23,7 +26,7 @@ def latex(options: Optional[Union[str, Iterable[str]]] = None):
2326
2427
"""
2528
if options is None:
26-
options = ["--pdf", "--interaction=nonstopmode", "--synctex=1"]
29+
options = DEFAULT_OPTIONS.copy()
2730
elif isinstance(options, str):
2831
options = [options]
2932
return options

Diff for: tests/test_collect.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import pytest
22
from _pytask.mark import Mark
33
from pytask_latex.collect import _create_command_line_arguments
4+
from pytask_latex.collect import DEFAULT_OPTIONS
45

56

67
class DummyTask:
@@ -9,11 +10,7 @@ class DummyTask:
910

1011
@pytest.mark.unit
1112
@pytest.mark.parametrize(
12-
"args, expected",
13-
[
14-
((), ["--pdf", "--interaction=nonstopmode", "--synctex=1"]),
15-
(("--xelatex",), ["--xelatex"]),
16-
],
13+
"args, expected", [((), DEFAULT_OPTIONS.copy()), (("--xelatex",), ["--xelatex"])],
1714
)
1815
def test_create_command_line_arguments(args, expected):
1916
task = DummyTask()

Diff for: tests/test_execute.py

+46
Original file line numberDiff line numberDiff line change
@@ -292,3 +292,49 @@ def task_compile_document():
292292

293293
assert session.exit_code == 2
294294
assert isinstance(session.collection_reports[0].exc_info[1], ValueError)
295+
296+
297+
@needs_latexmk
298+
@skip_on_github_actions_with_win
299+
@pytest.mark.end_to_end
300+
def test_compile_document_to_out_if_document_has_relative_resources(tmp_path):
301+
"""Test that motivates the ``"--cd"`` flag.
302+
303+
If you have a document which includes other resources via relative paths and you
304+
compile the document to a different output folder, latexmk will not find the
305+
relative resources. Thus, use the ``"--cd"`` flag to enter the source directory
306+
before the compilation.
307+
308+
"""
309+
tmp_path.joinpath("sub", "resources").mkdir(parents=True)
310+
311+
task_source = """
312+
import pytask
313+
314+
@pytask.mark.latex
315+
@pytask.mark.depends_on(["document.tex", "resources/content.tex"])
316+
@pytask.mark.produces("out/document.pdf")
317+
def task_compile_document():
318+
pass
319+
320+
"""
321+
tmp_path.joinpath("sub", "task_dummy.py").write_text(textwrap.dedent(task_source))
322+
323+
latex_source = r"""
324+
\documentclass{report}
325+
\begin{document}
326+
\input{resources/content}
327+
\end{document}
328+
"""
329+
tmp_path.joinpath("sub", "document.tex").write_text(textwrap.dedent(latex_source))
330+
331+
resources = r"""
332+
In Ottakring, in Ottakring, wo das Bitter so viel süßer schmeckt als irgendwo in
333+
Wien.
334+
"""
335+
tmp_path.joinpath("sub", "resources", "content.tex").write_text(resources)
336+
337+
session = main({"paths": tmp_path})
338+
339+
assert session.exit_code == 0
340+
assert len(session.tasks) == 1

0 commit comments

Comments
 (0)