Skip to main content

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

Project description

docstring-to-text

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

For example, here's a class docstring:

class MyClass:
  """
  Here's a class.
  
  
  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:

Here's a class.

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.1.tar.gz (14.5 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.1-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: docstring_to_text-1.0.1.tar.gz
  • Upload date:
  • Size: 14.5 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.1.tar.gz
Algorithm Hash digest
SHA256 ec7bbf9f7ec4da5856fb57d8c15b2f8d41ac60444f4bd249ed0d125db7f1b7cc
MD5 0c9e376a4acd95c0196f94e6e7ae58ec
BLAKE2b-256 209e5239905ffcebdc8bf9c1d139344e3b347ab37368f40260b416652530aee5

See more details on using hashes here.

Provenance

The following attestation bundles were made for docstring_to_text-1.0.1.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.1-py3-none-any.whl.

File metadata

File hashes

Hashes for docstring_to_text-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 476cb4c1303c2ab372af7dc121a3b877c281b03c42827a6a579cb9e2108789aa
MD5 327e1725ad14911d42036e14a7d32f56
BLAKE2b-256 9ca43e111cd0925c5defa11337e2852de7a62560bd3dbc8fd7a0c50c3ce08e84

See more details on using hashes here.

Provenance

The following attestation bundles were made for docstring_to_text-1.0.1-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