Prechádzať zdrojové kódy

docs: updated the look of the docs

Mikael Koli 4 rokov pred
rodič
commit
c649b3db80
4 zmenil súbory, kde vykonal 146 pridanie a 111 odobranie
  1. 4 2
      README.md
  2. 25 98
      docs/index.rst
  3. BIN
      docs/logo.png
  4. 117 11
      docs/tutorials/example.rst

+ 4 - 2
README.md

@@ -1,5 +1,5 @@
 
-# Red Mail
+# Red Mail: Advanced Email Sender
 > Next generation email sender
 
 ---
@@ -122,7 +122,9 @@ email.send(
 )
 ```
 
-See more practical example in [cookbook](https://red-mail.readthedocs.io/en/latest/tutorials/cookbook.html).
+Short examples from [here](https://red-mail.readthedocs.io/en/latest/tutorials/example.html).
+
+Practical example in [cookbook](https://red-mail.readthedocs.io/en/latest/tutorials/cookbook.html).
 
 ---
 

+ 25 - 98
docs/index.rst

@@ -3,8 +3,8 @@
    :description: Red Mail is an advanced email sender for Python. It is open source and well tested.
    :keywords: send, email, Python
 
-:red:`Red` Mail
-===============
+:red:`Red` Mail: Send Emails in Python
+=============================================
 
 .. image:: https://badgen.net/pypi/v/redmail
    :target: https://pypi.org/project/redmail/
@@ -13,17 +13,11 @@
    :target: https://pypi.org/project/redmail/
 
 Red Mail is a Python library for sending emails. 
-It makes sending emails a breeze regardless of if 
-you need to include HTML, embed images or tables or
-attach documents. 
-
-Sending emails is a pretty straight forward task.
-However, the standard SMTP libraries don't make 
-it particularly easy especially if you want to 
-include more than basic text. Red Mail aims to 
-fix this and it makes sending emails a breeze 
-regardless of if you need to include attachments,
-images or prettier HTML.
+It makes sending emails very trivial regardless of whether 
+you need to embed images, plots, tables or
+attach documents. It also provides you convenient 
+templating options and it is easy to create email alerts, 
+email reports or client notifications with it.
 
 Visit the `source code from Github <https://github.com/Miksus/red-mail>`_
 or `releases in Pypi page <https://pypi.org/project/redmail/>`_.
@@ -32,8 +26,10 @@ or `releases in Pypi page <https://pypi.org/project/redmail/>`_.
 Why Red Mail?
 -------------
 
-Standard SMTP libraries are not very convenient to use. They let you modify any part of the 
-message but simply sending emails **SHOULD NOT** look like this:
+Sending emails is a pretty straight forward task.
+However, the standard SMTP libraries don't make 
+it particularly easy and sending emails **SHOULD NOT** 
+look like this:
 
 .. code-block:: python
 
@@ -74,7 +70,7 @@ It should look like this:
         html="<h1>Hello!</h1>"
     )
 
-Here are also other reasons to use Red Mail:
+There are also other reasons to use Red Mail:
 
 - :ref:`You can put attachments to the email <attachments>`
 - :ref:`You can include images to the body <embedding-images>`
@@ -83,108 +79,39 @@ Here are also other reasons to use Red Mail:
 - :ref:`You can reuse your HTML templates <templating>`
 - :ref:`Gmail pre-configured <config-gmail>`
 - :ref:`Send with cc and bcc <send-cc-bcc>`
+- And it is well tested and documented
 
-In addition, normally tables in emails look like this:
-
-.. image:: /imgs/table_without_style.png
-   :width: 200px
-   
-Red Email styles them like this:
-
-.. image:: /imgs/table_with_style.png
-   :width: 200px
 
 More Examples
 -------------
 
-You can include attachments with your email:
-
-.. code-block:: python
-
-    from pathlib import Path
-    import pandas as pd
-
-    email.send(
-        subject="Email subject",
-        sender="me@example.com",
-        receivers=["you@example.com"],
-        text="Hi, this is a simple email.",
-        attachments={
-            'myfile.csv': Path("path/to/data.csv"),
-            'myfile.xlsx': pd.DataFrame({'A': [1, 2, 3]}),
-            'myfile.html': '<h1>This is content of an attachment</h1>'
-        }
-    )
-
-You can also embed images to the HTML body:
-
-.. code-block:: python
-
-    import pandas as pd
-
-    email.send(
-        subject="Email subject",
-        sender="me@example.com",
-        receivers=["you@example.com"],
-        html="""
-            <h1>Hi,</h1> 
-            <p>have you seen this?</p> 
-            {{ myimg }}
-        """,
-        body_images={"myimg": "path/to/my/image.png"}
-    )
-
-You can also embed prettified tables to the body (using Pandas):
-
-.. code-block:: python
-
-    import pandas as pd
-
-    email.send(
-        subject="Email subject",
-        sender="me@example.com",
-        receivers=["you@example.com"],
-        html="""
-            <h1>Hi,</h1> 
-            <p>have you seen this?</p> 
-            {{ mytable }}
-        """,
-        body_tables={"mytable": pd.DataFrame({'a': [1,2,3], 'b': [1,2,3]})}
-    )
-
-You can also parametrize and template the bodies with Jinja:
-
-.. code-block:: python
+Interested in more? 
+Here are some more quick examples:
 
-    import pandas as pd
-
-    email.send(
-        subject="Email subject",
-        sender="me@example.com",
-        receivers=["you@example.com"],
-        text="Hi {{ friend }}, nice to meet you.",
-        html="<h1>Hi {{ friend }}, nice to meet you</h1>",
-        body_params={
-            "friend": "Jack"
-        }
-    )
+- :ref:`examples-simple`
+- :ref:`examples-attachments`
+- :ref:`examples-embed-image`
+- :ref:`examples-embed-plot`
+- :ref:`examples-embed-table`
+- :ref:`examples-parametrized`
+- :ref:`examples-mega`
 
 
 Interested?
 -----------
 
-There is much more to offer. Install the package:
+Install the package:
 
 .. code-block:: console
 
     pip install redmail
 
-and read further. Here are some example use cases:
+
+Some more practical examples:
 
 - :ref:`cookbook-campaign`
 - :ref:`cookbook-alerts`
 - :ref:`cookbook-stats`
-- :ref:`examples-mega`
 
 .. toctree::
    :maxdepth: 2

BIN
docs/logo.png


+ 117 - 11
docs/tutorials/example.rst

@@ -1,11 +1,12 @@
 
-.. _examples-simple:
+
 
 Examples
 ========
 
-Simple Example
---------------
+This is a collection of various examples of 
+sending emails. Remember to initiate the 
+sender object as:
 
 .. code-block:: python
 
@@ -17,6 +18,14 @@ Simple Example
         user_name='me@example.com', 
         password='<PASSWORD>'
     )
+
+.. _examples-simple:
+
+Simple Example
+--------------
+
+.. code-block:: python
+
     email.send(
         subject="An email",
         sender="me@example.com",
@@ -25,6 +34,111 @@ Simple Example
         html="<h1>Hi, </h1><p>this is an email.</p>"
     )
 
+.. _examples-attachments:
+
+Attachments
+-----------
+
+.. code-block:: python
+
+    from pathlib import Path
+    import pandas as pd
+
+    email.send(
+        subject="Email subject",
+        sender="me@example.com",
+        receivers=["you@example.com"],
+        text="Hi, this is a simple email.",
+        attachments={
+            'myfile.csv': Path("path/to/data.csv"),
+            'myfile.xlsx': pd.DataFrame({'A': [1, 2, 3]}),
+            'myfile.html': '<h1>This is content of an attachment</h1>'
+        }
+    )
+
+.. _examples-embed-image:
+
+Embedded Images
+---------------
+
+.. code-block:: python
+
+    import pandas as pd
+
+    email.send(
+        subject="Email subject",
+        sender="me@example.com",
+        receivers=["you@example.com"],
+        html="""
+            <h1>Hi,</h1> 
+            <p>have you seen this?</p> 
+            {{ myimg }}
+        """,
+        body_images={"myimg": "path/to/my/image.png"}
+    )
+
+.. _examples-embed-plot:
+
+Embedded Plots
+--------------
+
+.. code-block:: python
+
+    import matplotlib.pyplot as plt
+    fig = plt.figure()
+    plt.plot([1,2,3,2,3])
+
+    email.send(
+        subject="Email subject",
+        sender="me@example.com",
+        receivers=["you@example.com"],
+        html="""
+            <h1>Hi,</h1> 
+            <p>have you seen this?</p> 
+            {{ myplot }}
+        """,
+        body_images={"myplot": fig}
+    )
+
+.. _examples-embed-table:
+
+Embedded Tables
+---------------
+
+.. code-block:: python
+
+    import pandas as pd
+
+    email.send(
+        subject="Email subject",
+        sender="me@example.com",
+        receivers=["you@example.com"],
+        html="""
+            <h1>Hi,</h1> 
+            <p>have you seen this?</p> 
+            {{ mytable }}
+        """,
+        body_tables={"mytable": pd.DataFrame({'a': [1,2,3], 'b': [1,2,3]})}
+    )
+
+.. _examples-parametrized:
+
+Parametrization
+---------------
+
+.. code-block:: python
+
+    email.send(
+        subject="Email subject",
+        sender="me@example.com",
+        receivers=["you@example.com"],
+        text="Hi {{ friend }}, nice to meet you.",
+        html="<h1>Hi {{ friend }}, nice to meet you</h1>",
+        body_params={
+            "friend": "Jack"
+        }
+    )
+
 .. _examples-mega:
 
 Super Example
@@ -49,14 +163,6 @@ features of Red Mail:
 
     byte_content = Path("a_file.bin").read_bytes()
 
-    email = EmailSender(
-        host='localhost', 
-        port=0, 
-        user_name='me@example.com', 
-        password='<PASSWORD>'
-    )
-
-    # Send an email
     email.send(
         subject="A lot of stuff!",
         sender="me@example.com",