From 6f5571037e2310e86134872fd9a411618f253f23 Mon Sep 17 00:00:00 2001 From: Martin Majlis Date: Mon, 3 Jul 2017 11:45:34 +0200 Subject: [PATCH] Another set of improvements for documentation generation. --- .gitignore | 5 +++++ API.rst | 8 ++++++++ CHANGES.rst | 10 ++++++++++ Makefile | 3 +++ README.rst | 6 ++++++ conf.py | 10 +++++----- mailgunv3/__init__.py | 4 ++++ setup.py | 18 +++++++++++------- 8 files changed, 52 insertions(+), 12 deletions(-) create mode 100644 API.rst create mode 100644 CHANGES.rst diff --git a/.gitignore b/.gitignore index 7bbc71c..e449107 100644 --- a/.gitignore +++ b/.gitignore @@ -99,3 +99,8 @@ ENV/ # mypy .mypy_cache/ + +# documentation +pypi-doc.html +_build/ + diff --git a/API.rst b/API.rst new file mode 100644 index 0000000..1bde051 --- /dev/null +++ b/API.rst @@ -0,0 +1,8 @@ + +API +--- + +.. automodule:: mailgunv3 + +.. autoclass:: MailGunV3 + :members: diff --git a/CHANGES.rst b/CHANGES.rst new file mode 100644 index 0000000..a4b9f3c --- /dev/null +++ b/CHANGES.rst @@ -0,0 +1,10 @@ +Changelog +====================== + +0.2 +--- +* Playing with documentation + +0.1 +--- +* Initial commit diff --git a/Makefile b/Makefile index ad08a53..68120bf 100644 --- a/Makefile +++ b/Makefile @@ -14,6 +14,9 @@ help: .PHONY: help Makefile +pypi-html: + python setup.py --long-description | rst2html.py > pypi-doc.html + # Catch-all target: route all unknown targets to Sphinx using the new # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). %: Makefile diff --git a/README.rst b/README.rst index 50bccf1..d64edf4 100644 --- a/README.rst +++ b/README.rst @@ -7,9 +7,14 @@ This package provides fluent API for `MailGun API`_. |build-status| |docs| |cc-badge| |cc-issues| +.. PYPI-BEGIN .. toctree:: :maxdepth: 2 + CHANGES + API +.. PYPI-END + Installation ------------ @@ -104,3 +109,4 @@ External Links :target: https://codeclimate.com/github/martin-majlis/MailGunV3 :alt: Issue Count + diff --git a/conf.py b/conf.py index 821763c..2fbf677 100644 --- a/conf.py +++ b/conf.py @@ -17,9 +17,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('mailgunv3')) # -- General configuration ------------------------------------------------ @@ -31,7 +31,7 @@ # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. -extensions = [] +extensions = ['sphinx.ext.autodoc'] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] @@ -57,7 +57,7 @@ # The short X.Y version. version = '0.2' # The full version, including alpha/beta/rc tags. -release = '0.2.2' +release = '0.2.4' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/mailgunv3/__init__.py b/mailgunv3/__init__.py index 5954e51..11d64ff 100644 --- a/mailgunv3/__init__.py +++ b/mailgunv3/__init__.py @@ -13,6 +13,10 @@ class MailGunV3(object): + """ + This is the only class that should be directly initialized. + """ + def __init__(self, domain, private_key, public_key): self.domain = domain self.private_key = private_key diff --git a/setup.py b/setup.py index b60f46a..88cce70 100644 --- a/setup.py +++ b/setup.py @@ -1,12 +1,16 @@ import os +import re from setuptools import setup, find_packages -#here = os.path.abspath(os.path.dirname(__file__)) -# with open(os.path.join(here, 'README.txt')) as f: -# README = f.read() -# with open(os.path.join(here, 'CHANGES.txt')) as f: -# CHANGES = f.read() +def fix_doc(txt): + return re.sub(r'\.\. PYPI-BEGIN([\r\n]|.)*?PYPI-END', '', txt, re.DOTALL) + +with open('README.rst') as fileR: + README = fix_doc(fileR.read()) + +with open('CHANGES.rst') as fileC: + CHANGES = fix_doc(fileC.read()) requires = [ 'requests', @@ -16,9 +20,9 @@ setup( name='MailGunV3', - version='0.2.2', + version='0.2.4', description='Python wrapper for Mailgun REST API.', - #long_description=README + '\n\n' + CHANGES, + long_description=README + '\n\n' + CHANGES, classifiers=[ 'Programming Language :: Python', ],