Skip to content

Commit

Permalink
Add support for using this recipe with paver by providing a paver task.
Browse files Browse the repository at this point in the history
  • Loading branch information
pcardune committed Aug 16, 2009
1 parent 39ea9b0 commit aa6ffb3
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 6 deletions.
24 changes: 22 additions & 2 deletions README.txt
@@ -1,6 +1,9 @@
==============
z3c.recipe.tag
==============

.. contents::

Introduction
------------

Expand All @@ -25,6 +28,9 @@ install ctags and utils in this way::
How to use this recipe
----------------------

With Buildout
.............

Suppose you have an egg called ``MyApplication``. To use this recipe with
buildout, you would add the following to the ``buildout.cfg`` file::

Expand All @@ -38,7 +44,7 @@ then run like this::
$ ./bin/tags

By default, this script produces three files in the directory from
which you ran the script:
which you ran the script:

- a ctags file called ``TAGS`` for use by emacs,
- a ctags file called ``tags`` for use by vi, and
Expand All @@ -50,7 +56,7 @@ Optionally, you can select which files to build. The following is the output
of ``./bin/tags --help``::

usage: build_tags [options]

options:
-h, --help show this help message and exit
-l LANGUAGES, --languages=LANGUAGES
Expand All @@ -61,6 +67,20 @@ of ``./bin/tags --help``::
-b, --ctags-bbedit flag to build bbedit ctags ``tags`` file
-i, --idutils flag to build idutils ``ID`` file

With Paver
..........

If you are using `Paver
<http://www.blueskyonmars.com/projects/paver/>`_ and already have
z3c.recipe.tag installed, then all you have to do is add this line to
your ``pavement.py`` file::

import z3c.recipe.tag

And then run the ``z3c.recipe.tag.tags`` task from the command line::

$ paver z3c.recipe.tag.tags

(BBEdit_ is a Macintosh text editor.)

.. _BBEdit: http://barebones.com/products/bbedit/
6 changes: 5 additions & 1 deletion buildout.cfg
@@ -1,7 +1,7 @@
[buildout]
index = http://download.zope.org/zope3.4
develop = .
parts = z3c.recipe.tag test
parts = z3c.recipe.tag test tags
newest = false

[z3c.recipe.tag]
Expand All @@ -13,3 +13,7 @@ eggs = z3c.recipe.tag
recipe = zc.recipe.testrunner
eggs = z3c.recipe.tag
defaults = ['--exit-with-status', '--tests-pattern', '^f?tests$', '-v']

[tags]
recipe = z3c.recipe.tag:tags
eggs = z3c.recipe.tag
20 changes: 17 additions & 3 deletions src/z3c/recipe/tag/__init__.py
Expand Up @@ -115,7 +115,7 @@ def __call__(self, targets=None, languages=None):

def _build_idutils(self):
return [['mkid'],
['-m',
['-m',
pkg_resources.resource_filename(
"z3c.recipe.tag", "id-lang.map"),
'-o',
Expand Down Expand Up @@ -152,7 +152,7 @@ def append_const(option, opt_str, value, parser, const):
parser.values.targets = []
parser.values.targets.append(const)

def build_tags():
def build_tags(args=None):
parser = optparse.OptionParser()
parser.add_option('-l', '--languages', dest='languages',
default='-JavaScript',
Expand All @@ -170,11 +170,25 @@ def build_tags():
parser.add_option('-i', '--idutils', action='callback',
callback=append_const, callback_args=('idutils',),
help='flag to build idutils ``ID`` file')
options, args = parser.parse_args()
options, args = parser.parse_args(args)
if args:
parser.error('no arguments accepted')
targets = getattr(options, 'targets', None)
if (targets and 'ctags_bbedit' in targets and 'ctags_vi' in targets):
parser.error('cannot build both vi and bbedit ctags files (same name)')
builder = Builder()
builder(targets, options.languages)

try:
import paver.easy
except ImportError:
HAS_PAVER = False
else:
HAS_PAVER = True

if HAS_PAVER:
@paver.easy.task
@paver.easy.consume_args
def tags(args):
"""Build tags database file for emacs, vim, or bbedit"""
build_tags(args)

0 comments on commit aa6ffb3

Please sign in to comment.