# 🏳️⚧️🐍 Transdoc Python
A Transdoc handler for Python docstrings.
## Installation
```sh
pip install transdoc[python]
```
## Usage
Transdoc rules are applied to Python docstrings.
For example, given the following rule:
```py
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:
```py
# 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>"
```
Raw data
{
"_id": null,
"home_page": "https://maddyguthridge.github.io/transdoc/handlers",
"name": "transdoc-python",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.11",
"maintainer_email": null,
"keywords": null,
"author": "Maddy Guthridge",
"author_email": "hello@maddyguthridge.com",
"download_url": "https://files.pythonhosted.org/packages/c2/ed/7ea5b1dbc60c5208c23bea91af5c8e012528d6742def9e46775161b671e8/transdoc_python-0.1.4.tar.gz",
"platform": null,
"description": "# \ud83c\udff3\ufe0f\u200d\u26a7\ufe0f\ud83d\udc0d Transdoc Python\n\nA Transdoc handler for Python docstrings.\n\n## Installation\n\n```sh\npip install transdoc[python]\n```\n\n## Usage\n\nTransdoc rules are applied to Python docstrings.\n\nFor example, given the following rule:\n\n```py\ndef mdn_link(e: str) -> str:\n '''\n Return a Markdown-formatted link to MDN's documentation of an HTML element.\n '''\n return (\n f\"[View `<{e}>` on MDN]\"\n f\"(https://developer.mozilla.org/en-US/docs/Web/HTML/Element/{e})\"\n )\n```\n\nThe following Python function's docstring would be transformed as follows:\n\n```py\n# Before\ndef make_link(text: str, href: str) -> str:\n '''\n Generate an HTML link.\n {{mdn_link[a]}}\n '''\n # Please don't write code this insecure in real life\n return f\"<a href={href}>{text}</a>\"\n\n# After\ndef make_link(text: str, href: str) -> str:\n '''\n Generate an HTML link.\n [View `<a>` on MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a)\n '''\n # Please don't write code this insecure in real life\n return f\"<a href={href}>{text}</a>\"\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A Transdoc handler for Python docstrings",
"version": "0.1.4",
"project_urls": {
"Bug Tracker": "https://github.com/MaddyGuthridge/transdoc-python/issues",
"Documentation": "https://maddyguthridge.github.io/transdoc/handlers",
"Homepage": "https://maddyguthridge.github.io/transdoc/handlers",
"Repository": "https://github.com/MaddyGuthridge/transdoc-python"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "6e963260b5841ec967dac69a5dda7412cd674a3f150573b47c5c63918dc02289",
"md5": "f8dd31605a0f198b79cff768576b618b",
"sha256": "b2ca4f89f37a1b7e7f967c3de803003228f24e0a636b83d6a6977f6c245e865e"
},
"downloads": -1,
"filename": "transdoc_python-0.1.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "f8dd31605a0f198b79cff768576b618b",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.11",
"size": 4914,
"upload_time": "2025-02-19T09:10:10",
"upload_time_iso_8601": "2025-02-19T09:10:10.195444Z",
"url": "https://files.pythonhosted.org/packages/6e/96/3260b5841ec967dac69a5dda7412cd674a3f150573b47c5c63918dc02289/transdoc_python-0.1.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "c2ed7ea5b1dbc60c5208c23bea91af5c8e012528d6742def9e46775161b671e8",
"md5": "21ef621319ba0e617dbf87d8df00361d",
"sha256": "b57710eb445e81a2484afc39bf7ab639ebe36bed37b19f551434e4354ca20590"
},
"downloads": -1,
"filename": "transdoc_python-0.1.4.tar.gz",
"has_sig": false,
"md5_digest": "21ef621319ba0e617dbf87d8df00361d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.11",
"size": 3804,
"upload_time": "2025-02-19T09:10:11",
"upload_time_iso_8601": "2025-02-19T09:10:11.241223Z",
"url": "https://files.pythonhosted.org/packages/c2/ed/7ea5b1dbc60c5208c23bea91af5c8e012528d6742def9e46775161b671e8/transdoc_python-0.1.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-02-19 09:10:11",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "MaddyGuthridge",
"github_project": "transdoc-python",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "transdoc-python"
}