doq


Namedoq JSON
Version 0.10.0 PyPI version JSON
download
home_page
SummaryDocstring generator
upload_time2023-08-07 11:29:29
maintainer
docs_urlNone
author
requires_python
licenseBSD
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            doq
---

.. image:: https://github.com/heavenshell/py-doq/workflows/build/badge.svg
    :target: https://github.com/heavenshell/py-doq/actions

.. image:: https://pyup.io/repos/github/heavenshell/py-doq/python-3-shield.svg
    :target: https://pyup.io/repos/github/heavenshell/py-doq/
    :alt: Python 3

.. image:: https://pyup.io/repos/github/heavenshell/py-doq/shield.svg
    :target: https://pyup.io/repos/github/heavenshell/py-doq/
    :alt: Updates

Docstring generator.

Installation
============

.. code::

  $ pip install doq

How to use
==========

.. code::

  $ cat spam.py
  def spam(arg1, arg2: str) -> str:
      pass

.. code::

  $ cat spam.py | doq
  def spam(arg1, arg2: str) -> str:
    """spam.

    :param arg1:
    :param arg2:
    :type arg2: str
    :rtype: str
    """
    pass

Default formatter is `sphinx`. You can choose `sphinx`, `google` or `numpy`.

.. code::

  $ cat spam.py | doq --formatter=google
  def spam(arg1, arg2: str) -> str:
    """spam.

    Args:
        arg1 : arg1
        arg2 (str): arg2

    Returns:
        str:
    """
    pass

.. code::

  $ cat spam.py | doq --formatter=numpy
  def spam(arg1, arg2: str) -> str:
    """spam.

    Parameters
    ----------
    arg1
          arg1
    arg2 : str
         arg2

    Returns
    -------
    str

    """
    pass

Usage
=====

.. code::

    $ python -m doq.cli --help
    usage: doq [-h] [-f FILE] [--start START] [--end END] [-t TEMPLATE_PATH]
               [-s STYLE] [--formatter FORMATTER] [--indent INDENT] [--omit OMIT]
               [-r] [-d DIRECTORY] [-w] [-v] [-c CONFIG] [--ignore_exception]
               [--ignore_yield] [--ignore_init]

    Docstring generator.

    optional arguments:
      -h, --help            show this help message and exit
      -f FILE, --file FILE  File or STDIN
      --start START         Start lineno
      --end END             End lineno
      -t TEMPLATE_PATH, --template_path TEMPLATE_PATH
                            Path to template directory
      -s STYLE, --style STYLE
                            Output style string or json
      --formatter FORMATTER
                            Docstring formatter. sphinx,google or numpy
      --indent INDENT       Indent number
      --omit OMIT           Omit first argument such as self
      -r, --recursive       Run recursively over directories
      -d DIRECTORY, --directory DIRECTORY
                            Path to directory
      -w, --write           Edit files in-place
      -v, --version         Output the version number
      -c CONFIG, --config CONFIG
                            Path to a setup.cfg or pyproject.toml
      --ignore_exception    Ignore exception statements
      --ignore_yield        Ignore yield statements
      --ignore_init         Ignore generate docstring to __init__ method

Customize template
==================

doq use Jinja2 template. So you can create your own template.

.. note::

    You must create 3 template files.

+-----------+-----------------------------------------+
| File name | Description                             |
+===========+=========================================+
| class.txt | class docstring                         |
+-----------+-----------------------------------------+
| def.txt   | def / method docstring                  |
+-----------+-----------------------------------------+
| noarg.txt | def / method without argument docstring |
+-----------+-----------------------------------------+

Available Jinja2's variable
~~~~~~~~~~~~~~~~~~~~~~~~~~~

+--------------------------+---------------------------+
| Name                     | Description               |
+==========================+===========================+
| name                     | class, method, def's name |
+-------------+------------+---------------------------+
| params      | argument   | Method, def's argument    |
|             +------------+---------------------------+
|             | annotation | Argument's type hint      |
|             +------------+---------------------------+
|             | default    | Defaut keyword argument   |
+-------------+------------+---------------------------+
| exceptions               | List of exception         |
+--------------------------+---------------------------+
| yields                   | List of yield             |
+--------------------------+---------------------------+
| return_type              | Return type hint          |
+--------------------------+---------------------------+

See `examples <https://github.com/heavenshell/py-doq/tree/master/examples>`_

Configuration
=============

doq will automatically search ``setup.cfg`` or ``pyproject.toml`` in your
project.

.. note::

    ignore_exception, ignore_exception and ignore_init can set `true` only.
    If you want turn off, remove from configuration.

setup.cfg
~~~~~~~~~

The section must be ``[doq]``.

configuration file example::

  [doq]
  style = "json"
  template_path = "/path/to/template"

pyproject.toml
~~~~~~~~~~~~~~

The section must be ``[tool.doq]``.

configuration file example::

  [tool.doq]
  style = "json"
  template_path = "/path/to/template"

Completion
==========

This program provides shell completions. It should be out of box if you install
it from a wheel file.

LICENSE
=======

NEW BSD LICENSE.

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "doq",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "",
    "author_email": "Shinya Ohyanagi <sohyanagi@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/bc/62/5d0ac8652ecfaf4470b22db21ca281c3c4dc2db47de8273ec46b4f99183a/doq-0.10.0.tar.gz",
    "platform": null,
    "description": "doq\n---\n\n.. image:: https://github.com/heavenshell/py-doq/workflows/build/badge.svg\n    :target: https://github.com/heavenshell/py-doq/actions\n\n.. image:: https://pyup.io/repos/github/heavenshell/py-doq/python-3-shield.svg\n    :target: https://pyup.io/repos/github/heavenshell/py-doq/\n    :alt: Python 3\n\n.. image:: https://pyup.io/repos/github/heavenshell/py-doq/shield.svg\n    :target: https://pyup.io/repos/github/heavenshell/py-doq/\n    :alt: Updates\n\nDocstring generator.\n\nInstallation\n============\n\n.. code::\n\n  $ pip install doq\n\nHow to use\n==========\n\n.. code::\n\n  $ cat spam.py\n  def spam(arg1, arg2: str) -> str:\n      pass\n\n.. code::\n\n  $ cat spam.py | doq\n  def spam(arg1, arg2: str) -> str:\n    \"\"\"spam.\n\n    :param arg1:\n    :param arg2:\n    :type arg2: str\n    :rtype: str\n    \"\"\"\n    pass\n\nDefault formatter is `sphinx`. You can choose `sphinx`, `google` or `numpy`.\n\n.. code::\n\n  $ cat spam.py | doq --formatter=google\n  def spam(arg1, arg2: str) -> str:\n    \"\"\"spam.\n\n    Args:\n        arg1 : arg1\n        arg2 (str): arg2\n\n    Returns:\n        str:\n    \"\"\"\n    pass\n\n.. code::\n\n  $ cat spam.py | doq --formatter=numpy\n  def spam(arg1, arg2: str) -> str:\n    \"\"\"spam.\n\n    Parameters\n    ----------\n    arg1\n          arg1\n    arg2 : str\n         arg2\n\n    Returns\n    -------\n    str\n\n    \"\"\"\n    pass\n\nUsage\n=====\n\n.. code::\n\n    $ python -m doq.cli --help\n    usage: doq [-h] [-f FILE] [--start START] [--end END] [-t TEMPLATE_PATH]\n               [-s STYLE] [--formatter FORMATTER] [--indent INDENT] [--omit OMIT]\n               [-r] [-d DIRECTORY] [-w] [-v] [-c CONFIG] [--ignore_exception]\n               [--ignore_yield] [--ignore_init]\n\n    Docstring generator.\n\n    optional arguments:\n      -h, --help            show this help message and exit\n      -f FILE, --file FILE  File or STDIN\n      --start START         Start lineno\n      --end END             End lineno\n      -t TEMPLATE_PATH, --template_path TEMPLATE_PATH\n                            Path to template directory\n      -s STYLE, --style STYLE\n                            Output style string or json\n      --formatter FORMATTER\n                            Docstring formatter. sphinx,google or numpy\n      --indent INDENT       Indent number\n      --omit OMIT           Omit first argument such as self\n      -r, --recursive       Run recursively over directories\n      -d DIRECTORY, --directory DIRECTORY\n                            Path to directory\n      -w, --write           Edit files in-place\n      -v, --version         Output the version number\n      -c CONFIG, --config CONFIG\n                            Path to a setup.cfg or pyproject.toml\n      --ignore_exception    Ignore exception statements\n      --ignore_yield        Ignore yield statements\n      --ignore_init         Ignore generate docstring to __init__ method\n\nCustomize template\n==================\n\ndoq use Jinja2 template. So you can create your own template.\n\n.. note::\n\n    You must create 3 template files.\n\n+-----------+-----------------------------------------+\n| File name | Description                             |\n+===========+=========================================+\n| class.txt | class docstring                         |\n+-----------+-----------------------------------------+\n| def.txt   | def / method docstring                  |\n+-----------+-----------------------------------------+\n| noarg.txt | def / method without argument docstring |\n+-----------+-----------------------------------------+\n\nAvailable Jinja2's variable\n~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n+--------------------------+---------------------------+\n| Name                     | Description               |\n+==========================+===========================+\n| name                     | class, method, def's name |\n+-------------+------------+---------------------------+\n| params      | argument   | Method, def's argument    |\n|             +------------+---------------------------+\n|             | annotation | Argument's type hint      |\n|             +------------+---------------------------+\n|             | default    | Defaut keyword argument   |\n+-------------+------------+---------------------------+\n| exceptions               | List of exception         |\n+--------------------------+---------------------------+\n| yields                   | List of yield             |\n+--------------------------+---------------------------+\n| return_type              | Return type hint          |\n+--------------------------+---------------------------+\n\nSee `examples <https://github.com/heavenshell/py-doq/tree/master/examples>`_\n\nConfiguration\n=============\n\ndoq will automatically search ``setup.cfg`` or ``pyproject.toml`` in your\nproject.\n\n.. note::\n\n    ignore_exception, ignore_exception and ignore_init can set `true` only.\n    If you want turn off, remove from configuration.\n\nsetup.cfg\n~~~~~~~~~\n\nThe section must be ``[doq]``.\n\nconfiguration file example::\n\n  [doq]\n  style = \"json\"\n  template_path = \"/path/to/template\"\n\npyproject.toml\n~~~~~~~~~~~~~~\n\nThe section must be ``[tool.doq]``.\n\nconfiguration file example::\n\n  [tool.doq]\n  style = \"json\"\n  template_path = \"/path/to/template\"\n\nCompletion\n==========\n\nThis program provides shell completions. It should be out of box if you install\nit from a wheel file.\n\nLICENSE\n=======\n\nNEW BSD LICENSE.\n",
    "bugtrack_url": null,
    "license": "BSD",
    "summary": "Docstring generator",
    "version": "0.10.0",
    "project_urls": {
        "Homepage": "http://github.com/heavenshell/py-doq"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3b5a6bed88a117a245cb1a2ba611013226fd8a89a347224b6bad17dd6fc99f3e",
                "md5": "20883db57adef7b161efdfd5a437fdcd",
                "sha256": "19b4a3b776b14f4fbe150fb271e177a5443d563e8de12c4853eee4c1c81992f3"
            },
            "downloads": -1,
            "filename": "doq-0.10.0-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "20883db57adef7b161efdfd5a437fdcd",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 16757,
            "upload_time": "2023-08-07T11:29:27",
            "upload_time_iso_8601": "2023-08-07T11:29:27.808111Z",
            "url": "https://files.pythonhosted.org/packages/3b/5a/6bed88a117a245cb1a2ba611013226fd8a89a347224b6bad17dd6fc99f3e/doq-0.10.0-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bc625d0ac8652ecfaf4470b22db21ca281c3c4dc2db47de8273ec46b4f99183a",
                "md5": "9cb00c1151225d0c4fa4fa988785b673",
                "sha256": "672b80c1aeb9f02cda3bcbe95b3046e96319385820bacc70662cc486f4c34a86"
            },
            "downloads": -1,
            "filename": "doq-0.10.0.tar.gz",
            "has_sig": false,
            "md5_digest": "9cb00c1151225d0c4fa4fa988785b673",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 14880,
            "upload_time": "2023-08-07T11:29:29",
            "upload_time_iso_8601": "2023-08-07T11:29:29.588121Z",
            "url": "https://files.pythonhosted.org/packages/bc/62/5d0ac8652ecfaf4470b22db21ca281c3c4dc2db47de8273ec46b4f99183a/doq-0.10.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-07 11:29:29",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "heavenshell",
    "github_project": "py-doq",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "tox": true,
    "lcname": "doq"
}
        
Elapsed time: 0.24569s