Metadata-Version: 2.0
Name: pygenstub
Version: 1.0b4
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 :: 4 - Beta
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.4
Classifier: Programming Language :: Python :: 2.7
Classifier: Topic :: Documentation :: Sphinx
Classifier: Topic :: Software Development :: Documentation
Requires-Dist: docutils
Provides-Extra: dev
Requires-Dist: flake8; extra == 'dev'
Requires-Dist: twine; extra == 'dev'
Requires-Dist: wheel; 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'

pygenstub is a utility for generating stub files from Python 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.python.org/pypi/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:

:code:

   .. code-block:: python

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

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

:stub:

   .. code-block:: python

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


Usage
-----

pygenstub can be installed 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.

.. tip::

   pygenstub can be used with PyCharm file watchers to update stub files
   automatically when source files are modified.

pygenstub consists of a single module which itself contains signature fields
and commands as described in the documentation. You can see the `source code`_
and the autogenerated `stub file`_ as an example.

.. note::

   Generating stub files this way might not be a good idea in some cases.
   However, if you're not manually writing your ``.pyi`` files,
   pygenstub should be harmless.

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

If pygenstub is activated as a Sphinx extension (after 'sphinx.ext.autodoc')
in the Sphinx configuration file, 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




History
=======

1.0b4 (2017-06-16)
------------------

* Collect builtin types from the builtins module.

1.0b3 (2017-06-16)
------------------

* Fixes for *args and **kwargs on Python 2 code.

1.0b2 (2017-05-26)
------------------

* Added support for Python 2 again.

1.0b1 (2017-05-09)
------------------

* Added support for using type hints in Sphinx autodoc.

1.0a6 (2017-03-06)
------------------

* Improvements on imported names.

1.0a5 (2017-02-07)
------------------

* Support for methods.
* Support for instance variables.
* Support for base classes.
* Shortened the field name from "signature" to "sig".
* Use three dots instead of actual value for parameter defaults.
* Dropped support for Python 2.

1.0a4 (2017-01-06)
------------------

* Long stubs are now spread over multiple lines.
* Better handling of parameter defaults that are tuples.
* Bugfix: handling of parameter defaults that have the value None.

1.0a3 (2017-01-06)
------------------

* Proper support for names from the typing module in input parameters.
* Added parameter default values to stubs.

1.0a2 (2017-01-03)
------------------

* Support for Python 2.7.

1.0a1 (2017-01-03)
------------------

* First release on PyPI.


