On the fly conversion of Python docstrings to markdown
Project Links
Meta
Author: Michał Krassowski
Requires Python: >=3.7
Classifiers
Intended Audience
- Developers
License
- OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+)
Programming Language
- Python
Topic
- Text Processing :: Markup
- Documentation :: Sphinx
docstring-to-markdown
On the fly conversion of Python docstrings to markdown
- Python 3.7+ (tested on 3.8 up to 3.13)
- can recognise reStructuredText and convert multiple of its features to Markdown
- since v0.13 includes initial support for Google-formatted docstrings
Installation
pip install docstring-to-markdown
Example
Convert reStructuredText:
>>> import docstring_to_markdown
>>> docstring_to_markdown.convert(':math:`\\sum`')
'$\\sum$'
When given the format cannot be recognised an exception will be raised:
>>> docstring_to_markdown.convert('\\sum')
Traceback (most recent call last):
raise UnknownFormatError()
docstring_to_markdown.UnknownFormatError
Extensibility
docstring_to_markdown entry point group allows to add custom converters which follow the Converter protocol.
The built-in converters can be customized by providing entry point with matching name.
Development
pip install -e .
pytest
0.17
May 02, 2025
0.16
Mar 25, 2025
0.15
Feb 21, 2024
0.14
Feb 19, 2024
0.13
Oct 11, 2023
0.12
Mar 21, 2023
0.11
Dec 02, 2022
0.10
Nov 17, 2021
0.9
Apr 05, 2021
0.8
Apr 05, 2021
0.7
Feb 27, 2021
0.6
Feb 20, 2021
0.5
Feb 13, 2021
0.4
Feb 13, 2021
0.3
Feb 08, 2021
0.2
Feb 07, 2021
0.1
Feb 07, 2021