Skip to content

Commit

Permalink
Add support for spell checking and carry out initial corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
craigloftus committed Jul 23, 2019
1 parent fe983bf commit 3488808
Show file tree
Hide file tree
Showing 92 changed files with 767 additions and 521 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ language: python

addons:
postgresql: "9.6"
apt_packages:
- enchant

matrix:
fast_finish: true
Expand Down
3 changes: 3 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,6 @@ doctest:
$(SPHINXBUILD) -a -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
@echo "Testing of doctests in the sources finished, look at the " \
"results in $(BUILDDIR)/doctest/output.txt."

spelling:
$(SPHINXBUILD) -a -b spelling $(ALLSPHINXOPTS) $(BUILDDIR)/spelling
121 changes: 70 additions & 51 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,20 @@
# 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
# documentation root, use os.path.abspath to make it absolute, like shown here.
#sys.path.insert(0, os.path.abspath('.'))
# sys.path.insert(0, os.path.abspath('.'))

# Add the project root and sandbox root to the path
import sys
import inspect
import os
import sys

import django
from django.utils.encoding import force_text
from django.utils.html import strip_tags

from oscar import get_version, get_short_version


oscar_folder = os.path.realpath(
os.path.join(os.path.dirname(__file__), '../..'))
sandbox_folder = os.path.realpath(
Expand All @@ -29,13 +38,12 @@
# Specify settings module (which will be picked up from the sandbox)
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'settings_sphinx')

import django
django.setup()

# -- General configuration -----------------------------------------------------

# If your documentation needs a minimal Sphinx version, state it here.
#needs_sphinx = '1.0'
# needs_sphinx = '1.0'

# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
Expand All @@ -45,17 +53,22 @@
'sphinx.ext.coverage',
'sphinx.ext.viewcode',
'sphinxcontrib.napoleon',
'sphinxcontrib.spelling',
'sphinx_issues',
]

# Going with British English as the default because of history of the project
spelling_lang = "en_GB"
spelling_word_list_filename = "spelling_wordlist.txt"

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# The suffix of source filenames.
source_suffix = '.rst'

# The encoding of source files.
#source_encoding = 'utf-8-sig'
# source_encoding = 'utf-8-sig'

# The master toctree document.
master_doc = 'index'
Expand All @@ -68,43 +81,42 @@
# built documents.
#
# The short X.Y version.
from oscar import get_version, get_short_version
version = get_version()
release = get_short_version()

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#language = None
# language = None

# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
#today = ''
# today = ''
# Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y'
# today_fmt = '%B %d, %Y'

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = ['_draft']

# The reST default role (used for this markup: `text`) to use for all documents.
#default_role = None
# default_role = None

# If true, '()' will be appended to :func: etc. cross-reference text.
#add_function_parentheses = True
# add_function_parentheses = True

# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
#add_module_names = True
# add_module_names = True

# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
#show_authors = False
# show_authors = False

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'

# A list of ignored prefixes for module index sorting.
#modindex_common_prefix = []
# modindex_common_prefix = []

# Github repo for sphinx-issues
issues_github_path = 'django-oscar/django-oscar'
Expand All @@ -126,72 +138,72 @@
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#html_theme_options = {}
# html_theme_options = {}

# Add any paths that contain custom themes here, relative to this directory.
#html_theme_path = []
# html_theme_path = []

# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
#html_title = None
# html_title = None

# A shorter title for the navigation bar. Default is the same as html_title.
#html_short_title = None
# html_short_title = None

# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
#html_logo = None
# html_logo = None

# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
#html_favicon = None
# html_favicon = None

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
#html_static_path = ['_static']
# html_static_path = ['_static']

# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
#html_last_updated_fmt = '%b %d, %Y'
# html_last_updated_fmt = '%b %d, %Y'

# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
#html_use_smartypants = True
# html_use_smartypants = True

# Custom sidebar templates, maps document names to template names.
#html_sidebars = {}
# html_sidebars = {}

# Additional templates that should be rendered to pages, maps page names to
# template names.
#html_additional_pages = {}
# html_additional_pages = {}

# If false, no module index is generated.
#html_domain_indices = True
# html_domain_indices = True

# If false, no index is generated.
#html_use_index = True
# html_use_index = True

# If true, the index is split into individual pages for each letter.
#html_split_index = False
# html_split_index = False

# If true, links to the reST sources are added to the pages.
#html_show_sourcelink = True
# html_show_sourcelink = True

# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
#html_show_sphinx = True
# html_show_sphinx = True

# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
#html_show_copyright = True
# html_show_copyright = True

# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served.
#html_use_opensearch = ''
# html_use_opensearch = ''

# This is the file name suffix for HTML files (e.g. ".xhtml").
#html_file_suffix = None
# html_file_suffix = None

# Output file base name for HTML help builder.
htmlhelp_basename = 'django-oscardoc'
Expand All @@ -200,49 +212,59 @@
# -- Options for LaTeX output --------------------------------------------------

# The paper size ('letter' or 'a4').
#latex_paper_size = 'letter'
# latex_paper_size = 'letter'

# The font size ('10pt', '11pt' or '12pt').
#latex_font_size = '10pt'
# latex_font_size = '10pt'

# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('index', 'django-oscar.tex', 'django-oscar Documentation',
'David Winterbottom', 'manual'),
(
'index',
'django-oscar.tex',
'django-oscar Documentation',
'David Winterbottom',
'manual',
),
]

# The name of an image file (relative to this directory) to place at the top of
# the title page.
#latex_logo = None
# latex_logo = None

# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
#latex_use_parts = False
# latex_use_parts = False

# If true, show page references after internal links.
#latex_show_pagerefs = False
# latex_show_pagerefs = False

# If true, show URL addresses after external links.
#latex_show_urls = False
# latex_show_urls = False

# Additional stuff for the LaTeX preamble.
#latex_preamble = ''
# latex_preamble = ''

# Documents to append as an appendix to all manuals.
#latex_appendices = []
# latex_appendices = []

# If false, no module index is generated.
#latex_domain_indices = True
# latex_domain_indices = True


# -- Options for manual page output --------------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'django-oscar', 'django-oscar Documentation',
['David Winterbottom'], 1)
(
'index',
'django-oscar',
'django-oscar Documentation',
['David Winterbottom'],
1,
),
]

# Autodoc settings
Expand All @@ -251,10 +273,6 @@
# Better documenting of Django models
# See http://djangosnippets.org/snippets/2533/

import inspect
from django.utils.html import strip_tags
from django.utils.encoding import force_text


def process_docstring(app, what, name, obj, options, lines):
# This causes import errors if left outside the function
Expand All @@ -263,7 +281,7 @@ def process_docstring(app, what, name, obj, options, lines):
# Only look at objects that inherit from Django's base model class
if inspect.isclass(obj) and issubclass(obj, models.Model):

# Ignore abstract models
# Ignore abstract models
if not hasattr(obj._meta, '_fields'):
return lines

Expand Down Expand Up @@ -293,6 +311,7 @@ def process_docstring(app, what, name, obj, options, lines):
# Return the extended docstring
return lines


def setup(app):
# Register the docstring processor with sphinx
app.connect('autodoc-process-docstring', process_docstring)
8 changes: 4 additions & 4 deletions docs/source/howto/how_to_change_a_url.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ all Oscar URLs to your Django project, you only need to include the list of URLs
Changing sub apps
-----------------

App configs of sub apps such as the ``catalogue`` app are dynamically obtained
by looking them up in the Django app registry::
:py:class:`~django.apps.config.AppConfig` of sub apps such as the ``catalogue`` app are dynamically
obtained by looking them up in the Django app registry::

# oscar/config.py
from django.apps import apps
Expand Down Expand Up @@ -129,8 +129,8 @@ class and override the ``get_urls`` method::
# myproject/__init__.py
default_app_config = 'myproject.apps.MyShop'

As the root app config is hardcoded in your project's ``urls.py``, you need to
modify it to use your new app config instead of Oscar's default::
Then change ``urls.py`` to use your new :py:class:`~django.apps.config.AppConfig`
instead of Oscar's default::

# urls.py
from django.apps import apps
Expand Down
12 changes: 6 additions & 6 deletions docs/source/howto/how_to_create_a_custom_benefit.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ Oscar ships with several offer benefits for building offers. There are three
types:

* Basket discounts. These lead to a discount off the price of items in your
basket.
basket.

* Shipping discounts.
* Shipping discounts.

* Post-order actions. These are benefits that don't affect your order total but
trigger some action once the order is placed. For instance, if your site
supports loyalty points, you might create an offer that gives 200 points when
a certain product is bought.

Oscar also lets you create your own benefits for use in offers.
Oscar also lets you create your own benefits for use in offers.

Custom benefits
---------------
Expand Down Expand Up @@ -66,9 +66,9 @@ A benefit class must be a proxy class and have the following methods::
"""

As noted in the docstring, the ``apply`` method must return an instance of
``oscar.apps.offer.models.ApplicationResult``. There are three subtypes
``oscar.apps.offer.models.ApplicationResult``. There are three subclasses
provided:

* ``oscar.apps.offer.models.BasketDiscount``. This takes an amount as it's
constructor parameter.

Expand All @@ -89,7 +89,7 @@ Here's an example of a post-order action benefit::

class Meta:
proxy = True

name = description = "Changes customer's name"

def apply(self, basket, condition, offer):
Expand Down
Loading

0 comments on commit 3488808

Please sign in to comment.