{ "info": { "author": "Ismo Toijala", "author_email": "ismo.toijala@gmail.com", "bugtrack_url": null, "classifiers": [ "Framework :: Sphinx :: Extension", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3 :: Only", "Topic :: Documentation :: Sphinx" ], "description": "sphinx_autodoc_future_annotations\n=================================\n\nThis extension allows you to use Python 3 type annotations for documenting module and class attributes and\nfunction arguments and return types.\nThe extension also has support for cyclic imports needed due to type annotations.\nThe extension only works for Python 3.7 and higher and requires the use of ``from __future__ import annotations``.\n\nExample (``a_module.py``):\n\n.. code-block:: python\n\n from __future__ import annotations\n\n import typing as t\n\n if t.TYPE_CHECKING:\n import another_module\n\n module_attribute: t.Optional[another_module.SomeClass] = None\n '''An attribute of the module.'''\n\n class AClass:\n '''A class.'''\n\n instance_attribute: int\n '''An instance attribute.'''\n\n class_attribute: float = 3.0\n '''A class attribute.'''\n\n def __init__(self, arg: t.Union[int, str]):\n pass\n\n def method(self) -> int:\n '''A method.'''\n pass\n\nExample (``another_module.py``):\n\n.. code-block:: python\n\n from __future__ import annotations\n\n import typing\n\n if typing.TYPE_CHECKING:\n import a_module\n\n def function(arg: a_module.AClass):\n '''A function.'''\n pass\n\n class SomeClass:\n pass\n\n\nInstallation and setup\n----------------------\n\nFirst, use pip to download and install the extension::\n\n $ pip install sphinx_autodoc_future_annotations\n\nThen, add the extension to your ``conf.py``:\n\n.. code-block:: python\n\n extensions = [\n 'sphinx.ext.autodoc',\n 'sphinx_autodoc_future_annotations',\n ]\n\n\nHow it works\n------------\n\nCyclic imports needed due to type annotations are supported in the following way.\nFirst, a hook is monkey-patched into ``sphinx.ext.autodoc`` to act when a module is imported.\nThis hook first imports the module normally.\nThen it parses the module's code and finds any top-level ``if``\\-statements that are conditional on\n``TYPE_CHECKING`` from the ``typing`` module.\nAll statements inside such ``if``-statements are executed in the context of te module.\nThis makes the additional imports available to ``typing.get_type_hints``.\n\nThe extension listens to the ``autodoc-process-signature`` and ``autodoc-process-docstring``\nSphinx events. In the former, it strips the annotations from the function signature. In the latter,\nit injects the appropriate ``:type argname:`` and ``:rtype:`` directives into the docstring.\n\nThe ``:type argname:`` and ``:rtype:`` directives are added if and only if no existing matching directive is found.\nEmpty ``:param argname:`` directives are added if no matching directive is found.\nThis allows to document the type of an argument without having to add trivial documentation on its use.\n\nThis extension does not currently have any configuration options.\n\nSome of the code is adapted from `sphinx-autodoc-typehints`_.\n\n.. _sphinx-autodoc-typehints: https://github.com/agronholm/sphinx-autodoc-typehints\n\n\nCompatibility with sphinx.ext.napoleon\n--------------------------------------\n\nTo use `sphinx.ext.napoleon`_ with sphinx_autodoc_future_annotations, make sure you load\n`sphinx.ext.napoleon`_ first, **before** sphinx_autodoc_future_annotations.\n\n.. _sphinx.ext.napoleon: http://www.sphinx-doc.org/en/stable/ext/napoleon.html\n\n.. code-block:: python\n\n extensions = [\n 'sphinx.ext.autodoc',\n 'sphinx.ext.napoleon',\n 'sphinx_autodoc_future_annotations',\n ]\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "sphinx-autodoc-future-annotations", "package_url": "https://pypi.org/project/sphinx-autodoc-future-annotations/", "platform": "", "project_url": "https://pypi.org/project/sphinx-autodoc-future-annotations/", "project_urls": { "Bug Tracker": "https://gitlab.com/itoijala/sphinx_autodoc_future_annotations/issues", "Source Code": "https://gitlab.com/itoijala/sphinx_autodoc_future_annotations" }, "release_url": "https://pypi.org/project/sphinx-autodoc-future-annotations/0.1.3/", "requires_dist": [ "astor (>=0.7.1)", "sphinx (>=1.8)" ], "requires_python": ">= 3.7", "summary": "", "version": "0.1.3" }, "last_serial": 4349390, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "9c10856f25c80b0f822f4b3b27ce9a82", "sha256": "9c7fd86698c0a879c01c9c8d0451aae106dfa5561b6cb9c76982fd4e531d535f" }, "downloads": -1, "filename": "sphinx_autodoc_future_annotations-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "9c10856f25c80b0f822f4b3b27ce9a82", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">= 3.7", "size": 4272, "upload_time": "2018-10-07T14:00:17", "url": "https://files.pythonhosted.org/packages/c0/87/c52daab2f353a1e1a3306bc187a054f3c8ecac17ff0d4e1a8c13c7021188/sphinx_autodoc_future_annotations-0.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "965d6b3ef830c265dee354a02bbf1063", "sha256": "a27b265a84c5ce92373c7e4f82acd32dc24a0339e75f86521e6aa3e76d09310c" }, "downloads": -1, "filename": "sphinx_autodoc_future_annotations-0.1.0.tar.gz", "has_sig": false, "md5_digest": "965d6b3ef830c265dee354a02bbf1063", "packagetype": "sdist", "python_version": "source", "requires_python": ">= 3.7", "size": 4766, "upload_time": "2018-10-07T14:00:18", "url": "https://files.pythonhosted.org/packages/ac/1f/b568c99f258a98173ef81d82ed776cff114f672a8e9079527e862926f3e3/sphinx_autodoc_future_annotations-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "08e048c7eefa02f99fd16a0b4f04bf65", "sha256": "d13871ef48c44ee355f775d01ad51ec971dd0b34209641e724cd1ead2ff560ac" }, "downloads": -1, "filename": "sphinx_autodoc_future_annotations-0.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "08e048c7eefa02f99fd16a0b4f04bf65", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">= 3.7", "size": 5447, "upload_time": "2018-10-07T14:04:31", "url": "https://files.pythonhosted.org/packages/8d/4e/b85fa798b9e2486d43e6fc90605b4c335031997900350b163862443fd11c/sphinx_autodoc_future_annotations-0.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "c72de130af82c0d8a94939e4a5e22d8f", "sha256": "8ef8f4aed36aedd5364afea88f213c24819e5ff0be27ed38fd0a982451a73dfc" }, "downloads": -1, "filename": "sphinx_autodoc_future_annotations-0.1.1.tar.gz", "has_sig": false, "md5_digest": "c72de130af82c0d8a94939e4a5e22d8f", "packagetype": "sdist", "python_version": "source", "requires_python": ">= 3.7", "size": 5124, "upload_time": "2018-10-07T14:04:32", "url": "https://files.pythonhosted.org/packages/97/0b/f0970c690ed7f53f95e1b8fe535a962f986c738cfe8a02e9f99f4d3958c0/sphinx_autodoc_future_annotations-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "4ad07314b2eff926c21613981ce01256", "sha256": "d8da14b5ee99a926485bfb309c3cd4fd122915da1bd81be55bbe4b4668d9a5f6" }, "downloads": -1, "filename": "sphinx_autodoc_future_annotations-0.1.2-py3-none-any.whl", "has_sig": false, "md5_digest": "4ad07314b2eff926c21613981ce01256", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">= 3.7", "size": 5441, "upload_time": "2018-10-07T14:08:30", "url": "https://files.pythonhosted.org/packages/31/c5/5622fb8b056291c70542870a92e9bb230dcb0b6559a2132e8c056aa4430e/sphinx_autodoc_future_annotations-0.1.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "2fecb5585db792faa96b265a35083f47", "sha256": "badd3d813ff1edcd26ca9c9cf8188a3969d10f757facc9b9fb5c5231ffbfb8d5" }, "downloads": -1, "filename": "sphinx_autodoc_future_annotations-0.1.2.tar.gz", "has_sig": false, "md5_digest": "2fecb5585db792faa96b265a35083f47", "packagetype": "sdist", "python_version": "source", "requires_python": ">= 3.7", "size": 5113, "upload_time": "2018-10-07T14:08:32", "url": "https://files.pythonhosted.org/packages/8c/3a/982a68305a55d704a895c3513880108f89969f49ed617d59a441bcfef965/sphinx_autodoc_future_annotations-0.1.2.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "276cad63ffccad6bc46def55014e0df7", "sha256": "4c5c08d3bcc5a35953aa29cb233e9a0026f886caa936bf3bd05b957be21b55b8" }, "downloads": -1, "filename": "sphinx_autodoc_future_annotations-0.1.3-py3-none-any.whl", "has_sig": false, "md5_digest": "276cad63ffccad6bc46def55014e0df7", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">= 3.7", "size": 5449, "upload_time": "2018-10-07T14:15:21", "url": "https://files.pythonhosted.org/packages/13/b9/5e8c20aeaad4d41f30373b7fb9aec73fee1cff1479c277f54c4683d4d513/sphinx_autodoc_future_annotations-0.1.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "52c72d48c609736b8da31b2deea7b829", "sha256": "18850a66bcf2a0709e17abf4588c66ea7758f01c28922eedd31d79ab4264c08e" }, "downloads": -1, "filename": "sphinx_autodoc_future_annotations-0.1.3.tar.gz", "has_sig": false, "md5_digest": "52c72d48c609736b8da31b2deea7b829", "packagetype": "sdist", "python_version": "source", "requires_python": ">= 3.7", "size": 5127, "upload_time": "2018-10-07T14:15:22", "url": "https://files.pythonhosted.org/packages/d9/db/9f483bd2a6c7ed3e3a25cf3e19ceccfe9ca40f698ad345f9c131dc44b2f3/sphinx_autodoc_future_annotations-0.1.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "276cad63ffccad6bc46def55014e0df7", "sha256": "4c5c08d3bcc5a35953aa29cb233e9a0026f886caa936bf3bd05b957be21b55b8" }, "downloads": -1, "filename": "sphinx_autodoc_future_annotations-0.1.3-py3-none-any.whl", "has_sig": false, "md5_digest": "276cad63ffccad6bc46def55014e0df7", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">= 3.7", "size": 5449, "upload_time": "2018-10-07T14:15:21", "url": "https://files.pythonhosted.org/packages/13/b9/5e8c20aeaad4d41f30373b7fb9aec73fee1cff1479c277f54c4683d4d513/sphinx_autodoc_future_annotations-0.1.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "52c72d48c609736b8da31b2deea7b829", "sha256": "18850a66bcf2a0709e17abf4588c66ea7758f01c28922eedd31d79ab4264c08e" }, "downloads": -1, "filename": "sphinx_autodoc_future_annotations-0.1.3.tar.gz", "has_sig": false, "md5_digest": "52c72d48c609736b8da31b2deea7b829", "packagetype": "sdist", "python_version": "source", "requires_python": ">= 3.7", "size": 5127, "upload_time": "2018-10-07T14:15:22", "url": "https://files.pythonhosted.org/packages/d9/db/9f483bd2a6c7ed3e3a25cf3e19ceccfe9ca40f698ad345f9c131dc44b2f3/sphinx_autodoc_future_annotations-0.1.3.tar.gz" } ] }