Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
JelteF authored Jul 23, 2024
2 parents 0477170 + 87629f9 commit 5bd077e
Show file tree
Hide file tree
Showing 73 changed files with 2,798 additions and 1,655 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Python package

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
build:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version:
- "3.7"
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12"
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
# Disable cache so that issues with new dependencies are found more easily
# cache: 'pip'
# cache-dependency-path: |
# dev_requirements.txt
# setup.py
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install texlive-latex-extra texlive-pictures texlive-science texlive-fonts-recommended lmodern ghostscript
python -m pip install --upgrade pip
pip install -r dev_requirements.txt --upgrade
sudo sed '/pattern=".*PDF.*"/d' -i /etc/ImageMagick*/policy.xml
- name: Run tests
run: |
./testall.sh
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ include *.md
recursive-include pylatex *.py
recursive-include python2_source/pylatex *.py
include versioneer.py
include examples/kitten.jpg
17 changes: 5 additions & 12 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PyLaTeX |Travis| |License| |PyPi| |Stable Docs| |Latest Docs|
=============================================================
PyLaTeX |Actions| |License| |PyPi| |Latest Docs|
==============================================================

PyLaTeX is a Python library for creating and compiling LaTeX files or
snippets. The goal of this library is being an easy, but extensible
Expand All @@ -21,12 +21,8 @@ Ubuntu
Documentation
-------------

There are two versions of the documentation:

- The one generated for the `last stable release
- For more details on how to use the library take a look at `the documentation
<https://jeltef.github.io/PyLaTeX/current/>`__.
- The one based on the `latest git version
<https://jeltef.github.io/PyLaTeX/latest/>`__.

Contributing
------------
Expand All @@ -51,8 +47,8 @@ Copyright and License
Copyright 2014 Jelte Fennema, under `the MIT
license <https://github.com/JelteF/PyLaTeX/blob/master/LICENSE>`__

.. |Travis| image:: https://img.shields.io/travis/JelteF/PyLaTeX.svg
:target: https://travis-ci.org/JelteF/PyLaTeX
.. |Actions| image:: https://github.com/JelteF/PyLaTeX/actions/workflows/ci.yml/badge.svg
:target: https://github.com/JelteF/PyLaTeX/actions/workflows/ci.yml

.. |License| image:: https://img.shields.io/github/license/jeltef/pylatex.svg
:target: https://github.com/JelteF/PyLaTeX/blob/master/LICENSE
Expand All @@ -62,6 +58,3 @@ license <https://github.com/JelteF/PyLaTeX/blob/master/LICENSE>`__

.. |Latest Docs| image:: https://img.shields.io/badge/docs-latest-brightgreen.svg?style=flat
:target: https://jeltef.github.io/PyLaTeX/latest/

.. |Stable Docs| image:: https://img.shields.io/badge/docs-stable-brightgreen.svg?style=flat
:target: https://jeltef.github.io/PyLaTeX/current/
93 changes: 54 additions & 39 deletions examples/complex_report.py → broken_examples/complex_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,33 @@
# begin-doc-include
import os

from pylatex import Document, PageStyle, Head, Foot, MiniPage, \
StandAloneGraphic, MultiColumn, Tabu, LongTabu, LargeText, MediumText, \
LineBreak, NewPage, Tabularx, TextColor, simple_page_number
from pylatex.utils import bold, NoEscape
from pylatex import (
Document,
Foot,
Head,
LargeText,
LineBreak,
LongTabu,
MediumText,
MiniPage,
MultiColumn,
NewPage,
PageStyle,
StandAloneGraphic,
Tabu,
Tabularx,
TextColor,
simple_page_number,
)
from pylatex.utils import NoEscape, bold


def generate_unique():
geometry_options = {
"head": "40pt",
"margin": "0.5in",
"bottom": "0.6in",
"includeheadfoot": True
"includeheadfoot": True,
}
doc = Document(geometry_options=geometry_options)

Expand All @@ -32,55 +47,57 @@ def generate_unique():

# Header image
with first_page.create(Head("L")) as header_left:
with header_left.create(MiniPage(width=NoEscape(r"0.49\textwidth"),
pos='c')) as logo_wrapper:
logo_file = os.path.join(os.path.dirname(__file__),
'sample-logo.png')
logo_wrapper.append(StandAloneGraphic(image_options="width=120px",
filename=logo_file))
with header_left.create(
MiniPage(width=NoEscape(r"0.49\textwidth"), pos="c")
) as logo_wrapper:
logo_file = os.path.join(os.path.dirname(__file__), "sample-logo.png")
logo_wrapper.append(
StandAloneGraphic(image_options="width=120px", filename=logo_file)
)

# Add document title
with first_page.create(Head("R")) as right_header:
with right_header.create(MiniPage(width=NoEscape(r"0.49\textwidth"),
pos='c', align='r')) as title_wrapper:
with right_header.create(
MiniPage(width=NoEscape(r"0.49\textwidth"), pos="c", align="r")
) as title_wrapper:
title_wrapper.append(LargeText(bold("Bank Account Statement")))
title_wrapper.append(LineBreak())
title_wrapper.append(MediumText(bold("Date")))

# Add footer
with first_page.create(Foot("C")) as footer:
message = "Important message please read"
with footer.create(Tabularx(
"X X X X",
width_argument=NoEscape(r"\textwidth"))) as footer_table:

with footer.create(
Tabularx("X X X X", width_argument=NoEscape(r"\textwidth"))
) as footer_table:
footer_table.add_row(
[MultiColumn(4, align='l', data=TextColor("blue", message))])
[MultiColumn(4, align="l", data=TextColor("blue", message))]
)
footer_table.add_hline(color="blue")
footer_table.add_empty_row()

branch_address = MiniPage(
width=NoEscape(r"0.25\textwidth"),
pos='t')
branch_address = MiniPage(width=NoEscape(r"0.25\textwidth"), pos="t")
branch_address.append("960 - 22nd street east")
branch_address.append("\n")
branch_address.append("Saskatoon, SK")

document_details = MiniPage(width=NoEscape(r"0.25\textwidth"),
pos='t', align='r')
document_details = MiniPage(
width=NoEscape(r"0.25\textwidth"), pos="t", align="r"
)
document_details.append("1000")
document_details.append(LineBreak())
document_details.append(simple_page_number())

footer_table.add_row([branch_address, branch_address,
branch_address, document_details])
footer_table.add_row(
[branch_address, branch_address, branch_address, document_details]
)

doc.preamble.append(first_page)
# End first page style

# Add customer information
with doc.create(Tabu("X[l] X[r]")) as first_page_table:
customer = MiniPage(width=NoEscape(r"0.49\textwidth"), pos='h')
customer = MiniPage(width=NoEscape(r"0.49\textwidth"), pos="h")
customer.append("Verna Volcano")
customer.append("\n")
customer.append("For some Person")
Expand All @@ -92,8 +109,7 @@ def generate_unique():
customer.append("Address3")

# Add branch information
branch = MiniPage(width=NoEscape(r"0.49\textwidth"), pos='t!',
align='r')
branch = MiniPage(width=NoEscape(r"0.49\textwidth"), pos="t!", align="r")
branch.append("Branch no.")
branch.append(LineBreak())
branch.append(bold("1181..."))
Expand All @@ -107,15 +123,14 @@ def generate_unique():
doc.add_color(name="lightgray", model="gray", description="0.80")

# Add statement table
with doc.create(LongTabu("X[l] X[2l] X[r] X[r] X[r]",
row_height=1.5)) as data_table:
data_table.add_row(["date",
"description",
"debits($)",
"credits($)",
"balance($)"],
mapper=bold,
color="lightgray")
with doc.create(
LongTabu("X[l] X[2l] X[r] X[r] X[r]", row_height=1.5)
) as data_table:
data_table.add_row(
["date", "description", "debits($)", "credits($)", "balance($)"],
mapper=bold,
color="lightgray",
)
data_table.add_empty_row()
data_table.add_hline()
row = ["2016-JUN-01", "Test", "$100", "$1000", "-$900"]
Expand All @@ -129,12 +144,12 @@ def generate_unique():

# Add cheque images
with doc.create(LongTabu("X[c] X[c]")) as cheque_table:
cheque_file = os.path.join(os.path.dirname(__file__),
'chequeexample.png')
cheque_file = os.path.join(os.path.dirname(__file__), "chequeexample.png")
cheque = StandAloneGraphic(cheque_file, image_options="width=200px")
for i in range(0, 20):
cheque_table.add_row([cheque, cheque])

doc.generate_pdf("complex_report", clean_tex=False)


generate_unique()
8 changes: 4 additions & 4 deletions examples/longtabu.py → broken_examples/longtabu.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"""

# begin-doc-include
from pylatex import Document, LongTabu, HFill
from pylatex import Document, HFill, LongTabu
from pylatex.utils import bold


Expand All @@ -19,7 +19,7 @@ def genenerate_longtabu():
"margin": "0.5in",
"headheight": "20pt",
"headsep": "10pt",
"includeheadfoot": True
"includeheadfoot": True,
}
doc = Document(page_numbers=True, geometry_options=geometry_options)

Expand All @@ -30,8 +30,7 @@ def genenerate_longtabu():
data_table.add_hline()
data_table.add_empty_row()
data_table.end_table_header()
data_table.add_row(["Prov", "Num", "CurBal", "IntPay", "Total",
"IntR"])
data_table.add_row(["Prov", "Num", "CurBal", "IntPay", "Total", "IntR"])
row = ["PA", "9", "$100", "%10", "$1000", "Test"]
for i in range(50):
data_table.add_row(row)
Expand All @@ -42,4 +41,5 @@ def genenerate_longtabu():

doc.generate_pdf("longtabu", clean_tex=False)


genenerate_longtabu()
9 changes: 5 additions & 4 deletions examples/tabus.py → broken_examples/tabus.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

# begin-doc-include
from random import randint
from pylatex import Document, LongTabu, Tabu, Center

from pylatex import Center, Document, LongTabu, Tabu
from pylatex.utils import bold


Expand All @@ -18,7 +19,7 @@ def genenerate_tabus():
"margin": "1.5in",
"headheight": "20pt",
"headsep": "10pt",
"includeheadfoot": True
"includeheadfoot": True,
}
doc = Document(page_numbers=True, geometry_options=geometry_options)

Expand All @@ -30,8 +31,7 @@ def genenerate_tabus():
data_table.add_hline()
data_table.add_empty_row()
data_table.end_table_header()
data_table.add_row(["Prov", "Num", "CurBal", "IntPay", "Total",
"IntR"])
data_table.add_row(["Prov", "Num", "CurBal", "IntPay", "Total", "IntR"])
row = ["PA", "9", "$100", "%10", "$1000", "Test"]
for i in range(40):
data_table.add_row(row)
Expand All @@ -56,4 +56,5 @@ def genenerate_tabus():

doc.generate_pdf("tabus", clean_tex=False)


genenerate_tabus()
9 changes: 0 additions & 9 deletions convert_to_py2.sh

This file was deleted.

2 changes: 0 additions & 2 deletions dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
-e .[all]
-e git+https://github.com/JelteF/sphinx.git@better-autodoc-skip-member#egg=sphinx
-e git+https://github.com/JelteF/sphinx_rtd_theme.git@master#egg=sphinx-rtd-theme
-e git+https://github.com/JelteF/flake8-putty.git@master#egg=flake8-putty
pyflakes==2.2.0
8 changes: 4 additions & 4 deletions docs/gen_example_title.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

title = sys.argv[1]

if title.endswith('_ex'):
if title.endswith("_ex"):
title = title[:-3]

title = title.replace('_', ' ')
title = title.capitalize() + ' example'
title = title.replace("_", " ")
title = title.capitalize() + " example"

print(title)
print(len(title) * '=')
print(len(title) * "=")
19 changes: 18 additions & 1 deletion docs/source/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,22 @@ This version might not be stable, but to install it use::

pip install git+https://github.com/JelteF/PyLaTeX.git

1.4.2_ - `docs <../v1.4.2/>`__ - 2023-10-19
-------------------------------------------

Added
~~~~~
- Add `.Chapter` in ``__init__.py``

Fixed
~~~~~
- Fix installation on Python 3.12

Cleanup
~~~~~~~
- Update tooling (use black and isort and remove custom flake8 stuff)


1.4.1_ - `docs <../v1.4.1/>`__ - 2020-10-18
-------------------------------------------

Expand Down Expand Up @@ -475,7 +491,8 @@ Fixed
- Fix package delegation with duplicate packages


.. _Unreleased: https://github.com/JelteF/PyLaTeX/compare/v1.4.1...HEAD
.. _Unreleased: https://github.com/JelteF/PyLaTeX/compare/v1.4.2...HEAD
.. _1.4.2: https://github.com/JelteF/PyLaTeX/compare/v1.4.1...1.4.2
.. _1.4.1: https://github.com/JelteF/PyLaTeX/compare/v1.4.0...1.4.1
.. _1.4.0: https://github.com/JelteF/PyLaTeX/compare/v1.3.4...1.4.0
.. _1.3.4: https://github.com/JelteF/PyLaTeX/compare/v1.3.3...1.3.4
Expand Down
Loading

0 comments on commit 5bd077e

Please sign in to comment.