Metadata-Version: 2.1
Name: pygenstub
Version: 1.1
Summary: Python stub file generator.
Home-page: https://bitbucket.org/uyar/pygenstub
Author: H. Turgut Uyar
Author-email: uyar@tekir.org
License: GPL
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Console
Classifier: Framework :: Sphinx :: Extension
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Documentation :: Sphinx
Classifier: Topic :: Software Development :: Documentation
Provides-Extra: test
Provides-Extra: doc
Provides-Extra: dev
Requires-Dist: docutils
Provides-Extra: dev
Requires-Dist: flake8; extra == 'dev'
Requires-Dist: flake8-isort; extra == 'dev'
Requires-Dist: flake8-docstrings; extra == 'dev'
Requires-Dist: readme-renderer; extra == 'dev'
Requires-Dist: wheel; extra == 'dev'
Requires-Dist: twine; extra == 'dev'
Provides-Extra: doc
Requires-Dist: sphinx; extra == 'doc'
Requires-Dist: sphinx-rtd-theme; extra == 'doc'
Provides-Extra: test
Requires-Dist: pytest; extra == 'test'
Requires-Dist: pytest-cov; extra == 'test'

Copyright (C) 2016-2018 H. Turgut Uyar <uyar@tekir.org>

pygenstub is a utility for generating stub files from docstrings
in source files. It takes a source file as input and creates a stub file
with the same base name and the ``.pyi`` extension.

:PyPI: https://pypi.org/project/pygenstub/
:Repository: https://bitbucket.org/uyar/pygenstub
:Documentation: https://pygenstub.readthedocs.io/

If the docstring of a function includes a **sig** field, the value of that
field will be used to generate a prototype by matching the types to the
parameters in the same order. For example, for the code given below:

.. code-block:: python

   def foo(a, b):
       """Do foo.

       :sig: (int, str) -> None
       """

pygenstub will generate the following stub:

.. code-block:: python

   def foo(a: int, b: str) -> None: ...

pygenstub consists of a single module which itself contains signatures.
You can see the `source code`_ and the autogenerated `stub file`_
as an example.

Usage
-----

pygenstub has been tested with Python 2.7, Python 3.4+, PyPy2 5.7+,
and PyPy3 5.7+. You can install the latest version using ``pip``::

  pip install pygenstub

Installation creates a script named ``pygenstub`` which can be used
as follows::

  pygenstub foo.py

This command will generate the file ``foo.pyi`` in the same directory
as the input file. If the output file already exists, it will be overwritten.

Sphinx autodoc support
----------------------

If pygenstub is activated as a Sphinx extension (after autodoc), it will insert
type comments for parameters and return values in the docstring. It will also
remove the signature fields to exclude them from the output:

.. code-block:: python

   extensions = [
       'sphinx.ext.autodoc',
       'pygenstub'
   ]

As an example of the output, you can see the `API documentation`_
for pygenstub itself.

.. _source code: https://bitbucket.org/uyar/pygenstub/src/tip/pygenstub.py
.. _stub file: https://bitbucket.org/uyar/pygenstub/src/tip/pygenstub.pyi
.. _API documentation: https://pygenstub.readthedocs.io/en/latest/api.html


