Skip to content

Commit

Permalink
[docs] Updated the package name in the docs
Browse files Browse the repository at this point in the history
- Change: Updated the README.
- Change: Updated the docs.
- Change: Updated docstrings and comments.
  • Loading branch information
AnonymouX47 committed Apr 20, 2022
1 parent 4500362 commit 2f994d3
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 37 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ If the image is animated (GIF, WEBP), the animation is infinitely looped **by de

**By default, if multiple sources or at least one directory is given, the TUI (Text-based/Terminal User Interface) is launched to navigate through the images (and/or directories).**

**NOTE:** `python -m term_img` can be used as an alternative to the `term-image` command ***(take note of the differences)***.
**NOTE:** `python -m term_image` can be used as an alternative to the `term-image` command ***(take note of the differences)***.

</details>

Expand All @@ -139,22 +139,22 @@ If the image is animated (GIF, WEBP), the animation is infinitely looped **by de
<summary>Click to expand</summary>

```python
from term_img.image import TermImage
from term_image.image import TermImage

image = TermImage.from_file("path/to/image.png")
```

You can also use a URL if you don't have the file stored locally
```python
from term_img.image import TermImage
from term_image.image import TermImage

image = TermImage.from_url("https://www.example.com/image.png")
```

The library can also be used with PIL images
```python
from PIL import Image
from term_img.image import TermImage
from term_image.image import TermImage

img = Image.open("path/to/image.png")
image = TermImage(img)
Expand Down
2 changes: 1 addition & 1 deletion docs/source/glossary.rst
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Below are definitions of terms used across the library's public interface, excep
font ratio
The **aspect ratio** of a terminal’s font i.e the ratio of **width to height** of a single **character cell** on the terminal.

See also: :py:func:`get_font_ratio() <term_img.get_font_ratio>` and :py:func:`set_font_ratio() <term_img.set_font_ratio>`.
See also: :py:func:`get_font_ratio() <term_image.get_font_ratio>` and :py:func:`set_font_ratio() <term_image.set_font_ratio>`.

padding
padding width
Expand Down
2 changes: 1 addition & 1 deletion docs/source/library/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Known Issues

* **Comment**: First of all, the issue is inherent to these shells and neither a fault of this library nor the Windows Terminal, as drawing images and animations works properly with WSL within Windows Terminal.

* **Solution**: A workaround is to leave some **horizontal allowance** of **at least two columns** to ensure the image never reaches the right edge of the terminal. This can be achieved in the library by using the *h_allow* parameter of :py:meth:`TermImage.set_size() <term_img.image.TermImage.set_size>`.
* **Solution**: A workaround is to leave some **horizontal allowance** of **at least two columns** to ensure the image never reaches the right edge of the terminal. This can be achieved in the library by using the *h_allow* parameter of :py:meth:`TermImage.set_size() <term_image.image.TermImage.set_size>`.


.. _library-planned:
Expand Down
4 changes: 2 additions & 2 deletions docs/source/library/reference/exceptions.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.. automodule:: term_img.exceptions
.. automodule:: term_image.exceptions
:members:
:show-inheritance:

The ``term_img.exceptions`` module defines the following:
The ``term_image.exceptions`` module defines the following:
4 changes: 2 additions & 2 deletions docs/source/library/reference/image.rst
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Core Library Definitions
========================

.. automodule:: term_img.image
.. automodule:: term_image.image
:members:
:show-inheritance:

The ``term_img.image`` module defines the following:
The ``term_image.image`` module defines the following:

.. note:: It's allowed to set properties for :term:`animated` images on non-animated ones, the values are simply ignored.

Expand Down
4 changes: 2 additions & 2 deletions docs/source/library/reference/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ Reference
Top-Level Functions
-------------------

.. autofunction:: term_img.get_font_ratio
.. autofunction:: term_image.get_font_ratio

.. autofunction:: term_img.set_font_ratio
.. autofunction:: term_image.set_font_ratio

|
Expand Down
24 changes: 12 additions & 12 deletions docs/source/library/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@ Creating an instance

If the file is stored on your local filesystem::

from term_img.image import TermImage
from term_image.image import TermImage

image = TermImage.from_file("python.png")

You can also use a URL if you don't have the file stored locally::

from term_img.image import TermImage
from term_image.image import TermImage

image = TermImage.from_url("https://raw.githubusercontent.com/AnonymouX47/term-image/docs/source/resources/python.png")

The library can also be used with PIL images::

from PIL import Image
from term_img.image import TermImage
from term_image.image import TermImage

img = Image.open("python.png")
image = TermImage(img)
Expand Down Expand Up @@ -137,12 +137,12 @@ Drawing/Displaying an image to/in the terminal

There are two ways to draw an image to the terminal screen:

1. The :py:meth:`draw() <term_img.image.TermImage.draw>` method
1. The :py:meth:`draw() <term_image.image.TermImage.draw>` method
::

image.draw()

**NOTE:** :py:meth:`TermImage.draw() <term_img.image.TermImage.draw>` has various parameters for :term:`alignment`/:term:`padding`, transparency and animation control.
**NOTE:** :py:meth:`TermImage.draw() <term_image.image.TermImage.draw>` has various parameters for :term:`alignment`/:term:`padding`, transparency and animation control.

2. Using ``print()`` with an image render output (i.e printing the rendered string)

Expand All @@ -157,7 +157,7 @@ There are two ways to draw an image to the terminal screen:
print(f"{image:>200.^70#ffffff}") # Uses format()

.. note::
- For :term:`animated` images, only the former animates the output, the latter only draws the **current** frame (see :py:meth:`TermImage.seek() <term_img.image.TermImage.seek()>` and :py:meth:`TermImage.tell() <term_img.image.TermImage.tell()>`).
- For :term:`animated` images, only the former animates the output, the latter only draws the **current** frame (see :py:meth:`TermImage.seek() <term_image.image.TermImage.seek()>` and :py:meth:`TermImage.tell() <term_image.image.TermImage.tell()>`).
- Also, the former performs size validation to see if the image will fit into the terminal, while the latter doesn't.


Expand All @@ -167,7 +167,7 @@ There are two ways to draw an image to the terminal screen:
Image render size
-----------------
| The :term:`render size` of an image is the dimension with which an image is rendered.
| The *render size* can be retrieved via the :py:attr:`size <term_img.image.TermImage.size>`, :py:attr:`width <term_img.image.TermImage.width>` and :py:attr:`height <term_img.image.TermImage.height>` properties.
| The *render size* can be retrieved via the :py:attr:`size <term_image.image.TermImage.size>`, :py:attr:`width <term_image.image.TermImage.width>` and :py:attr:`height <term_image.image.TermImage.height>` properties.
The *render size* of an image can be in either of two states:

Expand Down Expand Up @@ -226,7 +226,7 @@ Traceback (most recent call last):
.
ValueError: Cannot specify both width and height

The :py:attr:`width <term_img.image.TermImage.width>` and :py:attr:`height <term_img.image.TermImage.height>` properties are used to set the :term:`render size` of an image after instantiation.
The :py:attr:`width <term_image.image.TermImage.width>` and :py:attr:`height <term_image.image.TermImage.height>` properties are used to set the :term:`render size` of an image after instantiation.

>>> image = Termimage.from_file("python.png") # Unset
>>> image.size is None
Expand Down Expand Up @@ -260,7 +260,7 @@ True

.. note:: An exception is raised if the terminal size is too small to calculate a size.

The :py:attr:`size <term_img.image.TermImage.size>` property can only be set to one value, ``None`` and doing this :ref:`unsets <unset-size>` the :term:`render size`.
The :py:attr:`size <term_image.image.TermImage.size>` property can only be set to one value, ``None`` and doing this :ref:`unsets <unset-size>` the :term:`render size`.

>>> image = Termimage.from_file("python.png", width=100)
>>> image.size
Expand All @@ -279,7 +279,7 @@ True

.. hint::

See :py:meth:`TermImage.set_size() <term_img.image.TermImage.set_size()>` for advanced sizing control.
See :py:meth:`TermImage.set_size() <term_image.image.TermImage.set_size()>` for advanced sizing control.


.. _render-scale:
Expand All @@ -290,7 +290,7 @@ Image render scale
| The :term:`render scale` of an image is the **fraction** of the :term:`render size` that'll actually be used to render the image.
| A valid scale value is a ``float`` in the range ``0 < x <= 1`` i.e greater than zero and less than or equal to one.
The *render scale* can be retrieved via the properties :py:attr:`scale <term_img.image.TermImage.scale>`, :py:attr:`scale_x <term_img.image.TermImage.scale_x>` and :py:attr:`scale_y <term_img.image.TermImage.scale_y>`.
The *render scale* can be retrieved via the properties :py:attr:`scale <term_image.image.TermImage.scale>`, :py:attr:`scale_x <term_image.image.TermImage.scale_x>` and :py:attr:`scale_y <term_image.image.TermImage.scale_y>`.

The scale can be set at instantiation by passing a value to the *scale* **keyword-only** paramter.

Expand All @@ -312,7 +312,7 @@ The rendered result (using ``image.draw()``) should look like:

.. image:: /resources/tutorial/scale_unset.png

| The properties :py:attr:`scale <term_img.image.TermImage.scale>`, :py:attr:`scale_x <term_img.image.TermImage.scale_x>` and :py:attr:`scale_y <term_img.image.TermImage.scale_y>` are used to set the *render scale* of an image after instantiation.
| The properties :py:attr:`scale <term_image.image.TermImage.scale>`, :py:attr:`scale_x <term_image.image.TermImage.scale_x>` and :py:attr:`scale_y <term_image.image.TermImage.scale_y>` are used to set the *render scale* of an image after instantiation.
| ``scale`` accepts a tuple of two scale values or a single scale value.
| ``scale_x`` and ``scale_y`` each accept a single scale value.
Expand Down
2 changes: 1 addition & 1 deletion docs/source/viewer/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Image viewer

The package comes with a standalone in-terminal image viewer based on the library.

| The image viewer is started from the command line using either the ``term-image`` command (only works if the Python scripts directory is on ``PATH``) or ``python -m term_img``.
| The image viewer is started from the command line using either the ``term-image`` command (only works if the Python scripts directory is on ``PATH``) or ``python -m term_image``.
| **\*Take note of the differences**.

Expand Down
2 changes: 1 addition & 1 deletion docs/source/viewer/tui.rst
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,4 @@ Actions

.. note::

All contexts and their actions (with default properties) are defined in ``_context_keys`` in the ``term_img.config`` sub-module.
All contexts and their actions (with default properties) are defined in ``_context_keys`` in the ``term_image.config`` sub-module.
4 changes: 2 additions & 2 deletions term_image/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ def finish_multi_logging():
log_queue.put((None,) * 2) # End of logs
log_queue.join()

# Can't use "term_img", since the logger's level is changed.
# Otherwise, it would affect children of "term_img".
# Can't use "term_image", since the logger's level is changed.
# Otherwise, it would affect children of "term_image".
logger = _logging.getLogger("term-image")
logger.setLevel(_logging.INFO)

Expand Down
14 changes: 7 additions & 7 deletions term_image/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ def draw(
ValueError: An argument is of an appropriate type but has an
unexpected/invalid value.
ValueError: :term:`Render size` or :term:`scale` too small.
term_img.exceptions.InvalidSize: The image's :term:`rendered size` can not
term_image.exceptions.InvalidSize: The image's :term:`rendered size` can not
fit into the :term:`available terminal size <available size>`.
* Animations, **by default**, are infinitely looped and can be terminated
Expand Down Expand Up @@ -582,7 +582,7 @@ def from_url(
Raises:
TypeError: *url* is not a string.
ValueError: The URL is invalid.
term_img.exceptions.URLNotFoundError: The URL does not exist.
term_image.exceptions.URLNotFoundError: The URL does not exist.
PIL.UnidentifiedImageError: Propagated from ``PIL.Image.open()``.
Also propagates connection-related exceptions from ``requests.get()``
Expand Down Expand Up @@ -681,9 +681,9 @@ def set_size(
ValueError: *fit_to_width* or *fit_to_height* is ``True`` when *width*,
*height* or *maxsize* is given.
ValueError: The :term:`available size` is too small for automatic sizing.
term_img.exceptions.InvalidSize: The resulting :term:`render size` is too
term_image.exceptions.InvalidSize: The resulting :term:`render size` is too
small.
term_img.exceptions.InvalidSize: *maxsize* is given and the resulting
term_image.exceptions.InvalidSize: *maxsize* is given and the resulting
:term:`rendered size` will not fit into it.
If neither *width* nor *height* is given or anyone given is ``None``,
Expand Down Expand Up @@ -711,7 +711,7 @@ def set_size(
3. Be careful when setting *fit_to_height* to ``True`` as it might result
in the image's :term:`rendered width` being larger than the terminal
width (or maxsize[0]) because :py:meth:`draw` will (by default) raise
:py:exc:`term_img.exceptions.InvalidSize` if such is the case.
:py:exc:`term_image.exceptions.InvalidSize` if such is the case.
| :term:`Vertical allowance` does not apply when *fit_to_width* is ``True``.
| :term:`horizontal allowance` does not apply when *fit_to_height* is ``True``.
Expand Down Expand Up @@ -1228,10 +1228,10 @@ def _renderer(
Raises:
ValueError: Render size or scale too small.
term_img.exceptions.InvalidSize: *check_size* or *animated* is ``True`` and
term_image.exceptions.InvalidSize: *check_size* or *animated* is ``True`` and
the image's :term:`rendered size` can not fit into the :term:`available
terminal size <available size>`.
term_img.exceptions.TermImageException: The image has been finalized.
term_image.exceptions.TermImageException: The image has been finalized.
NOTE:
* If the ``set_size()`` method was previously used to set the *render size*,
Expand Down
4 changes: 2 additions & 2 deletions term_image/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@ def run(self):
# Writing to STDERR messes up output, especially with the TUI
warnings.showwarning = _log_warning

# Can't use "term_img", since the logger's level is changed.
# Otherwise, it would affect children of "term_img".
# Can't use "term_image", since the logger's level is changed.
# Otherwise, it would affect children of "term_image".
_logger = logging.getLogger("term-image")

# the _stacklevel_ parameter was added in Python 3.8
Expand Down

0 comments on commit 2f994d3

Please sign in to comment.