Skip to main content

A Transdoc handler for Python docstrings

Project description

🏳️‍⚧️🐍 Transdoc Python

A Transdoc handler for Python docstrings.

Installation

pip install transdoc[python]

Usage

Transdoc rules are applied to Python docstrings.

For example, given the following rule:

def mdn_link(e: str) -> str:
    '''
    Return a Markdown-formatted link to MDN's documentation of an HTML element.
    '''
    return (
        f"[View `<{e}>` on MDN]"
        f"(https://developer.mozilla.org/en-US/docs/Web/HTML/Element/{e})"
    )

The following Python function's docstring would be transformed as follows:

# Before
def make_link(text: str, href: str) -> str:
    '''
    Generate an HTML link.
    {{mdn_link[a]}}
    '''
    # Please don't write code this insecure in real life
    return f"<a href={href}>{text}</a>"

# After
def make_link(text: str, href: str) -> str:
    '''
    Generate an HTML link.
    [View `<a>` on MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a)
    '''
    # Please don't write code this insecure in real life
    return f"<a href={href}>{text}</a>"

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

transdoc_python-0.1.3.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

transdoc_python-0.1.3-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file transdoc_python-0.1.3.tar.gz.

File metadata

  • Download URL: transdoc_python-0.1.3.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.11.11 Linux/6.8.0-1021-azure

File hashes

Hashes for transdoc_python-0.1.3.tar.gz
Algorithm Hash digest
SHA256 60cadc095eb37abcc7f2fccec2a3a1dc336c5388d0e24dd6138b919e8858a51e
MD5 9088c9d2a5635a00994781f24c359007
BLAKE2b-256 7559d7d2ba4ef372c09d7b6fcbc24ce8f026d079efcdc7881fa68393de4c8b95

See more details on using hashes here.

File details

Details for the file transdoc_python-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: transdoc_python-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.11.11 Linux/6.8.0-1021-azure

File hashes

Hashes for transdoc_python-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 8a69dc4804a08859845d48cd1656efcbda4510bf536ec5dab65623bf36e6cc40
MD5 d03113ef383230bc9f0ded7e1fc1440c
BLAKE2b-256 af4241db8923ddb2d300644fdbaea344a9fe3f502abd729ebd1f9916b39dd678

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page