autodoc-traits


Nameautodoc-traits JSON
Version 1.2.2 PyPI version JSON
download
home_pageNone
SummarySphinx extension to autodoc traitlets
upload_time2024-04-17 09:40:44
maintainerNone
docs_urlNone
authorNone
requires_python>=3.7
licenseBSD 3-Clause License Copyright (c) Project Jupyter Contributors All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
keywords autodoc extension sphinx traitlets
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # autodoc-traits

[![Latest PyPI version](https://img.shields.io/pypi/v/autodoc-traits?logo=pypi)](https://pypi.python.org/pypi/autodoc-traits)
[![GitHub](https://img.shields.io/badge/issue_tracking-github-blue?logo=github)](https://github.com/jupyterhub/autodoc-traits/issues)
[![Discourse](https://img.shields.io/badge/help_forum-discourse-blue?logo=discourse)](https://discourse.jupyter.org/c/jupyterhub)
[![Gitter](https://img.shields.io/badge/social_chat-gitter-blue?logo=gitter)](https://gitter.im/jupyterhub/jupyterhub)

`autodoc-traits` is a Sphinx extension that builds on [`sphinx.ext.autodoc`][]
to better document classes with [Traitlets][] based configuration.
`autodoc-traits` provides the [Sphinx directives][] `autoconfigurable` (use with
classes) and `autotrait` (use with the traitlets based configuration options).

The `sphinx.ext.autodoc` provided directive [`automodule`][], which can overview
classes, will with `autodoc-traits` enabled use `autoconfigurable` over
[`autoclass`][] for classes has trait based configuration. Similarly, the
`sphinx.ext.autodoc` provided `autoclass` directive will use `autotrait` over
[`autoattribute`][] if configured to present the traitlets attributes normally
not presented.

The `autoattribute` directive will provide a header looking like `trait
c.SampleConfigurable.trait = Bool(False)`, and as docstring it will use the
trait's configured help text.

## How to use it

1. Install `autodoc-traits`:

   ```shell
   pip install autodoc-traits
   ```

2. Configure Sphinx to use the `autodoc_traits` extensions in a Sphinx project's
   `conf.py` file:

   ```python
   # -- General Sphinx configuration --------------------------------------------
   # ref: https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
   #
   extensions = [
       "autodoc_traits",
       # sphinx.ext.autodoc will be registered by autodoc_traits,
       # but can safely be registered again.
       # ...
   ]
   ```

3. Make use of the `sphinx.ext.autodoc` Sphinx directive like `automodule` that
   document classes, the `autodoc_traits` provided `autoconfigurable` that
   documents traitlets configurable classes, or the `autodoc_traits` provided
   `autotrait` that documents individual traitlets configuration options:

   From a .rst document:

   ```rst
   .. automodule:: sample_module
      :members:

   .. autoconfigurable:: sample_module.SampleConfigurable

   .. autotrait:: sample_module.SampleConfigurable.trait
   ```

## Use with MyST Parser

While you can use [`myst-parser`][], `sphinx.ext.autodoc`'s directives emits
unparsed rST, forcing us to parse the autodoc directives in a rST context.

From a .md document, with `myst-parser`:

````markdown
```{eval-rst}
.. autoconfigurable:: sample_module.SampleConfigurable
```
````

Due to this, also the Python docstrings are required to be in rST as well.
Addressing this can be tracked from [executablebooks/team-compass issue
#6](https://github.com/executablebooks/team-compass/issues/6).

[`sphinx.ext.autodoc`]: https://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html
[sphinx directives]: https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html#directives
[`autoclass`]: https://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html#directive-autoclass
[`autoattribute`]: https://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html#directive-autoattribute
[traitlets]: https://github.com/ipython/traitlets
[`traitlets.traittype`]: https://traitlets.readthedocs.io/en/stable/trait_types.html#traitlets.TraitType
[`myst-parser`]: https://myst-parser.readthedocs.io/en/latest/

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "autodoc-traits",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "autodoc, extension, sphinx, traitlets",
    "author": null,
    "author_email": "Jupyter Development Team <jupyter@googlegroups.com>",
    "download_url": "https://files.pythonhosted.org/packages/26/ca/8837edecbfa7ca4640a063249422ca5b1431694d3d7f1b06be8879fce498/autodoc_traits-1.2.2.tar.gz",
    "platform": null,
    "description": "# autodoc-traits\n\n[![Latest PyPI version](https://img.shields.io/pypi/v/autodoc-traits?logo=pypi)](https://pypi.python.org/pypi/autodoc-traits)\n[![GitHub](https://img.shields.io/badge/issue_tracking-github-blue?logo=github)](https://github.com/jupyterhub/autodoc-traits/issues)\n[![Discourse](https://img.shields.io/badge/help_forum-discourse-blue?logo=discourse)](https://discourse.jupyter.org/c/jupyterhub)\n[![Gitter](https://img.shields.io/badge/social_chat-gitter-blue?logo=gitter)](https://gitter.im/jupyterhub/jupyterhub)\n\n`autodoc-traits` is a Sphinx extension that builds on [`sphinx.ext.autodoc`][]\nto better document classes with [Traitlets][] based configuration.\n`autodoc-traits` provides the [Sphinx directives][] `autoconfigurable` (use with\nclasses) and `autotrait` (use with the traitlets based configuration options).\n\nThe `sphinx.ext.autodoc` provided directive [`automodule`][], which can overview\nclasses, will with `autodoc-traits` enabled use `autoconfigurable` over\n[`autoclass`][] for classes has trait based configuration. Similarly, the\n`sphinx.ext.autodoc` provided `autoclass` directive will use `autotrait` over\n[`autoattribute`][] if configured to present the traitlets attributes normally\nnot presented.\n\nThe `autoattribute` directive will provide a header looking like `trait\nc.SampleConfigurable.trait = Bool(False)`, and as docstring it will use the\ntrait's configured help text.\n\n## How to use it\n\n1. Install `autodoc-traits`:\n\n   ```shell\n   pip install autodoc-traits\n   ```\n\n2. Configure Sphinx to use the `autodoc_traits` extensions in a Sphinx project's\n   `conf.py` file:\n\n   ```python\n   # -- General Sphinx configuration --------------------------------------------\n   # ref: https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration\n   #\n   extensions = [\n       \"autodoc_traits\",\n       # sphinx.ext.autodoc will be registered by autodoc_traits,\n       # but can safely be registered again.\n       # ...\n   ]\n   ```\n\n3. Make use of the `sphinx.ext.autodoc` Sphinx directive like `automodule` that\n   document classes, the `autodoc_traits` provided `autoconfigurable` that\n   documents traitlets configurable classes, or the `autodoc_traits` provided\n   `autotrait` that documents individual traitlets configuration options:\n\n   From a .rst document:\n\n   ```rst\n   .. automodule:: sample_module\n      :members:\n\n   .. autoconfigurable:: sample_module.SampleConfigurable\n\n   .. autotrait:: sample_module.SampleConfigurable.trait\n   ```\n\n## Use with MyST Parser\n\nWhile you can use [`myst-parser`][], `sphinx.ext.autodoc`'s directives emits\nunparsed rST, forcing us to parse the autodoc directives in a rST context.\n\nFrom a .md document, with `myst-parser`:\n\n````markdown\n```{eval-rst}\n.. autoconfigurable:: sample_module.SampleConfigurable\n```\n````\n\nDue to this, also the Python docstrings are required to be in rST as well.\nAddressing this can be tracked from [executablebooks/team-compass issue\n#6](https://github.com/executablebooks/team-compass/issues/6).\n\n[`sphinx.ext.autodoc`]: https://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html\n[sphinx directives]: https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html#directives\n[`autoclass`]: https://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html#directive-autoclass\n[`autoattribute`]: https://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html#directive-autoattribute\n[traitlets]: https://github.com/ipython/traitlets\n[`traitlets.traittype`]: https://traitlets.readthedocs.io/en/stable/trait_types.html#traitlets.TraitType\n[`myst-parser`]: https://myst-parser.readthedocs.io/en/latest/\n",
    "bugtrack_url": null,
    "license": "BSD 3-Clause License  Copyright (c) Project Jupyter Contributors All rights reserved.  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:  * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.  * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.  * Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.",
    "summary": "Sphinx extension to autodoc traitlets",
    "version": "1.2.2",
    "project_urls": {
        "Documentation": "https://github.com/jupyterhub/autodoc-traits#readme",
        "Issues": "https://github.com/jupyterhub/autodoc-traits/issues",
        "Source": "https://github.com/jupyterhub/autodoc-traits"
    },
    "split_keywords": [
        "autodoc",
        " extension",
        " sphinx",
        " traitlets"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d05cc88609bd486d570ba581cc8a2dfbf7df1a7b52f96159a648c56840aa844a",
                "md5": "9c708e24b18fa8f2531d4f1de3cf52cb",
                "sha256": "f26c5e942745c3b8c5350bfdaac409fe531aca2b4639a4daaaad398e9592a1a1"
            },
            "downloads": -1,
            "filename": "autodoc_traits-1.2.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9c708e24b18fa8f2531d4f1de3cf52cb",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 7357,
            "upload_time": "2024-04-17T09:40:43",
            "upload_time_iso_8601": "2024-04-17T09:40:43.164154Z",
            "url": "https://files.pythonhosted.org/packages/d0/5c/c88609bd486d570ba581cc8a2dfbf7df1a7b52f96159a648c56840aa844a/autodoc_traits-1.2.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "26ca8837edecbfa7ca4640a063249422ca5b1431694d3d7f1b06be8879fce498",
                "md5": "3bd9b12fb6ea5276b2010ef371e91b21",
                "sha256": "a42bc8a78fe95cffb84bdb30b301368347442666ae6f9543304c566761d6a91c"
            },
            "downloads": -1,
            "filename": "autodoc_traits-1.2.2.tar.gz",
            "has_sig": false,
            "md5_digest": "3bd9b12fb6ea5276b2010ef371e91b21",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 16537,
            "upload_time": "2024-04-17T09:40:44",
            "upload_time_iso_8601": "2024-04-17T09:40:44.896601Z",
            "url": "https://files.pythonhosted.org/packages/26/ca/8837edecbfa7ca4640a063249422ca5b1431694d3d7f1b06be8879fce498/autodoc_traits-1.2.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-17 09:40:44",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "jupyterhub",
    "github_project": "autodoc-traits#readme",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "autodoc-traits"
}
        
Elapsed time: 0.24536s