Skip to content

Commit

Permalink
Merge pull request #31 from matthewhughes934/generate-docs-from-pydocs
Browse files Browse the repository at this point in the history
Add a 'reference' documentation section
  • Loading branch information
piyueh committed Aug 5, 2021
2 parents 0458030 + 3219581 commit a7eb3b6
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 14 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,9 @@ jobs:
flags: py${{ matrix.python-version }}
fail_ci_if_error: true
verbose: true
- name: Install docs dependencies
working-directory: docs
run: pip install --requirement requirements.txt
- name: Build docs
working-directory: docs
run: make html
7 changes: 4 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))
import os
import sys
sys.path.insert(0, os.path.abspath('..'))


# -- Project information -----------------------------------------------------
Expand All @@ -31,6 +31,7 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
]

# Add any paths that contain templates here, relative to this directory.
Expand Down
4 changes: 4 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ Python threaded IMAP4 client module ``imaplib2``
:maxdepth: 2
:caption: Contents:

reference

.. contents:: :local:

This module defines a class, ``IMAP4``, which encapsulates a threaded
connection to an IMAP4 server and implements the IMAP4rev1 client
protocol as defined in RFC 3501 with several extensions. This module
Expand Down
4 changes: 4 additions & 0 deletions docs/reference.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Library Reference
=================

.. autofunction:: imaplib2.version
20 changes: 9 additions & 11 deletions imaplib2/imaplib2.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,17 +139,15 @@


def version(use_tuple=False):
"""Return the version of this module.
Arguments
---------
use_tuple : bool
Whether to return a string or a tuple of (major, minor). When True, the major and minor in the tuple will be
integers rather than strings.
Returns
-------
The version.
"""
Return the version of this module, either as a single string (the default) or a :class:`tuple`
of ``major_version, minor_version`` as integers
:param use_tuple: Whether to return :class:`tuple`
:type use_tuple: :class:`bool`
:return: The version of this library, the format depends on the value of ``use_tuple``
:rtype: (:class:`int`, :class:`int`) if ``use_tuple``
:rtype: :class:`str` otherwise
"""

if use_tuple:
Expand Down

0 comments on commit a7eb3b6

Please sign in to comment.