From 9c67fcd9ff985a1e99a19534f25f54fa804484c2 Mon Sep 17 00:00:00 2001 From: baseplate-admin <61817579+baseplate-admin@users.noreply.github.com> Date: Sat, 13 Apr 2024 09:15:45 +0600 Subject: [PATCH] add --- .readthedocs.yml | 1 + docs/conf.py | 7 +++--- docs/contributing.rst | 56 +++++++++++++++++++++++++++++++++++++++++++ docs/index.rst | 10 ++++---- docs/installation.rst | 23 +++--------------- docs/resvg.rst | 7 ++++++ docs/usage.rst | 42 ++++++++++++++++++++++++++++++++ 7 files changed, 118 insertions(+), 28 deletions(-) create mode 100644 docs/contributing.rst create mode 100644 docs/resvg.rst create mode 100644 docs/usage.rst diff --git a/.readthedocs.yml b/.readthedocs.yml index 94ad694..25271d9 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -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: diff --git a/docs/conf.py b/docs/conf.py index 083389d..7bce843 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -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 diff --git a/docs/contributing.rst b/docs/contributing.rst new file mode 100644 index 0000000..086c50e --- /dev/null +++ b/docs/contributing.rst @@ -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 `_ + +* Install `pipx `_ + +* Install `maturin `_ + + +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. \ No newline at end of file diff --git a/docs/index.rst b/docs/index.rst index 2d9ab45..51be79b 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -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 `_ functionalities +Safe bindings to `resvg `_ .. toctree:: :maxdepth: 2 :caption: Contents: installation - usage - manager + usgae + contributing Indices and tables ================== diff --git a/docs/installation.rst b/docs/installation.rst index b2a40f6..2ef25a1 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -4,9 +4,9 @@ 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 `_ github-actions. Installation @@ -14,23 +14,6 @@ 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 \ No newline at end of file + python -m pip install resvg_py diff --git a/docs/resvg.rst b/docs/resvg.rst new file mode 100644 index 0000000..fd422e9 --- /dev/null +++ b/docs/resvg.rst @@ -0,0 +1,7 @@ +Resvg Module +============ + +.. currentmodule:: resvg_py.svg_to_base64 + + +.. function \ No newline at end of file diff --git a/docs/usage.rst b/docs/usage.rst new file mode 100644 index 0000000..e9112eb --- /dev/null +++ b/docs/usage.rst @@ -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 + +
+ + + +
+ + +We can convert it to `PNG` by: + + +.. code-block:: python + + + import resvg_py + + svg_string = """ + +   + + """ + + print(resvg_py.svg_to_base64(svg_string)) + + +This should return the following **PNG** image: + +.. raw:: html + +
+ +