[Checkins] SVN: z3ext.controlpanel/trunk/ Add narrative documentation for this package.

Dan Korostelev nadako at gmail.com
Thu Oct 29 13:12:28 EDT 2009


Log message for revision 105370:
  Add narrative documentation for this package.

Changed:
  U   z3ext.controlpanel/trunk/buildout.cfg
  A   z3ext.controlpanel/trunk/docs/
  A   z3ext.controlpanel/trunk/docs/Makefile
  A   z3ext.controlpanel/trunk/docs/README.txt
  A   z3ext.controlpanel/trunk/docs/conf.py

-=-
Modified: z3ext.controlpanel/trunk/buildout.cfg
===================================================================
--- z3ext.controlpanel/trunk/buildout.cfg	2009-10-29 17:05:22 UTC (rev 105369)
+++ z3ext.controlpanel/trunk/buildout.cfg	2009-10-29 17:12:28 UTC (rev 105370)
@@ -1,6 +1,6 @@
 [buildout]
 develop = .
-parts = test coverage-test coverage-report i18n i18nall i18ncheck i18ndude
+parts = test coverage-test coverage-report i18n i18nall i18ncheck i18ndude sphinx
 
 [test]
 recipe = zc.recipe.testrunner
@@ -45,3 +45,9 @@
 unzip = true
 recipe = zc.recipe.egg
 eggs = i18ndude
+
+[sphinx]
+recipe = zc.recipe.egg
+eggs =
+  sphinx
+  docutils


Property changes on: z3ext.controlpanel/trunk/docs
___________________________________________________________________
Added: svn:ignore
   + _build


Added: z3ext.controlpanel/trunk/docs/Makefile
===================================================================
--- z3ext.controlpanel/trunk/docs/Makefile	                        (rev 0)
+++ z3ext.controlpanel/trunk/docs/Makefile	2009-10-29 17:12:28 UTC (rev 105370)
@@ -0,0 +1,89 @@
+# Makefile for Sphinx documentation
+#
+
+# You can set these variables from the command line.
+SPHINXOPTS    =
+SPHINXBUILD   = ../bin/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) .
+
+.PHONY: help clean html dirhtml pickle json htmlhelp qthelp latex changes linkcheck doctest
+
+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 "  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 "  latex     to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
+	@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."
+
+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/z3extpreferences.qhcp"
+	@echo "To view the help file:"
+	@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/z3extpreferences.qhc"
+
+latex:
+	$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+	@echo
+	@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
+	@echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
+	      "run these through (pdf)latex."
+
+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."

Added: z3ext.controlpanel/trunk/docs/README.txt
===================================================================
--- z3ext.controlpanel/trunk/docs/README.txt	                        (rev 0)
+++ z3ext.controlpanel/trunk/docs/README.txt	2009-10-29 17:12:28 UTC (rev 105370)
@@ -0,0 +1,188 @@
+Control panel
+=============
+
+The ``z3ext.controlpanel`` package provides an easy way to add per-site
+configuration snippets (we'll call them "configlets"), automatically handling
+data storage and browser UI.
+
+For those who knows ``z3ext.preferences``, this package work in a similar way,
+but storing data per site instead of per principal.
+
+Basic usage
+-----------
+
+In most simple cases, when you just want to store some configuration for a site,
+creating a configlet is easy. First, you need to create a schema for a configlet,
+defining fields that will be stored. Example::
+
+  class ISiteMetaData(Interface):
+  
+      keywords = TextLine(title=u'Keywords', required=False)
+      description = Text(title=u'Description', required=False)
+
+And second, you need to register a configlet for this schema using the
+``z3ext:configlet`` ZCML directive::
+
+  <z3ext:configlet
+      name="metadata"
+      schema=".interfaces.ISiteMetaData"
+      title="Site meta-data"
+      />
+
+The ZCML directive have three required arguments: name, schema and title.
+``schema`` should point to a schema we create for a configlet, ``title`` is
+a human-readable, translatable title for use in UI, and the ``name`` is an
+unique identifier of a configlet.
+
+Configlet's are organized hierarchically, so one configlet can have children
+configlets. In the ``name`` argument of the ZCML directive dot symbol has a
+special meaning, used to declare hierarchies.
+
+In the example above, we don't have any dots in the name. It means that this
+configlet is top-level, it will be added to the root configlet. However, if we
+create another configlet with, for example, "metadata.language" as its name,
+the new configlet will be added as a child to our "metadata" configlet and it's
+menu item will be rendered as a sub-menu item under the "Site meta-data".
+
+There is no restriction on the depth of configlet nesting, but remember
+that you should always register parent configlet before registering children.
+
+After registering a configlet, it will be available as named IConfiglet utility,
+with name equal to the value of ``name`` argument of the ZCML directive.
+
+.. note::
+
+   The configlet objects are not persistent and only those attributes will be
+   stored by default that are defined in the configlet schema.
+
+The browser UI for the control panel (which is a collection of configlets) is
+available as view named "settings" for the site objects (objects providing 
+``zope.app.component.interfaces.ISite`` interface). So if your site root is at
+"http://yoursiteurl.com", the control panel will be available at
+"http://yoursiteurl.com/settings". 
+
+
+Advanced usage
+--------------
+
+ZCML directive
+~~~~~~~~~~~~~~
+
+The ``z3ext:configlet`` ZCML directive has more arguments that can be used to
+make a more specific configlet. Let's describe them all:
+
+* name - The unique identifier of a configlet. Hierarchy of configlets is
+  organized using dots in the names (see above).
+
+* schema - Configlet schema interface. By default, storable properties will be
+  created only for fields defined in this schema. It makes sense to use an
+  empty interface as the schema, in case you want the configlet to be
+  registered and provide custom data storage mechanism and/or browser views.
+
+* title - Human-friendly translatable title of a configlet to be used in menus
+  and headings. 
+
+* description - Human friendly translatable description of a configlet to be
+  used in UI.
+
+* class - A mixin class for the configlet. The ZCML directive creates a new
+  class using ``z3ext.controlpanel.configlet.Configlet`` as base and mixing
+  in custom class if given. It can be used to override behaviour or implement
+  some custom methods.
+
+* provides - A list of additional interfaces that the configlet will provide.
+  Can be used to mark a configlet with marker interfaces, for example to give
+  access to special browser views.
+
+* permission - An id of permission that will be used for accessing fields defined
+  in the schema for reading and writing. By default, ``z3ext.Configure`` is used.
+
+* tests - A list of global functions that will be used for testing whether the
+  configlet is available. These functions should recieve one argument - the
+  actual configlet object.
+
+If you need more control over attribute access permissions for the configlet,
+you can use "require" and "allow" sub-directives with the same sematics
+as with standard zope "class" directive.
+
+Full example::
+
+  <z3ext:configlet
+    id="siteinfo"
+    schema=".interfaces.ISiteInfo"
+    title="Site information"
+    description="Misc site information, such as title, main author etc."
+    class=".configlet.SiteInfoConfiglet"
+    provides=".interfaces.ISomeMarker"
+    permission="z3ext.ChangeSiteInfo"
+    tests=".configlet.isSiteInfoAvailable"
+    >
+
+    <allow attributes="title" />
+
+    <require
+      permission="yourproject.ChangeMainAuthor"
+      set_attributes="mainAuthor"
+      />
+
+  </z3ext:configlet>
+
+Availability testing
+~~~~~~~~~~~~~~~~~~~~
+
+Configlet objects have the ``isAvailable`` method, as described in the IConfiglet
+interface. It does checking whether the configlet is available in current
+conditions, so it can be hidden in UI for example.
+
+You can override this method in custom configlet class, but default implementation
+is fine in most cases. The default implementation of this method does check if
+the parent configlet available and then performs checking using "test" functions
+(see "tests" argument of the ZCML directive) and if either of them returns False
+value, the configlet group won't be available.
+
+
+Custom browser views
+~~~~~~~~~~~~~~~~~~~~
+
+The default browser UI for a configlet is an edit form for fields defined in its
+schema, but you can override the view, simply registering own view for the
+configlet schema interface.
+
+This fact can be used if you want to create more complex configlets that,
+for example, does not contain any fields, but provides some other methods of
+changing site-related data, or if you just want to place a special form in the
+site control panel UI. 
+
+
+Configlet data storage
+~~~~~~~~~~~~~~~~~~~~~~
+
+The default configlet implementation (the ``z3ext.controlpanel.configlet.Configlet``
+class) has the ``data`` property that is a per-site persistent data object where
+values of configlet fields are stored.
+
+That object is available via adapter lookup from configlet to the
+``z3ext.controlpanel.interfaces.IConfigletData`` interface and can have different
+nature for different configlet types. However, the default implementation of
+configlet field properties (that are created for every field in configlet's schema)
+assumes that this object has mapping interface for storing values. So does the
+default IConfigletData adapter implementation.
+
+The default IConfigletData adapter is quite complex and customizable, so let's
+talk some more about it.
+
+First, this adapter uses the special IConfigletDataFactory interface to actually
+create IConfigletData object, so if you just want to provide custom data
+object and don't want to think about how it will be stored, you can simply
+provide an adapter from your configlet type to the IConfigletDataFactory
+interface, which is a simple callable factory that should return the
+IConfigletData object.
+
+And second, it also uses the IConfigletDataStorage adapter lookup to get the
+persistent mapping object where configlet data objects will be stored by their
+configlets' unique names. So, if you don't care about exact configlet data
+object types and want to change their storage, you need to provide an adapter
+from a site-manager (the object returned by site's ``getSiteManager`` method)
+to the IConfigletDataStorage interface. The returned object should provide
+mapping interface. The default adapter is provided for zope local site-managers
+and stores a persistent container named "controlpanel" in the site-manager itself.

Added: z3ext.controlpanel/trunk/docs/conf.py
===================================================================
--- z3ext.controlpanel/trunk/docs/conf.py	                        (rev 0)
+++ z3ext.controlpanel/trunk/docs/conf.py	2009-10-29 17:12:28 UTC (rev 105370)
@@ -0,0 +1,194 @@
+# -*- coding: utf-8 -*-
+#
+# z3ext.preferences documentation build configuration file, created by
+# sphinx-quickstart on Wed Oct 28 17:04:08 2009.
+#
+# 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.append(os.path.abspath('.'))
+
+# -- General configuration -----------------------------------------------------
+
+# 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.todo']
+
+# Add any paths that contain templates here, relative to this directory.
+#templates_path = ['_templates']
+
+# The suffix of source filenames.
+source_suffix = '.txt'
+
+# The encoding of source files.
+#source_encoding = 'utf-8'
+
+# The master toctree document.
+master_doc = 'README'
+
+# General information about the project.
+project = u'z3ext.controlpanel'
+copyright = u'2009, Dan Korostelev'
+
+# 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 = '0'
+# The full version, including alpha/beta/rc tags.
+release = 'development'
+
+# 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 documents that shouldn't be included in the build.
+#unused_docs = []
+
+# List of directories, relative to source directory, that shouldn't be searched
+# for source files.
+exclude_trees = ['_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.  Major themes that come with
+# Sphinx are currently 'default' and 'sphinxdoc'.
+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_use_modindex = 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, 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 = ''
+
+# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
+#html_file_suffix = ''
+
+# Output file base name for HTML help builder.
+htmlhelp_basename = 'z3extcontrolpaneldoc'
+
+
+# -- Options for LaTeX output --------------------------------------------------
+
+# The paper size ('letter' or 'a4').
+#latex_paper_size = 'letter'
+
+# The font size ('10pt', '11pt' or '12pt').
+#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', 'z3extcontrolpanel.tex', u'z3ext.controlpanel Documentation',
+   u'Dan Korostelev', '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
+
+# Additional stuff for the LaTeX preamble.
+#latex_preamble = ''
+
+# Documents to append as an appendix to all manuals.
+#latex_appendices = []
+
+# If false, no module index is generated.
+#latex_use_modindex = True


Property changes on: z3ext.controlpanel/trunk/docs/conf.py
___________________________________________________________________
Added: svn:keywords
   + Id



More information about the checkins mailing list