Skip to content

Let's discuss documenation #37

@elebur

Description

@elebur

One of the things I like most about the PTB is its documentation. This is one of the best documentation I've ever worked with! And I want PTBTest to have such documentation too.

I think we need to develop a style guide for docstrings so that the documentation is consistent across the project.

Right now, I'm working on the documentation for the EntityParser. Here is an example of docstrings for the module:

This module provides a helper class to transform
marked-up messages to plain text and a :obj:`tuple` of
:class:`entities <telegram.MessageEntity>`.

`Telegram Docs <https://core.telegram.org/bots/api#formatting-options>`_

And here is an example for the get_item function:

    Safely gets item from the sequence by its index.
    If the ``index`` is out of the range, then the ``default`` value is returned.

    :param seq: (`type`: :obj:`~collections.abc.Sequence`) A sequence to get the item from.
    :param index: (`type`: :obj:`int`) An item's index.
    :param default: (`type`: :obj:`~typing.Any`) The value to be returned if the
        ``index`` is out of the range, defaults to :obj:`None`.
    :return: (`type`: :obj:`~typing.Any`) An item under the given ``index`` or
        the ``default`` value.

And here is how these docstrings are rendered:
Image

tuple, entities, Sequence, Any, None, int are links to the objects.


The general template I'm using right now is the next:

Description of a method/funtion

    :param one: (`type`: :obj:`type.of.param`) The param description
    :return: (`type`: :obj:`type.of.return.value`) A return value description.
  • Use cross reference. E.g. if MessageEntity is mentioned it must be a link to the PTB's documentation:
    The function returns :obj:`telegram.MessageEntity`

What would you say?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions