[Python-modules-commits] [straight.plugin] 01/04: Imported Upstream version 1.4.1

Sergio Durigan Junior sergiodj-guest at moszumanska.debian.org
Fri Jul 1 22:42:50 UTC 2016


This is an automated email from the git hooks/post-receive script.

sergiodj-guest pushed a commit to branch master
in repository straight.plugin.

commit 1d29a6e9a9a877768d5b19fe18bb06e5ab481445
Author: Sergio Durigan Junior <sergiodj at sergiodj.net>
Date:   Fri Jul 1 18:33:30 2016 -0400

    Imported Upstream version 1.4.1
---
 .gitignore                                         |   2 +
 AUTHORS                                            |   3 +
 LICENSE                                            |  19 ++
 MANIFEST.in                                        |   6 +
 README.rst                                         |  46 ++++
 docs/Makefile                                      | 153 ++++++++++++
 docs/api.rst                                       |  19 ++
 docs/conf.py                                       | 244 ++++++++++++++++++
 docs/getting-started.rst                           | 117 +++++++++
 docs/glossary.rst                                  |  45 ++++
 docs/index.rst                                     |  82 +++++++
 docs/loaders.rst                                   |  85 +++++++
 docs/make.bat                                      | 190 ++++++++++++++
 docs/write-plugin.rst                              |  96 ++++++++
 requirements-dev.txt                               |   1 +
 setup.py                                           |  26 ++
 straight/__init__.py                               |   1 +
 straight/plugin/__init__.py                        |   4 +
 straight/plugin/loaders.py                         | 173 +++++++++++++
 straight/plugin/manager.py                         |  62 +++++
 .../class-test-plugins/testplugin/__init__.py      |   2 +
 .../class-test-plugins/testplugin/testclasses.py   |  10 +
 test-packages/imply-plugins/testplugin/__init__.py |   2 +
 test-packages/imply-plugins/testplugin/foo.py      |   7 +
 .../imply-plugins/testplugin_2/__init__.py         |   2 +
 test-packages/imply-plugins/testplugin_2/bar.py    |   2 +
 .../more-test-plugins/testplugin/__init__.py       |   2 +
 test-packages/more-test-plugins/testplugin/bar.py  |   2 +
 .../package-test-plugins/testplugin/__init__.py    |   2 +
 .../testplugin/bar/__init__.py                     |   2 +
 .../testplugin/baz/__init__.py                     |   2 +
 .../testplugin/baz/quu/__init__.py                 |   2 +
 .../testplugin/foo/__init__.py                     |   2 +
 test-packages/pep-420-plugins/testplugin/foo.py    |   2 +
 .../some-test-plugins/testplugin/__init__.py       |   2 +
 test-packages/some-test-plugins/testplugin/foo.py  |   2 +
 tests.py                                           | 273 +++++++++++++++++++++
 tox.ini                                            |  10 +
 38 files changed, 1702 insertions(+)

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..a52592e
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+*.py[co]
+*.swp
diff --git a/AUTHORS b/AUTHORS
new file mode 100644
index 0000000..da8a014
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,3 @@
+Calvin Spealman ironfroggy at gmail.com @ironfroggy http://github.com/ironfroggy
+Dustin Lacewell dlacewell at gmail.com @dustinlacewell http://github.com/dustinlacewell
+Erik Youngren artanis.00 at gmail.com http://artanis00.blogspot.com/ http://github.com/Artanis
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..b151070
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,19 @@
+Copyright (C) 2011 by Calvin Spealman (ironfroggy at gmail.com)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/MANIFEST.in b/MANIFEST.in
new file mode 100644
index 0000000..9eb9910
--- /dev/null
+++ b/MANIFEST.in
@@ -0,0 +1,6 @@
+include README.rst
+include LICENSE
+include AUTHORS
+include tests.py
+graft test-packages
+graft doc
diff --git a/README.rst b/README.rst
new file mode 100644
index 0000000..ad543ec
--- /dev/null
+++ b/README.rst
@@ -0,0 +1,46 @@
+Full Documentation: http://readthedocs.org/docs/straightplugin/
+Mailing List: https://groups.google.com/forum/#!forum/straight.plugin
+
+Straight Plugin is very easy.
+
+Straight Plugin provides a type of plugin you can create
+from almost any existing Python modules, and an easy way for outside developers
+to add functionality and customization to your projects with their own
+plugins.
+
+Using any available plugins is a snap.
+
+::
+
+    from straight.plugin import load
+
+    plugins = load('theproject.plugins', subclasses=FileHandler)
+
+    handlers = plugins.produce()
+    for line in open(filename):
+        print handlers.pipe(line)
+
+
+And, writing plugins is just as easy.
+
+::
+
+    from theproject import FileHandler
+
+    class LineNumbers(FileHandler):
+        def __init__(self):
+            self.lineno = 0
+        def pipe(line):
+            self.lineno += 1
+            return "%04d %s" % (self.lineno, line)
+
+Plugins are found from a :term:`namespace`, which means the above example
+would find any ``FileHandler`` classes defined in modules you might import
+as ``theproject.plugins.default`` or ``theproject.plugins.extra``. Through
+the magic of :term:`namespace packages <namespace package>`, we can even
+split these up into separate installations, even managed by different teams.
+This means you can ship a project with a set of default plugins implementing
+its behavior, and allow other projects to hook in new functionality simply
+by shipping their own plugins under the same :term:`namespace`.
+
+:doc:`Get started and learn more, today <getting-started>`
diff --git a/docs/Makefile b/docs/Makefile
new file mode 100644
index 0000000..47228f3
--- /dev/null
+++ b/docs/Makefile
@@ -0,0 +1,153 @@
+# Makefile for Sphinx documentation
+#
+
+# You can set these variables from the command line.
+SPHINXOPTS    =
+SPHINXBUILD   = sphinx-build
+PAPER         =
+BUILDDIR      = _build
+
+# Internal variables.
+PAPEROPT_a4     = -D latex_paper_size=a4
+PAPEROPT_letter = -D latex_paper_size=letter
+ALLSPHINXOPTS   = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
+# the i18n builder cannot share the environment and doctrees with the others
+I18NSPHINXOPTS  = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
+
+.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
+
+help:
+	@echo "Please use \`make <target>' where <target> is one of"
+	@echo "  html       to make standalone HTML files"
+	@echo "  dirhtml    to make HTML files named index.html in directories"
+	@echo "  singlehtml to make a single large HTML file"
+	@echo "  pickle     to make pickle files"
+	@echo "  json       to make JSON files"
+	@echo "  htmlhelp   to make HTML files and a HTML help project"
+	@echo "  qthelp     to make HTML files and a qthelp project"
+	@echo "  devhelp    to make HTML files and a Devhelp project"
+	@echo "  epub       to make an epub"
+	@echo "  latex      to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
+	@echo "  latexpdf   to make LaTeX files and run them through pdflatex"
+	@echo "  text       to make text files"
+	@echo "  man        to make manual pages"
+	@echo "  texinfo    to make Texinfo files"
+	@echo "  info       to make Texinfo files and run them through makeinfo"
+	@echo "  gettext    to make PO message catalogs"
+	@echo "  changes    to make an overview of all changed/added/deprecated items"
+	@echo "  linkcheck  to check all external links for integrity"
+	@echo "  doctest    to run all doctests embedded in the documentation (if enabled)"
+
+clean:
+	-rm -rf $(BUILDDIR)/*
+
+html:
+	$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
+	@echo
+	@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
+
+dirhtml:
+	$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
+	@echo
+	@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
+
+singlehtml:
+	$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
+	@echo
+	@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
+
+pickle:
+	$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
+	@echo
+	@echo "Build finished; now you can process the pickle files."
+
+json:
+	$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
+	@echo
+	@echo "Build finished; now you can process the JSON files."
+
+htmlhelp:
+	$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
+	@echo
+	@echo "Build finished; now you can run HTML Help Workshop with the" \
+	      ".hhp project file in $(BUILDDIR)/htmlhelp."
+
+qthelp:
+	$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
+	@echo
+	@echo "Build finished; now you can run "qcollectiongenerator" with the" \
+	      ".qhcp project file in $(BUILDDIR)/qthelp, like this:"
+	@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/straightplugin.qhcp"
+	@echo "To view the help file:"
+	@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/straightplugin.qhc"
+
+devhelp:
+	$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
+	@echo
+	@echo "Build finished."
+	@echo "To view the help file:"
+	@echo "# mkdir -p $$HOME/.local/share/devhelp/straightplugin"
+	@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/straightplugin"
+	@echo "# devhelp"
+
+epub:
+	$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
+	@echo
+	@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
+
+latex:
+	$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+	@echo
+	@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
+	@echo "Run \`make' in that directory to run these through (pdf)latex" \
+	      "(use \`make latexpdf' here to do that automatically)."
+
+latexpdf:
+	$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+	@echo "Running LaTeX files through pdflatex..."
+	$(MAKE) -C $(BUILDDIR)/latex all-pdf
+	@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
+
+text:
+	$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
+	@echo
+	@echo "Build finished. The text files are in $(BUILDDIR)/text."
+
+man:
+	$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
+	@echo
+	@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
+
+texinfo:
+	$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
+	@echo
+	@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
+	@echo "Run \`make' in that directory to run these through makeinfo" \
+	      "(use \`make info' here to do that automatically)."
+
+info:
+	$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
+	@echo "Running Texinfo files through makeinfo..."
+	make -C $(BUILDDIR)/texinfo info
+	@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
+
+gettext:
+	$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
+	@echo
+	@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
+
+changes:
+	$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
+	@echo
+	@echo "The overview file is in $(BUILDDIR)/changes."
+
+linkcheck:
+	$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
+	@echo
+	@echo "Link check complete; look for any errors in the above output " \
+	      "or in $(BUILDDIR)/linkcheck/output.txt."
+
+doctest:
+	$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
+	@echo "Testing of doctests in the sources finished, look at the " \
+	      "results in $(BUILDDIR)/doctest/output.txt."
diff --git a/docs/api.rst b/docs/api.rst
new file mode 100644
index 0000000..a10752f
--- /dev/null
+++ b/docs/api.rst
@@ -0,0 +1,19 @@
+Straight Plugin API
+===================
+
+Loaders
+#######
+
+.. autofunction:: straight.plugin.loaders.unified_load
+.. autoclass:: straight.plugin.loaders.Loader
+.. autoclass:: straight.plugin.loaders.ModuleLoader
+.. autoclass:: straight.plugin.loaders.ObjectLoader
+.. autoclass:: straight.plugin.loaders.ClassLoader
+
+.. _api-plugin-manager:
+
+PluginManager
+#############
+
+.. autoclass:: straight.plugin.manager.PluginManager
+   :members: produce, call, first, pipe,
diff --git a/docs/conf.py b/docs/conf.py
new file mode 100644
index 0000000..2c172e0
--- /dev/null
+++ b/docs/conf.py
@@ -0,0 +1,244 @@
+# -*- coding: utf-8 -*-
+#
+# straight.plugin documentation build configuration file, created by
+# sphinx-quickstart on Wed Jan 25 22:49:22 2012.
+#
+# This file is execfile()d with the current directory set to its containing dir.
+#
+# Note that not all possible configuration values are present in this
+# autogenerated file.
+#
+# All configuration values have a default; values that are commented out
+# serve to show the default.
+
+import sys, os
+
+# 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('.'))
+
+# -- General configuration -----------------------------------------------------
+
+# If your documentation needs a minimal Sphinx version, state it here.
+#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.
+extensions = [
+    'sphinx.ext.autodoc',
+]
+
+# 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'
+
+# The master toctree document.
+master_doc = 'index'
+
+# General information about the project.
+project = u'straight.plugin'
+copyright = u'2012, Calvin Spealman'
+
+# The version info for the project you're documenting, acts as replacement for
+# |version| and |release|, also used in various other places throughout the
+# built documents.
+#
+# The short X.Y version.
+version = '1.4'
+# The full version, including alpha/beta/rc tags.
+release = '1.4.0'
+
+# The language for content autogenerated by Sphinx. Refer to documentation
+# for a list of supported languages.
+#language = None
+
+# There are two options for replacing |today|: either, you set today to some
+# non-false value, then it is used:
+#today = ''
+# Else, today_fmt is used as the format for a strftime call.
+#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 = ['_build']
+
+# The reST default role (used for this markup: `text`) to use for all documents.
+#default_role = None
+
+# If true, '()' will be appended to :func: etc. cross-reference text.
+#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
+
+# If true, sectionauthor and moduleauthor directives will be shown in the
+# output. They are ignored by default.
+#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 = []
+
+
+# -- Options for HTML output ---------------------------------------------------
+
+# The theme to use for HTML and HTML Help pages.  See the documentation for
+# a list of builtin themes.
+html_theme = 'default'
+
+# 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 = {}
+
+# Add any paths that contain custom themes here, relative to this directory.
+#html_theme_path = []
+
+# The name for this set of Sphinx documents.  If None, it defaults to
+# "<project> v<release> documentation".
+#html_title = None
+
+# A shorter title for the navigation bar.  Default is the same as html_title.
+#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
+
+# 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
+
+# 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']
+
+# 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'
+
+# If true, SmartyPants will be used to convert quotes and dashes to
+# typographically correct entities.
+#html_use_smartypants = True
+
+# Custom sidebar templates, maps document names to template names.
+#html_sidebars = {}
+
+# Additional templates that should be rendered to pages, maps page names to
+# template names.
+#html_additional_pages = {}
+
+# If false, no module index is generated.
+#html_domain_indices = True
+
+# If false, no index is generated.
+#html_use_index = True
+
+# If true, the index is split into individual pages for each letter.
+#html_split_index = False
+
+# If true, links to the reST sources are added to the pages.
+#html_show_sourcelink = True
+
+# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
+#html_show_sphinx = True
+
+# If true, "(C) Copyright ..." is shown in the HTML footer. Default is 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 = ''
+
+# This is the file name suffix for HTML files (e.g. ".xhtml").
+#html_file_suffix = None
+
+# Output file base name for HTML help builder.
+htmlhelp_basename = 'straightplugindoc'
+
+
+# -- Options for LaTeX output --------------------------------------------------
+
+latex_elements = {
+# The paper size ('letterpaper' or 'a4paper').
+#'papersize': 'letterpaper',
+
+# The font size ('10pt', '11pt' or '12pt').
+#'pointsize': '10pt',
+
+# Additional stuff for the LaTeX preamble.
+#'preamble': '',
+}
+
+# Grouping the document tree into LaTeX files. List of tuples
+# (source start file, target name, title, author, documentclass [howto/manual]).
+latex_documents = [
+  ('index', 'straightplugin.tex', u'straight.plugin Documentation',
+   u'Calvin Spealman', 'manual'),
+]
+
+# The name of an image file (relative to this directory) to place at the top of
+# the title page.
+#latex_logo = None
+
+# For "manual" documents, if this is true, then toplevel headings are parts,
+# not chapters.
+#latex_use_parts = False
+
+# If true, show page references after internal links.
+#latex_show_pagerefs = False
+
+# If true, show URL addresses after external links.
+#latex_show_urls = False
+
+# Documents to append as an appendix to all manuals.
+#latex_appendices = []
+
+# If false, no module index is generated.
+#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', 'straightplugin', u'straight.plugin Documentation',
+     [u'Calvin Spealman'], 1)
+]
+
+# If true, show URL addresses after external links.
+#man_show_urls = False
+
+
+# -- Options for Texinfo output ------------------------------------------------
+
+# Grouping the document tree into Texinfo files. List of tuples
+# (source start file, target name, title, author,
+#  dir menu entry, description, category)
+texinfo_documents = [
+  ('index', 'straightplugin', u'straight.plugin Documentation',
+   u'Calvin Spealman', 'straightplugin', 'One line description of project.',
+   'Miscellaneous'),
+]
+
+# Documents to append as an appendix to all manuals.
+#texinfo_appendices = []
+
+# If false, no module index is generated.
+#texinfo_domain_indices = True
+
+# How to display URL addresses: 'footnote', 'no', or 'inline'.
+#texinfo_show_urls = 'footnote'
diff --git a/docs/getting-started.rst b/docs/getting-started.rst
new file mode 100644
index 0000000..9256723
--- /dev/null
+++ b/docs/getting-started.rst
@@ -0,0 +1,117 @@
+Getting Started
+===============
+
+Install
+^^^^^^^
+
+::
+
+    pip install straight.plugin
+
+That was super easy.
+
+Decide on a Namespace
+^^^^^^^^^^^^^^^^^^^^^
+
+You'll want to decide on a :term:`namespace` within your package where you'll
+keep your own plugins and where other developers can add more plugins for
+your package to use.
+
+For example, if you're writing a log filtering library named ``logfilter`` you may
+choose ``logfilter.plugins`` as a package to hold your plugins, so you'll create
+the empty package as you would any other python package. However, the only
+contents of ``logfilter/plugins/__init__.py`` will be a little bit of special
+code telling python this is a :term:`namespace package`.
+
+::
+
+    # This file will not be needed in Python 3.3
+    from pkgutil import extend_path
+    __path__ = extend_path(__path__, __name__)
+
+
+Now, any modules you place in this package are plugin modules able to be loaded
+by ``straight.plugin``.
+
+::
+
+    from straight.plugin import load
+
+    plugins = load("logfilter.plugins")
+
+If you'll be using more plugins than writing them, you should
+:doc:`read more <loaders>` about the loaders available and how they work.
+
+
+Write a Plugin
+^^^^^^^^^^^^^^
+
+Writing a plugin is even easier than loading them. There are two important
+plugin types to learn: Module plugins and class Plugins. Every module in
+your :term:`namespace package` is a module plugin. Every class they define
+is a class plugin.
+
+When you load module plugins, you get all of them.
+
+When you load class plugins, you filter them by a common base and only get
+those class plugins which inherit it.
+
+Module plugins are simple and usually define a few functions with names
+expected by whoever is loading and using the plugins.
+
+::
+
+    # This is a module plugin
+
+    def add_extra(data):
+        if 'x' in data and 'y' in data:
+            data['z'] = x * y
+
+    # This was a fairly useless plugin
+
+Class plugins are only a little longer, but can be a bit more controlled to
+work with. They depend on a common class the plugins inherit, and this would
+be defined by the project loading and using the plugins.
+
+::
+
+    # This is a class plugin
+
+    class RstContentParser(ContentPlugin):
+        """Parses any .rst files in a bundle."""
+
+        extensions = ('.rst',)
+
+        def parse(self, content_file):
+            src = content_file.read()
+            return self.parse_string(src)
+
+        def parse_string(self, src):
+            parts = publish_parts(source=src, writer_name='html')
+            return parts['html_body']
+
+You can fit as many class plugins inside a module plugin as you want, and
+to load them instead of the modules you simply pass a ``subclasses``
+parameter to ``load()``.
+
+::
+    
+    from straight.plugin import load
+
+    plugins = load("jules.plugins", subclasses=ContentPlugin)
+
+The resulting set of plugins are all the classes found which inherit from
+ContentPlugin. You can do whatever you want with these, but there are some
+helpful tools to make it easier to work with Class plugins.
+
+You can easily create instances of all the classes, which gives you a set
+of Instance plugins.
+
+::
+
+    instances = plugins.produce()
+
+You can even pass initialization parameters to ``produce()`` and they'll
+be used when creating instances of all the classes. You can see the
+:ref:`API docs <api-plugin-manager>` for the ``PluginManager`` to see the
+other ways you can work with groups of plugins.
diff --git a/docs/glossary.rst b/docs/glossary.rst
new file mode 100644
index 0000000..7972de9
--- /dev/null
+++ b/docs/glossary.rst
@@ -0,0 +1,45 @@
+Glossary
+-------------
+
+.. glossary::
+    :sorted:
+
+    package
+        A Python package is a module defined by a directory, containing
+        a ``__init__.py`` file, and can contain other modules or other
+        packages within it.
+
+        ::
+        
+            package/
+                __init__.py
+                subpackage/
+                    __init__.py
+                submodule.py
+
+        see also, :term:`namespace package`
+
+    distribution
+        Separately installable sets of Python modules as stored in the
+        Python package index, and installed by distutils or setuptools.
+
+        *definition taken from* `PEP 382`_ *text*
+
+    vendor package
+        Groups of files installed by an operating system's packaging
+        mechanism (e.g. Debian or Redhat packages install on Linux systems).
+        
+        *definition taken from* `PEP 382`_ *text*
+
+    namespace package
+        Mechanism for splitting a single Python package across multiple
+        directories on disk. One or more distributions (see :term:`distribution`)
+        may provide modules which exist inside the same :term:`namespace package`.
+
+        *definition taken from* `PEP 382`_ *text*
+
+    module
+        An importable python namespace defined in a single file.
+
+
+.. _PEP 382: http://www.python.org/dev/peps/pep-0382/
diff --git a/docs/index.rst b/docs/index.rst
new file mode 100644
index 0000000..652ac15
--- /dev/null
+++ b/docs/index.rst
@@ -0,0 +1,82 @@
+.. straight.plugin documentation master file, created by
+   sphinx-quickstart on Wed Jan 25 22:49:22 2012.
+   You can adapt this file completely to your liking, but it should at least
+   contain the root `toctree` directive.
+
+Welcome to straight.plugin's documentation!
+===========================================
+
+.. toctree::
+   :maxdepth: 1
+
+   Getting Started <getting-started>
+   Writing Plugins <write-plugin>
+   Using Plugins <loaders>
+   API <api>
+   Glossary <glossary>
+
+
+Overview
+========
+
+Straight Plugin is very easy.
+
+Straight Plugin provides a type of plugin you can create
+from almost any existing Python modules, and an easy way for outside developers
+to add functionality and customization to your projects with their own
+plugins.
+
+Using any available plugins is a snap.
+
+::
+
+    from straight.plugin import load
+
+    plugins = load('theproject.plugins', subclasses=FileHandler)
+
+    handlers = plugins.produce()
+    for line in open(filename):
+        print handlers.pipe(line)
+
+
+And, writing plugins is just as easy.
+
+::
+
+    from theproject import FileHandler
+
+    class LineNumbers(FileHandler):
+        def __init__(self):
+            self.lineno = 0
+        def pipe(line):
+            self.lineno += 1
+            return "%04d %s" % (self.lineno, line)
+
+
+Plugins are found from a :term:`namespace`, which means the above example
+would find any ``FileHandler`` classes defined in modules you might import
+as ``theproject.plugins.default`` or ``theproject.plugins.extra``. Through
+the magic of :term:`namespace packages <namespace package>`, we can even
+split these up into separate installations, even managed by different teams.
+This means you can ship a project with a set of default plugins implementing
+its behavior, and allow other projects to hook in new functionality simply
+by shipping their own plugins under the same :term:`namespace`.
+
+:doc:`Get started and learn more, today <getting-started>`
+    
+
+More Resources
+##############
+
+* Full Documentation: http://readthedocs.org/docs/straightplugin/
+
+* Mailing List: https://groups.google.com/forum/#!forum/straight.plugin
+
+
+Indices and tables
+==================
+
+* :ref:`genindex`
+* :ref:`modindex`
+* :ref:`search`
+
diff --git a/docs/loaders.rst b/docs/loaders.rst
new file mode 100644
index 0000000..16ca823
--- /dev/null
+++ b/docs/loaders.rst
@@ -0,0 +1,85 @@
+Plugin Loaders
+==============
+
+Currently, three simple loaders are provided.
+
+* The :ref:`ModuleLoader <moduleloader>` simply loads the modules found
+* The :ref:`ClassLoader <classloader>` loads the subclasses of a given type
+* The :ref:`ObjectLoader <objectloader>` loads arbitrary objects from the modules
+
+.. _classloader:
+
+ClassLoader
+-----------
+
+The recommended loader is the ``ClassLoader``, used to load all the
+classes from all of the modules in the namespace given. Optionally,
+you can pass a ``subclasses`` parameter to ``load()``, which will
+filter the loaded classes to those which are a sub-class of any given
+type.
+
+For example,
+
+::
+
+    import os
+    from straight.plugin.loaders import ClassLoader
+    from myapp import FileHandler
+
+    plugins = ClassLoader().load('myplugins', subclasses=FileHandler)
+
+    for filename in os.listdir('.'):
+        for handler_cls in plugins:
+            handler = handler_cls(filename)
+            if handler.valid():
+                handler.process()
+
+However, it is preferred that you use the ``load()`` helper provided.
+
+::
+
+    from straight.plugin import load
+
+    plugins = load('myplugins', subclasses=FileHandler)
+
+This will automatically use the ``ClassLoader`` when given a ``subclasses``
+argument.
+
+.. _moduleloader:
+
+ModuleLoader
+------------
+
+Before anything else, ``straight.plugin`` loads modules. The
+``ModuleLoader`` is used to do this.
+
+::
+
+    from straight.plugin.loaders import ModuleLoader
+
+    plugins = ModuleLoader().load('myplugins')
+
+A note about `PEP-420 <http://www.python.org/dev/peps/pep-0420/>`_:
+
+Python 3.3 will support a new type of package, the Namespace Package. This
+allows language-level support for the namespaces that make ``straight.plugin``
+work and when 3.3 lands, you can create addition plugins to be found in a
+namespace. For now, continue to use the ``pkgutil`` boilerplate, but when
+3.3 is released, ``straight.plugin`` already supports both forms of
+namespace package!
+
+.. _objectloader:
+
+ObjectLoader
+------------
+
+If you need to combine multiple plugins inside each module, you can
+load all the objects from the modules, rather than the modules themselves.
+
+::
+
+    from straight.plugin.loaders import ObjectLoader
+    
+    plugins = ObjectLoader().load('myplugins')
+
+
diff --git a/docs/make.bat b/docs/make.bat
new file mode 100644
index 0000000..c6535d2
--- /dev/null
+++ b/docs/make.bat
@@ -0,0 +1,190 @@
+ at ECHO OFF
+
+REM Command file for Sphinx documentation
+
+if "%SPHINXBUILD%" == "" (
+	set SPHINXBUILD=sphinx-build
+)
+set BUILDDIR=_build
+set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% .
+set I18NSPHINXOPTS=%SPHINXOPTS% .
+if NOT "%PAPER%" == "" (
+	set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%
+	set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS%
+)
+
+if "%1" == "" goto help
+
+if "%1" == "help" (
+	:help
+	echo.Please use `make ^<target^>` where ^<target^> is one of
+	echo.  html       to make standalone HTML files
+	echo.  dirhtml    to make HTML files named index.html in directories
+	echo.  singlehtml to make a single large HTML file
+	echo.  pickle     to make pickle files
+	echo.  json       to make JSON files
+	echo.  htmlhelp   to make HTML files and a HTML help project
+	echo.  qthelp     to make HTML files and a qthelp project
+	echo.  devhelp    to make HTML files and a Devhelp project
+	echo.  epub       to make an epub
+	echo.  latex      to make LaTeX files, you can set PAPER=a4 or PAPER=letter
+	echo.  text       to make text files
+	echo.  man        to make manual pages
+	echo.  texinfo    to make Texinfo files
+	echo.  gettext    to make PO message catalogs
+	echo.  changes    to make an overview over all changed/added/deprecated items
+	echo.  linkcheck  to check all external links for integrity
+	echo.  doctest    to run all doctests embedded in the documentation if enabled
+	goto end
+)
+
+if "%1" == "clean" (
+	for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i
+	del /q /s %BUILDDIR%\*
+	goto end
+)
+
+if "%1" == "html" (
+	%SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The HTML pages are in %BUILDDIR%/html.
+	goto end
+)
+
+if "%1" == "dirhtml" (
... 978 lines suppressed ...

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/straight.plugin.git



More information about the Python-modules-commits mailing list