Skip to content

Commit

Permalink
add
Browse files Browse the repository at this point in the history
  • Loading branch information
baseplate-admin committed Apr 13, 2024
1 parent d9661f9 commit 9c67fcd
Show file tree
Hide file tree
Showing 7 changed files with 118 additions and 28 deletions.
1 change: 1 addition & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ build:
os: ubuntu-22.04
tools:
python: '3.12'
rust: '1.55'
# You can also specify other tool versions:
jobs:
post_create_environment:
Expand Down
7 changes: 4 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@

# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
import datetime

project = "django_ltree"
copyright = "2024, baseplate-admin"
project = "resvg_py"
author = "baseplate-admin"
release = "0.1.5"
copyright = f"2024-{datetime.date.today().year}, {author}"
release = "0.1.0"

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
Expand Down
56 changes: 56 additions & 0 deletions docs/contributing.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
Contributing
============

Thank you taking interest in this project.


Goals
-----

My goal for this project is:

* To enable all the features available in `resvg` but don't write to the disk, everything must be done in memory.
* Use the bare minimum amount of packages, in both python side and rust side

Getting Started
---------------

Pre-requisite packages:

* Install `poetry <https://python-poetry.org/>`_

* Install `pipx <https://pipx.pypa.io/stable/installation/>`_

* Install `maturin <https://www.maturin.rs/tutorial>`_


Then do the modifications to the `lib.rs` file and add test in tests directory.

1. Install **poetry** dependencies:

.. code-block:: sh
poetry install
2. Activate **poetry** shell:

.. code-block:: sh
poetry shell
3. Build with **maturin**:

.. code-block:: sh
maturin develop
4. Run tests:


.. code-block:: sh
pytest .
If all tests pass, please send a Pull Request to the main repository.
10 changes: 5 additions & 5 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
.. django_ltree documentation master file, created by
.. resvg_py documentation master file, created by
sphinx-quickstart on Sat Feb 24 21:13:02 2024.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to django_ltree's documentation!
Welcome to resvg_py's documentation!
========================================

Augmenting `django` orm with postgres `ltree <https://www.postgresql.org/docs/current/ltree.html>`_ functionalities
Safe bindings to `resvg <https://github.com/RazrFalcon/resvg>`_

.. toctree::
:maxdepth: 2
:caption: Contents:

installation
usage
manager
usgae
contributing

Indices and tables
==================
Expand Down
23 changes: 3 additions & 20 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,16 @@ Installation
Requirements
------------

Python 3.10 to 3.12 supported.
Python 3.8 to 3.12 supported.

Django 4.2 to 5.0 supported.
Currently it builds the non-EOL python versions with `maturin <https://github.com/PyO3/maturin>`_ github-actions.


Installation
------------

1. Install with **pip**:

.. code-block:: sh
python -m pip install django-ltree-2
2. Add django-ltree to your ``INSTALLED_APPS``:

.. code-block:: python
# settings.py
INSTALLED_APPS = [
...,
"django_ltree",
...,
]
3. Run migrations:

.. code-block:: sh
./manage.py migrate
python -m pip install resvg_py
7 changes: 7 additions & 0 deletions docs/resvg.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Resvg Module
============

.. currentmodule:: resvg_py.svg_to_base64


.. function
42 changes: 42 additions & 0 deletions docs/usage.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
Usage
=====


The module takes in **utf-8** encoded `svg_string` and returns `base64` encoded **PNG** string.


Lets say our svg looks like this :

.. raw:: html

<center>
<svg width="300" height="130" xmlns="http://www.w3.org/2000/svg">
<rect width="200" height="100" x="10" y="10" rx="20" ry="20" fill="blue" />
</svg>
</center>


We can convert it to `PNG` by:


.. code-block:: python
import resvg_py
svg_string = """
<svg width="300" height="130" xmlns="http://www.w3.org/2000/svg">
  <rect width="200" height="100" x="10" y="10" rx="20" ry="20" fill="blue" />
</svg>
"""
print(resvg_py.svg_to_base64(svg_string))
This should return the following **PNG** image:

.. raw:: html

<center>
<img src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VVfd7BujBXPVfAfGv4q8GPoqrrrrqfl8D+miu+q+A+Ffxg4Gnc9VVV93vIaBbueq/AuJfzd8NvBdXXXXV14A+mqv+qyD+1XwcuBU4xlVX/f91CXgwaJer/qsg/k381sBPcdVV/3+9Deinueq/EuLfzN8NvBdXXfX/z9eAPpqr/qsh/l3808BbcdVV/3/8DOitueq/A+LfxceB7wbeiquu+r/vZ4D3Bu1y1X8HxH8IfzfwXlx11f9dXwP6aK7674T4D+O3Br4bOMZVV/3fcQl4b9BPc9V/N8R/KB8Hvhp4L6666n+/rwE+G7TLVf8TIP5T+MHARwNvDTyIq6763+MZwE8DXw26lav+J0H8p/NLA68NvDbwYOCluOqq/zn+BrgV+G3gt0F/zVX/UyGuuuqqq/53QFx11VVX/e+AuOqqq6763wFx1VVXXfW/A+Kqq6666n8HxFVXXXXV/w6Iq6666qr/HRBXXXXVVf87IK666qqr/ndAXHXVVVf974C46qqrrvrfAXHVVVdd9b8D4qqrrrrqfwfEVVddddX/Doirrrrqqv8dEFddddVV/zsgrrrqqqv+d0BcddVVV/3vgLjqqquu+t8BcdVVV131vwP/CCSk/oOTVh6qAAAAAElFTkSuQmCC" ></img>
</center>

0 comments on commit 9c67fcd

Please sign in to comment.