Skip to content

Commit

Permalink
Merge pull request #30 from AceofSpades5757/docs
Browse files Browse the repository at this point in the history
docs: update
  • Loading branch information
AceofSpades5757 committed Apr 11, 2024
2 parents 230c262 + 0448f79 commit 783400f
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 25 deletions.
1 change: 1 addition & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Welcome to clip-util's documentation!
.. toctree::
:maxdepth: 2
:caption: Contents:

quickstart

Description
Expand Down
85 changes: 61 additions & 24 deletions docs/source/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,46 +10,55 @@ Supported Clipboard Formats

- Text
- HTML
- RTF

Clipboard
=========

Will open and close every time the values are set, or retrieved. It's better to use a context manager.

.. code:: python
from clipboard import Clipboard
from clipboard import Clipboard
clipboard = Clipboard()
# Set Clipboard
clipboard['text'] = 'Hello World!'
# OR
clipboard.set_clipboard('text') = 'Hello World!'
clipboard = Clipboard()
# Get Clipboard
text = clipboard['text']
# OR
text = clipboard.get_clipboard('text')
# Set Clipboard
clipboard["text"] = "Hello World!"
# OR
clipboard.set_clipboard("Hello World!")
# Get Clipboard
text = clipboard["text"]
# OR
text = clipboard.get_clipboard("text")
# Supports HTML
clipboard["html"] = "<h1>Hello World</h1>"
Context Manager
===============

.. code:: python
from clipboard import Clipboard
from clipboard import Clipboard
with Clipboard() as clipboard:
with Clipboard() as clipboard:
# Set Clipboard
clipboard['text'] = 'Hello World!'
# OR
clipboard.set_clipboard('text') = 'Hello World!'
# Set Clipboard
clipboard["text"] = "Hello World!"
# OR
clipboard.set_clipboard("Hello World!")
# Get Clipboard
text = clipboard['text']
# OR
text = clipboard.get_clipboard('text')
# Get Clipboard
text = clipboard["text"]
# OR
text = clipboard.get_clipboard("text")
# HTML
clipboard["html"] = "<h1>Hello World</h1>"
Get Clipboard Formats
=====================
Expand All @@ -63,7 +72,35 @@ Get Clipboard Formats
``ClipboardFormats.CF_RTF``
: Represents rich text format.

..code:: python
from clipboard import Clipboard
from clipboard import ClipboardFormats
from clipboard import HTMLClipboard
.. code:: python
from clipboard import Clipboard
from clipboard import ClipboardFormat
with Clipboard() as clipboard:
# Get All Available Formats
format_ids: list[int] = clipboard.available_formats()
# Get Specific Format by ID
# Use parentheses to access the format
formats: list[ClipboardFormat] = []
for format_id in format_ids:
if format_id in ClipboardFormat:
format: ClipboardFormat = ClipboardFormat(format_id)
formats.append(format)
else:
# Format is not supported directly by this library
pass
# Get Specified Format by Name
# Use bracket notation to access the format
format_name: str
for format_name in [f.name for f in formats]:
if format_name in ClipboardFormat:
format: ClipboardFormat = ClipboardFormat[format_name]
name: str = format.name
else:
# Format is not supported directly by this library
pass
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "clip-util"
description = "Clipboard utilities for use with Python."
version = "0.1.23"
version = "0.1.24"
requires-python = ">=3.9"
dependencies = []
license = {file = "LICENSE"}
Expand Down

0 comments on commit 783400f

Please sign in to comment.