Skip to main content

A simple pip package converting docstrings into clean text (proper paragraphs and indents)

Project description

docstring-to-text

PyPI GitHub Release Test status

A simple pip package converting docstrings into clean text (proper paragraphs and indents).

For example, here's a class docstring:

class MyClass:
  """
  This is a class docstring.
  
  
  It has sphinx-like paragraphs, which can
  span multiple lines. Any modern IDE would
  display them as a single line, that wraps
  the given width.
  
  You can't just remove all the new lines
  in the entire string, because you want
  to preserve paragraphs themselves.
  
  Also, when it comes to lists:
    - You probably want to separate items
    with new lines.
    - However, you don't want to preserve
    lines inside each item.
  
  And...
  * ... you might need various bullet
  characters.
  • Including unicode ones.
  
  And don't forget that the list still needs
  to be separated from the following text.
  """
  ...

With this package, you could do:

from docstring_to_text import *

clean_text = format_docstring(cleandoc(MyClass.__doc__))
clean_text = format_object_docstring(MyClass)

Then, the resulting string would be:

This is a class docstring.

It has sphinx-like paragraphs, which can span multiple lines. Any modern IDE would display them as a single line, that wraps the given width.
You can't just remove all the new lines in the entire string, because you want to preserve paragraphs themselves.
Also, when it comes to lists:
- You probably want to separate items with new lines.
- However, you don't want to preserve lines inside each item.
And...
* ... you might need various bullet characters.
• Including unicode ones.
And don't forget that the list still needs to be separated from the following text.

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

docstring_to_text-1.0.3.tar.gz (17.7 kB view details)

Uploaded Source

Built Distribution

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

docstring_to_text-1.0.3-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

Details for the file docstring_to_text-1.0.3.tar.gz.

File metadata

  • Download URL: docstring_to_text-1.0.3.tar.gz
  • Upload date:
  • Size: 17.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for docstring_to_text-1.0.3.tar.gz
Algorithm Hash digest
SHA256 99d9346a7c3d9f02a140c6503ce2d0ef5eb2671ce2bd7ebfbdc457f486dec6f7
MD5 1001b20a822a2a7d34676668725b1348
BLAKE2b-256 b33b6432115bd8e05698fe5ca1351ab41cfe4eb9fdec1ed936605631af915dae

See more details on using hashes here.

Provenance

The following attestation bundles were made for docstring_to_text-1.0.3.tar.gz:

Publisher: publish-release-to-pypi.yml on Lex-DRL/Py-docstring-to-text

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file docstring_to_text-1.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for docstring_to_text-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 256df10ea647dbe48c2ae84948c5f2196bd6a9e442458540f968ea539c802ce7
MD5 77a57932f13e41d27e0a5921fc7c8616
BLAKE2b-256 7069fc20b4d00d0420ffe78d2379a43c309131130db2be30e28e0c84d5a93a76

See more details on using hashes here.

Provenance

The following attestation bundles were made for docstring_to_text-1.0.3-py3-none-any.whl:

Publisher: publish-release-to-pypi.yml on Lex-DRL/Py-docstring-to-text

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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