Anonymous avatar Anonymous committed d885266

pre-0.3 release

Comments (0)

Files changed (2)

docs/conf.py.orig

-# -*- coding: utf-8 -*-
-#
-# flask-testing documentation build configuration file, created by
-# sphinx-quickstart on Wed Jun 23 08:26:41 2010.
-#
-# 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('_themes'))
-
-# -- 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', 'sphinx.ext.intersphinx']
-
-# 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'Flask-Script'
-copyright = u'2010, Dan Jacob'
-
-# 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.2'
-# The full version, including alpha/beta/rc tags.
-release = '0.2'
-
-# 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 = 'flask_small'
-
-html_theme_options = {
-     'index_logo': 'flask-script.png',
-     'github_fork': None
-}
-# 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 = ['_themes']
-
-# 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 = ''
-
-# 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 = 'flask-scriptdoc'
-
-
-# -- 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', 'flask-script.tex', u'Flask-Script Documentation',
-   u'Dan Jacob', '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
-
-# 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_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', 'flask-script', u'Flask-Script Documentation',
-     [u'Dan Jacob'], 1)
-]

docs/index.rst.orig

-Flask-Script
-======================================
-
-.. module:: Flask-Script
-
-The **Flask-Script** extension provides support for writing external scripts in Flask. It uses `argparse`_ to parse command line arguments.
-
-You define and add commands that can be called from the command line to a ``Manager`` instance::
-
-    # manage.py
-    
-    from flaskext.script import Manager
-
-    from myapp import app
-
-    manager = Manager(app)
-    
-    @manager.command
-    def hello(app):
-        print "hello"
-
-    if __name__ == "__main__":
-        manager.run()
-
-Then run the script like this::
-
-    python manage.py hello
-    > hello
-    
-Source code and issue tracking at `Bitbucket`_.
-
-Installing Flask-Script
-------------------------
-
-Install with **pip** and **easy_install**::
-
-    pip install Flask-Script
-
-or download the latest version from Bitbucket::
-
-    hg clone http://bitbucket.org/danjac/flask-script
-
-    cd flask-script
-
-    python setup.py develop
-
-If you are using **virtualenv**, it is assumed that you are installing **Flask-Script**
-in the same virtualenv as your Flask application(s).
-
-Creating and running commands
------------------------------
-
-The first step is to create a Python module to run your script commands in. You can call it
-anything you like, for our examples we'll call it **manage.py**.
-
-You don't have to place all your commands in the same file; for example, in a larger project
-with lots of commands you might want to split them into a number of files with related commands.
-
-In your **manage.py** file you have to create a ``Manager`` instance. The ``Manager`` class
-keeps track of all the commands and handles how they are called from the command line::
-
-    from flaskext.script import Manager
-
-    app = Flask(__name__)
-    # configure your app
-
-    manager = Manager(app)
-
-    if __name__ == "__main__":
-        manager.run()
-
-Calling ``manager.run()`` prepares your ``Manager`` instance to receive input from the command line.
-
-The ``Manager`` requires a single argument, a **Flask** instance. This may also be a function or callable
-that returns a **Flask** instance instead, if you want to use a factory pattern.
-
-The next step is to create and add your commands. There are three methods for creating commands:
-
-    * subclassing the ``Command`` class
-    * using the ``@command`` decorator
-    * using the ``@option`` decorator
-
-To take a very simple example, we want to create a ``Print`` command that just prints out "hello world". It 
-doesn't take any arguments so is very straightforward::
-
-    from flaskext.script import Command
-
-    class Print(Command):
-
-        description = "prints hello world"
-
-        def run(self, app):
-            print "hello world"
-
-Now the command needs to be added to our ``Manager`` instance, created above::
-
-    manager.add_command('print', Print())
-
-This of course needs to be called before ``manager.run``. Now in our command line::
-
-    python manage.py print
-    > hello world
-
-You can also pass the ``Command`` instance in a dict to ``manager.run()``::
-
-    manager.run({'print' : Print()})
-
-The first argument to your ``run`` command, other than ``self``, is always ``app``: this is the Flask
-application instance provided by the ``app`` passed to the ``Manager``. Additional arguments
-are configured through the ``option_list`` (see below).
-
-To get a list of available commands and their descriptions, just run with no command::
-
-    python manage.py
-
-To get help text for a particular command::
-
-    python manage.py runserver -h
-
-This will print usage plus the docstring of the ``Command``.
-
-The next method is using the ``@command`` decorator, which belongs to the ``Manager`` instance. 
-
-This is probably the easiest to use, when you have a simple command::
-
-    @manager.command
-    def hello(app):
-        "Just say hello"
-        print "hello"
-
-Commands created this way are run in exactly the same way as those created with the ``Command`` class::
-
-    python manage.py hello
-    > hello
-
-As with the ``Command`` class, the docstring you use for the function will appear when you run with the **-h** option::
-
-    python manage.py -h
-    > Just say hello
-
-Finally, the ``@option`` decorator, again belonging to ``Manager`` can be used when you want more sophisticated 
-control over your commands::
-
-    @manager.option('-n', '--name', help='Your name')
-    def hello(app, name):
-        print "hello", name
-
-The ``@option`` command takes the exact same arguments as the ``Option`` instance - see the section on adding arguments
-to commands below.
-
-Note that with ``@command`` and ``@option`` decorators, the function must take the Flask application instance as the first
-argument, just as with ``Command.run``.
-
-Adding arguments to commands
-----------------------------
-
-Most commands take a number of named or positional arguments that you pass in the command line.
-
-Taking the above examples, rather than just print "hello world" we would like to be able to print some
-arbitrary name, like this::
-
-    python manage.py hello --name=Joe
-    hello Joe
-
-or alternatively::
-
-    python manage.py hello -n Joe
-
-To facilitate this you use the ``option_list`` attribute of the ``Command`` class::
-
-    from flaskext.script import Command, Manager, Option
-
-    class Hello(Command):
-
-        option_list = (
-            Option('--name', '-n', dest='name'),
-        )
-
-        def run(self, app, name):
-            print "hello %s" % name
-
-Positional and optional arguments are stored as ``Option`` instances - see the API below for details.
-
-Alternatively, you can define a ``get_options`` method for your ``Command`` class. This is useful if you want to be able
-to return options at runtime based on for example per-instance attributes::
-
-    class Hello(Command):
-
-        def __init__(self, default_name='Joe'):
-            self.default_name=default_name
-
-        def get_options(self):
-            return [
-                Option('-n', '--name', dest='name', default=self.default_name),
-            ]
-
-        def run(self, app, name):
-            print "hello",  name
-
-If you are using the ``@command`` decorator, it's much easier - the options are extracted automatically from your function arguments::
-
-    @manager.command
-    def hello(app, name):
-        print "hello", name
-
-
-Then do::
-
-    > python manage.py hello Joe
-    hello joe
-
-Or you can do optional arguments::
-
-    @manager.command
-    def hello(app, name="Fred")
-        print hello, name
-
-These can be called like this::
-
-    > python manage.py hello --name=Joe
-    hello Joe
-
-alternatively::
-    
-    > python manage.py hello -n Joe
-    hello Joe
-
-
-and if you don't pass in any argument::
-
-    > python manage.py hello 
-    hello Fred
-
-There are a couple of important points to note here.
-
-The short-form **-n** is formed from the first letter of the argument, so "name" > "-n". Therefore it's a good idea that your
-optional argument variable names begin with different letters ("app" is ignored, so don't worry about "a" being taken).
-
-The second issue is that the **-h** switch always runs the help text for that command, so avoid arguments starting with the letter "h".
-
-Note also that if your optional argument is a boolean, for example::
-
-    @manage.command
-    def verify(app, verified=False):
-        """
-        Checks if verified
-        """
-        print "VERIFIED?", "YES" if verified else "NO"
-
-You can just call it like this::
-
-    > python manage.py verify
-    VERIFIED? NO
-
-    > python manage.py verify -v
-    VERIFIED? YES
-
-    > python manage.py verify --verified
-    VERIFIED? YES
-
-For more complex options it's better to use the ``@option`` decorator::
-
-    @manager.option('-n', '--name', dest='name', default='joe')
-    def hello(app, name):
-        print "hello", name
-
-You can add as many options as you want::
-
-    @manager.option('-n', '--name', dest='name', default='joe')
-    @manager.option('-u', '--url', dest='url', default=None)
-    def hello(app, name, url):
-        if url is None:
-            print "hello", name
-        else:
-            print "hello", name, "from", url
-
-This can be called like so::
-
-    > python manage.py hello -n Joe -u reddit.com
-    hello Joe from reddit.com
-
-or like this::
-    
-    > python manage.py hello --name=Joe --url=reddit.com
-    hello Joe from reddit.com
-
-Adding options to the manager
------------------------------
-
-Options can also be passed to the ``Manager`` instance. This is allows you to set up options that are passed to the application rather
-than a single command. For example, you might want to have a flag to set the configuration file for your application::
-
-    def create_app(config=None):
-        
-        app = Flask(__name__)
-        if config is not None:
-            app.config.from_pyfile(config)
-        # configure your app...
-        return app
-
-In order to pass that ``config`` argument, use the ``add_option()`` method of your ``Manager`` instance. It takes the same arguments
-as ``Option``::
-
-    manager.add_option('-c', '--config', dest='config', required=False)
-
-Suppose you have this command::
-    
-    @manager.command
-    def hello(app, name):
-        uppercase = app.config.get('USE_UPPERCASE', False)
-        if uppercase:
-            name = name.upper()
-        print hello, name
-
-You can now run the following::
-
-    > python manage.py hello joe -c dev.cfg
-    hello JOE
-
-Assuming the ``USE_UPPERCASE`` setting is **True** in your dev.cfg file.
-
-Notice also that the "config" option is **not** passed to the command.
-
-In order for manager options to work it is assumed that you are passing a factory function, rather than a Flask instance, to your 
-``Manager`` constructor.
-
-Getting user input
-------------------
-
-**Flask-Script** comes with a set of helper functions for grabbing user input from the command line. For example::
-    
-    from flaskext.script import Manager, prompt_bool
-    
-    from myapp import app
-    from myapp.models import db
-
-    manager = Manager(app)
-        
-    @manager.command
-    def dropdb(app):
-        if prompt_bool(
-            "Are you sure you want to lose all your data"):
-            db.drop_all()
-
-It then runs like this::
-
-    python manage.py dropdb
-    > Are you sure you want to lose all your data ? [N]
-
-Default commands
-----------------
-
-**Flask-Script** has a couple of ready commands you can add and customize: ``Server`` and ``Shell``.
-
-The ``Server`` command runs the **Flask** development server. It takes an optional ``port`` argument (default **5000**)::
-
-    from flaskext.script import Server, Manager
-    from myapp import create_app
-
-    manager = Manager(create_app)
-    manager.add_command("runserver", Server())
-
-    if __name__ == "__main__":
-        manager.run()
-
-and then run the command::
-
-    python manage.py runserver
-
-The ``Server`` command has a number of command-line arguments - run ``python manage.py runserver -h`` for details on these.
-
-Needless to say the development server is not intended for production use.
-
-The ``Shell`` command starts a Python shell. You can pass in a ``make_context`` argument, which must be a ``callable`` returning a ``dict``. By default, this is just a dict returning the ``app`` instance::
-
-    from flaskext.script import Shell, Manager
-    
-    from myapp import app
-    from myapp import models
-    from myapp.models import db
-
-    def _make_context(app):
-        return dict(app=app, db=db, models=models)
-
-    manager = Manager(create_app)
-    manager.add_command("shell", Shell(make_context=_make_context))
-    
-This is handy if you want to include a bunch of defaults in your shell to save typing lots of ``import`` statements.
-
-The ``Shell`` command will use `IPython <http://ipython.scipy.org/moin/>`_ if it is installed, otherwise it defaults to the standard Python shell. You can disable this behaviour in two ways: by passing the ``use_ipython`` argument to the ``Shell`` constructor, or passing the flag ``--no-ipython`` in the command line. 
-
-The default commands **shell** and **runserver** are included by default, with the default options for these commands. If you wish to 
-replace them with different commands simply override with ``add_command()`` or the decorators. If you pass ``with_default_commands=False``
-to the ``Manager`` constructor these commands will not be loaded::
-
-    manager = Manager(app, with_default_commands=False)
-
-
-Accessing local proxies
------------------------
-
-The ``Manager`` runs the command inside a `Flask test context <http://flask.pocoo.org/docs/testing/#other-testing-tricks>`_. This means thathat you can access request-local proxies where appropriate, such as ``current_app``, which may be used by extensions.
-
-API
----
-
-.. module:: flaskext.script
-
-.. autoclass:: Manager
-   :members:
-    
-.. autoclass:: Command
-   :members:
-
-.. autoclass:: Shell
-
-.. autoclass:: Server
-
-.. class:: Option
-
-    Stores option parameters for `argparse.ArgumentParser.add_argument <http://pypi.python.org/pypi/argparse>`_. Use with ``Command.option_list`` or ``Command.get_options()``. 
-
-    .. method:: __init__(name_or_flags, action, nargs, const, default, type, choices, required, help, metavar, dest)
-
-        :param name_or_flags: Either a name or a list of option strings, e.g. foo or -f, --foo
-        :param action: The basic type of action to be taken when this argument is encountered at the command-line.
-        :param nargs: The number of command-line arguments that should be consumed.
-        :param const: A constant value required by some action and nargs selections.
-        :param default: The value produced if the argument is absent from the command-line.
-        :param type: The type to which the command-line arg should be converted.
-        :param choices: A container of the allowable values for the argument.
-        :param required: Whether or not the command-line option may be omitted (optionals only).
-        :param help: A brief description of what the argument does.
-        :param metavar: A name for the argument in usage messages.
-        :param dest: The name of the attribute to be added to the object returned by parse_args().
-
-.. autofunction:: prompt
-
-.. autofunction:: prompt_bool
-
-.. autofunction:: prompt_pass
-
-.. autofunction:: prompt_choices
-
-.. _Flask: http://flask.pocoo.org
-.. _Bitbucket: http://bitbucket.org/danjac/flask-script
-.. _argparse: http://pypi.python.org/pypi/argparse
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.