code-snapshot


Namecode-snapshot JSON
Version 0.2.4 PyPI version JSON
download
home_pagehttps://github.com/ainomic/code-snapshot
Summarycode_snapshot - A Python library for interacting with the Showcode api.
upload_time2023-05-26 06:10:49
maintainer
docs_urlNone
authorAinomic Technology
requires_python
licenseGNU General Public License (GPL)
keywords snapshot screenshot code-snapshot code-screenshot
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Code snapshot

Create a snapshot image for your code to share the formatted code anywhere. We use [SHOWCODE api](https://api.showcode.app) to create a PNG image for the specified code snippet.

## Getting started

1. Create an account on [Showcode App](https://api.showcode.app/register) to fetch the API key.
1. Sign in to the account and create an API token:
   1. Token name: _Provide a name to the token which you can remember where it is being used_
   1. Check "read" permissions
   1. Copy the token displayed and store somewhere in safe. __Note: This token won't be shown again, so you need to paste it before you close the window__

   ![Create API token snapshot](Showcode_API_token.png)
1. Export an environment variable to store the token in the terminal: `export SHOWCODE_API_KEY={API Token}`
1. Now, you're ready to use the package in your applications.

## Installation

1. Create a virtual environment: `conda create -n code-snapshot-test-env -y python=3.8`
1. Activate the environment: `conda activate code-snapshot-test-env`
1. Install the package `pip install code-snapshot`

## Usage

1. Set the Showcode API token as an environment variable following [Getting started](#getting-started) section
1. Write a python script as following:

   ```python
   from code_snapshot.code_snapshot import CodeSnapshot
   from code_snapshot.models import CodeSnapshotSettings, CodeSnapshotEditor

   if __name__ == "__main__":
      settings=CodeSnapshotSettings(
         title="Hello world in Python",
      )
      editor=CodeSnapshotEditor(
         value="""
   def greet(name):
      print(f"Hello {name}!")

   greet("World")
         """
      )
      cs = CodeSnapshot()
      cs.save_snapshot(settings, editor, filepath="./code_snapshot.png")

   ```

1. Run the python script `python main.py`. This should generate a file `code_snapshot.png` in the same directory as `main.py`.
1. It should look like this:
   ![code_snapshot](code_snapshot.png)
1. You can use `cs.generate_snapshot(settings, editor)` to consume `bytes` if required.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/ainomic/code-snapshot",
    "name": "code-snapshot",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "snapshot,screenshot,code-snapshot,code-screenshot",
    "author": "Ainomic Technology",
    "author_email": "contact@ainomic.in",
    "download_url": "https://files.pythonhosted.org/packages/e3/67/505b5cc997e5ada28d9ce847b3cc73a794415c018160df5b9b7cd0cdb43a/code-snapshot-0.2.4.tar.gz",
    "platform": "ALL",
    "description": "# Code snapshot\n\nCreate a snapshot image for your code to share the formatted code anywhere. We use [SHOWCODE api](https://api.showcode.app) to create a PNG image for the specified code snippet.\n\n## Getting started\n\n1. Create an account on [Showcode App](https://api.showcode.app/register) to fetch the API key.\n1. Sign in to the account and create an API token:\n   1. Token name: _Provide a name to the token which you can remember where it is being used_\n   1. Check \"read\" permissions\n   1. Copy the token displayed and store somewhere in safe. __Note: This token won't be shown again, so you need to paste it before you close the window__\n\n   ![Create API token snapshot](Showcode_API_token.png)\n1. Export an environment variable to store the token in the terminal: `export SHOWCODE_API_KEY={API Token}`\n1. Now, you're ready to use the package in your applications.\n\n## Installation\n\n1. Create a virtual environment: `conda create -n code-snapshot-test-env -y python=3.8`\n1. Activate the environment: `conda activate code-snapshot-test-env`\n1. Install the package `pip install code-snapshot`\n\n## Usage\n\n1. Set the Showcode API token as an environment variable following [Getting started](#getting-started) section\n1. Write a python script as following:\n\n   ```python\n   from code_snapshot.code_snapshot import CodeSnapshot\n   from code_snapshot.models import CodeSnapshotSettings, CodeSnapshotEditor\n\n   if __name__ == \"__main__\":\n      settings=CodeSnapshotSettings(\n         title=\"Hello world in Python\",\n      )\n      editor=CodeSnapshotEditor(\n         value=\"\"\"\n   def greet(name):\n      print(f\"Hello {name}!\")\n\n   greet(\"World\")\n         \"\"\"\n      )\n      cs = CodeSnapshot()\n      cs.save_snapshot(settings, editor, filepath=\"./code_snapshot.png\")\n\n   ```\n\n1. Run the python script `python main.py`. This should generate a file `code_snapshot.png` in the same directory as `main.py`.\n1. It should look like this:\n   ![code_snapshot](code_snapshot.png)\n1. You can use `cs.generate_snapshot(settings, editor)` to consume `bytes` if required.\n",
    "bugtrack_url": null,
    "license": "GNU General Public License (GPL)",
    "summary": "code_snapshot - A Python library for interacting with the Showcode api.",
    "version": "0.2.4",
    "project_urls": {
        "Homepage": "https://github.com/ainomic/code-snapshot"
    },
    "split_keywords": [
        "snapshot",
        "screenshot",
        "code-snapshot",
        "code-screenshot"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3866083f5c227394fdcb605d5cd0fce6ebb486e064d4038e023ffb8ae6fecda4",
                "md5": "a1b299707417c7ad4f9bbaa1b3eb5551",
                "sha256": "c884acd082b342f9e8ec4ac0beb07bbd4cf8766803d7ff98ce6a0f5b2838c5d7"
            },
            "downloads": -1,
            "filename": "code_snapshot-0.2.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a1b299707417c7ad4f9bbaa1b3eb5551",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 16146,
            "upload_time": "2023-05-26T06:10:47",
            "upload_time_iso_8601": "2023-05-26T06:10:47.860729Z",
            "url": "https://files.pythonhosted.org/packages/38/66/083f5c227394fdcb605d5cd0fce6ebb486e064d4038e023ffb8ae6fecda4/code_snapshot-0.2.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e367505b5cc997e5ada28d9ce847b3cc73a794415c018160df5b9b7cd0cdb43a",
                "md5": "2cc782e9e83eb888def2b84e28d95037",
                "sha256": "a738c605ffc58bdc08efaa4bb88c50c59104ef5fc9562da5a94c6f9d75934bce"
            },
            "downloads": -1,
            "filename": "code-snapshot-0.2.4.tar.gz",
            "has_sig": false,
            "md5_digest": "2cc782e9e83eb888def2b84e28d95037",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 162479,
            "upload_time": "2023-05-26T06:10:49",
            "upload_time_iso_8601": "2023-05-26T06:10:49.727518Z",
            "url": "https://files.pythonhosted.org/packages/e3/67/505b5cc997e5ada28d9ce847b3cc73a794415c018160df5b9b7cd0cdb43a/code-snapshot-0.2.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-05-26 06:10:49",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ainomic",
    "github_project": "code-snapshot",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "code-snapshot"
}
        
Elapsed time: 0.08740s