Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add auto-generated API documention #810

Merged
merged 6 commits into from Sep 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/main.yml
Expand Up @@ -63,7 +63,8 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.8
# Mininum supported Python version
python-version: 3.6
- name: Install dependencies
run: python -m pip install tox
- name: Build docs
Expand Down
3 changes: 2 additions & 1 deletion .readthedocs.yaml
Expand Up @@ -14,7 +14,8 @@ formats:
- epub

python:
version: 3.8
# Mininum supported Python version
version: "3.6"
install:
- requirements: docs/requirements.txt
- method: pip
Expand Down
21 changes: 21 additions & 0 deletions docs/conf.py
Expand Up @@ -272,10 +272,31 @@
"https://github.com/pypa/twine/issues/*",
# Avoid errors from channels interpreted as anchors
"https://web.libera.chat/#",
# Avoid error from InvalidPyPIUploadURL docstring
"https://upload.pypi.org/legacy",
]

# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {"https://docs.python.org/": None}

# Be strict about the invalid references:
nitpicky = True

# TODO: Try to add these to intersphinx_mapping
nitpick_ignore_regex = [
(r"py:.*", r"(pkginfo|requests|IO).*"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why can't we add the intersphinx mapping for requests? It should be as simple as updating 280 to be

{
  "python": ("https://docs.python.org/", None),
  "requests": ("https://requests.readthedocs.io/", None),
}

See also: https://www.sphinx-doc.org/en/master/usage/extensions/intersphinx.html

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried that, via:

intersphinx_mapping = {
    "python": ("https://docs.python.org/", None),
    "requests": ("https://docs.python-requests.org/en/latest/", None),
}

But it's not entirely working:

WARNING: py:class reference target not found: requests.models.Response

Via intersphinx-untangled, it seems that the documented reference is the public requests.Response, and even though that's the type hint, it's being resolved to the internal class definition.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why can't we just use requests.models.Response? It's documented as that in the docs. Most people use requests.Response because the author wanted to re-export the world which was a bad idea anyway

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why can't we just use requests.models.Response? It's documented as that in the docs.

Where do you see it documented that way? I only see https://docs.python-requests.org/en/master/api/#requests.Response.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went down the rabbit hole on this, with the end result being sphinx-doc/sphinx#9653.

]

# -- Options for apidoc output ------------------------------------------------

autodoc_default_options = {
"members": True,
"private-members": True,
bhrutledge marked this conversation as resolved.
Show resolved Hide resolved
"undoc-members": True,
"member-order": "bysource",
}

autodoc_class_signature = "separated"
autodoc_preserve_defaults = True
# autodoc_typehints = "both"
# autodoc_typehints_description_target = "documented"
7 changes: 7 additions & 0 deletions docs/contributing.rst
Expand Up @@ -211,6 +211,13 @@ specify either as a default, in the :file:`.pypirc` file, or pass on
the command line), and the methods that upload the package securely to
a URL.

For more details, refer to the source documentation (currently a
`work in progress <https://github.com/pypa/twine/issues/635>`_):

.. toctree::

internal/twine

bhrutledge marked this conversation as resolved.
Show resolved Hide resolved
Where Twine gets configuration and credentials
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Expand Down
4 changes: 4 additions & 0 deletions docs/internal/twine.auth.rst
@@ -0,0 +1,4 @@
twine.auth module
=================

.. automodule:: twine.auth
4 changes: 4 additions & 0 deletions docs/internal/twine.cli.rst
@@ -0,0 +1,4 @@
twine.cli module
================

.. automodule:: twine.cli
4 changes: 4 additions & 0 deletions docs/internal/twine.commands.check.rst
@@ -0,0 +1,4 @@
twine.commands.check module
===========================

.. automodule:: twine.commands.check
4 changes: 4 additions & 0 deletions docs/internal/twine.commands.register.rst
@@ -0,0 +1,4 @@
twine.commands.register module
==============================

.. automodule:: twine.commands.register
11 changes: 11 additions & 0 deletions docs/internal/twine.commands.rst
@@ -0,0 +1,11 @@
twine.commands package
======================

.. automodule:: twine.commands

.. toctree::
:maxdepth: 4

twine.commands.check
twine.commands.register
twine.commands.upload
4 changes: 4 additions & 0 deletions docs/internal/twine.commands.upload.rst
@@ -0,0 +1,4 @@
twine.commands.upload module
============================

.. automodule:: twine.commands.upload
4 changes: 4 additions & 0 deletions docs/internal/twine.exceptions.rst
@@ -0,0 +1,4 @@
twine.exceptions module
=======================

.. automodule:: twine.exceptions
4 changes: 4 additions & 0 deletions docs/internal/twine.package.rst
@@ -0,0 +1,4 @@
twine.package module
====================

.. automodule:: twine.package
4 changes: 4 additions & 0 deletions docs/internal/twine.repository.rst
@@ -0,0 +1,4 @@
twine.repository module
=======================

.. automodule:: twine.repository
18 changes: 18 additions & 0 deletions docs/internal/twine.rst
@@ -0,0 +1,18 @@
twine package
=============

.. automodule:: twine

.. toctree::
:maxdepth: 4

twine.commands
twine.auth
twine.cli
twine.exceptions
twine.package
twine.repository
twine.settings
twine.utils
twine.wheel
twine.wininst
4 changes: 4 additions & 0 deletions docs/internal/twine.settings.rst
@@ -0,0 +1,4 @@
twine.settings module
=====================

.. automodule:: twine.settings
4 changes: 4 additions & 0 deletions docs/internal/twine.utils.rst
@@ -0,0 +1,4 @@
twine.utils module
==================

.. automodule:: twine.utils
4 changes: 4 additions & 0 deletions docs/internal/twine.wheel.rst
@@ -0,0 +1,4 @@
twine.wheel module
==================

.. automodule:: twine.wheel
4 changes: 4 additions & 0 deletions docs/internal/twine.wininst.rst
@@ -0,0 +1,4 @@
twine.wininst module
====================

.. automodule:: twine.wininst
3 changes: 2 additions & 1 deletion tox.ini
Expand Up @@ -43,7 +43,8 @@ deps =
-rdocs/requirements.txt
sphinx-autobuild
commands =
sphinx-autobuild -W -b html -d {envtmpdir}/doctrees \
sphinx-autobuild -b html -d {envtmpdir}/doctrees \
--watch twine \
{posargs:--host 127.0.0.1} \
docs docs/_build/html

Expand Down
5 changes: 5 additions & 0 deletions twine/__init__.py
@@ -1,3 +1,8 @@
"""Top-level module for Twine.

The contents of this package are not a public API. For more details, see
https://github.com/pypa/twine/issues/194 and https://github.com/pypa/twine/issues/665.
"""
# Copyright 2018 Donald Stufft and individual contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down