From 1c644baee006c894f1f68b9bd813df3278321e52 Mon Sep 17 00:00:00 2001 From: Mark Walker Date: Wed, 26 Feb 2020 13:03:51 +0000 Subject: [PATCH] Add option for setup tools to build the docs Updated internal link in `setup.rst` --- docs/conf.py | 8 ++------ docs/setup.rst | 2 +- setup.py | 22 +++++++++++++++++++--- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 82edf86..e2d93a0 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -11,10 +11,6 @@ # All configuration values have a default; values that are commented out # serve to show the default. -import os -import sys - -from django_bleach import VERSION # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the @@ -51,9 +47,9 @@ # built documents. # # The short X.Y version. -version = '.'.join(VERSION[:2]) +# version = '0.6' # The full version, including alpha/beta/rc tags. -release = '.'.join(VERSION) +# release = '0.6.1' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/docs/setup.rst b/docs/setup.rst index 0a81604..0f3dcd8 100644 --- a/docs/setup.rst +++ b/docs/setup.rst @@ -15,7 +15,7 @@ Setup 3. Configure ``django_bleach``. It comes with some sensible defaults, but you will probably want to tweak the settings for your application. See the - :role:`settings` page for more information + :ref:`settings` page for more information 3. Add a ``django_bleach.models.BleachField`` to a model, a ``django_bleach.forms.BleachField`` to a form, or use the ``bleach`` diff --git a/setup.py b/setup.py index 412aa35..cd1f57c 100755 --- a/setup.py +++ b/setup.py @@ -6,6 +6,7 @@ from setuptools import setup, find_packages from setuptools.command.test import test as test_command +from sphinx.setup_command import BuildDoc class Tox(test_command): @@ -46,7 +47,9 @@ def find_variable(variable, *parts): raise RuntimeError("Unable to find version string.") -version = find_variable('__version__', 'django_bleach', '__init__.py') +name = 'django-bleach' +release = find_variable('__version__', 'django_bleach', '__init__.py') +version = release.rstrip('.') if sys.argv[-1] == 'build': os.system('python setup.py sdist bdist_wheel') @@ -61,7 +64,7 @@ def find_variable(variable, *parts): setup( - name='django-bleach', + name=name, version=version, description='Easily use bleach with Django models and templates', long_description=read('README.rst'), @@ -77,9 +80,22 @@ def find_variable(variable, *parts): tests_require=[ 'bleach>=1.5.0', 'mock', + 'sphinx', 'tox' ], - cmdclass={'test': Tox}, + cmdclass={ + 'build_sphinx': BuildDoc, + 'test': Tox + }, + command_options={ + 'build_sphinx': { + 'project': ('setup.py', name), + 'version': ('setup.py', version), + 'release': ('setup.py', release), + 'source_dir': ('setup.py', 'docs'), + 'build_dir': ('setup.py', './docs/_build') + } + }, package_data={}, classifiers=[ 'Environment :: Web Environment',