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.2.tar.gz (3.5 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.2-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for transdoc_python-0.1.2.tar.gz
Algorithm Hash digest
SHA256 1df20b434f911b6218766cc4d64ac99ef658038ce7f0491f745add7615a92763
MD5 54d9400900a2ee925598dd38540d96c7
BLAKE2b-256 21c93bf055c1a1955953b7521e04ab255856f70834cc133568db1e890066daef

See more details on using hashes here.

File details

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

File metadata

  • Download URL: transdoc_python-0.1.2-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-1020-azure

File hashes

Hashes for transdoc_python-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1485e0089eabb1ed960c619ddae7febc1150726061fa4844c19f237a4c83a514
MD5 02cb0811b1cc80b443871e80c016d6ab
BLAKE2b-256 c94ea768115371c4e673077176d6ecfcc33e6fb4fc996fb1a1d1f1921de528d7

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