Skip to content

Commit

Permalink
Make customization parameters keyword-only
Browse files Browse the repository at this point in the history
  • Loading branch information
mportesdev committed Dec 4, 2023
1 parent dae39e1 commit f86c951
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 18 deletions.
9 changes: 5 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,14 @@ Example:
)
pictures.save_pdf('vegetables.pdf')
The keyword parameters of the ``save_pdf`` method and their default values
correspond to the above shown command line options:
The customization parameters of the ``save_pdf`` method are keyword-only and
their default values correspond to the above shown command line options:

.. code-block:: python
PictureShow.save_pdf(
output_file,
*,
page_size='A4',
landscape=False,
margin=72,
Expand Down Expand Up @@ -149,8 +150,8 @@ Example:
must be specified as a keyword argument in the above example, because the
``pictures_to_pdf`` function treats all positional arguments as input files.)

The keyword parameters of the ``pictures_to_pdf`` function and their
default values correspond to the above shown command line options:
The customization parameters of the ``pictures_to_pdf`` function are keyword-only
and their default values correspond to the above shown command line options:

.. code-block:: python
Expand Down
41 changes: 41 additions & 0 deletions changelog.d/20231203_234025_michalportes1_functions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<!--
A new scriv changelog fragment.
Uncomment the section that is right (remove the HTML comment wrapper).
-->

<!--
### Removed
- A bullet item for the Removed category.
-->
<!--
### Added
- A bullet item for the Added category.
-->
### Changed

- Library API: the `page_size`, `landscape`, `margin`, `layout`, `stretch_small`, `fill_area` and `force_overwrite`
parameters to `PictureShow.save_pdf` are now keyword-only

<!--
### Deprecated
- A bullet item for the Deprecated category.
-->
<!--
### Fixed
- A bullet item for the Fixed category.
-->
<!--
### Security
- A bullet item for the Security category.
-->
30 changes: 16 additions & 14 deletions src/pictureshow/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def __init__(self, *pic_files):
def save_pdf(
self,
output_file,
*,
page_size='A4',
landscape=False,
margin=72,
Expand All @@ -47,20 +48,21 @@ def save_pdf(
"""
for _ in self._save_pdf(
output_file,
page_size,
landscape,
margin,
layout,
stretch_small,
fill_area,
force_overwrite,
page_size=page_size,
landscape=landscape,
margin=margin,
layout=layout,
stretch_small=stretch_small,
fill_area=fill_area,
force_overwrite=force_overwrite,
):
pass
return self.result

def _save_pdf(
self,
output_file,
*,
page_size,
landscape,
margin,
Expand Down Expand Up @@ -235,11 +237,11 @@ def pictures_to_pdf(

return pic_show.save_pdf(
output_file,
page_size,
landscape,
margin,
layout,
stretch_small,
fill_area,
force_overwrite,
page_size=page_size,
landscape=landscape,
margin=margin,
layout=layout,
stretch_small=stretch_small,
fill_area=fill_area,
force_overwrite=force_overwrite,
)

0 comments on commit f86c951

Please sign in to comment.