Package pyrobase :: Package paver :: Module documentation
[hide private]
[frames] | no frames]

Source Code for Module pyrobase.paver.documentation

 1  # -*- coding: utf-8 -*- 
 2  # pylint: disable=expression-not-assigned 
 3  """ Paver Documentation Generator Tasks. 
 4   
 5      Copyright (c) 2011 The PyroScope Project <pyroscope.project@gmail.com> 
 6  """ 
 7  # This program is free software; you can redistribute it and/or modify 
 8  # it under the terms of the GNU General Public License as published by 
 9  # the Free Software Foundation; either version 2 of the License, or 
10  # (at your option) any later version. 
11  # 
12  # This program is distributed in the hope that it will be useful, 
13  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
15  # GNU General Public License for more details. 
16  # 
17  # You should have received a copy of the GNU General Public License along 
18  # with this program; if not, write to the Free Software Foundation, Inc., 
19  # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 
20  import os 
21  import re 
22  import sys 
23   
24  from paver import easy 
25   
26  from pyrobase.paver import support 
27   
28   
29  @easy.task 
30  @easy.cmdopts([ 
31      ('docs-dir=', 'd', 'directory to put the api documentation in'), 
32      ('includes=', 'i', 'list of additional packages'), 
33      ('excludes=', 'x', 'list of packages to exclude'), 
34  ]) 
35 @support.task_requires("epydoc>=3.0") 36 -def docs():
37 "create documentation" 38 from epydoc import cli # pylint: disable=W0404 39 40 easy.path('build').exists() or easy.path('build').makedirs() 41 42 # get storage path 43 docs_dir = easy.options.docs.get('docs_dir', 'build/apidocs') 44 45 # clean up previous docs 46 (easy.path(docs_dir) / "epydoc.css").exists() and easy.path(docs_dir).rmtree() 47 48 # set up includes 49 try: 50 include_names = easy.options.docs.includes 51 except AttributeError: 52 include_names = [] 53 else: 54 include_names = include_names.replace(',', ' ').split() 55 56 # set up excludes 57 try: 58 exclude_names = easy.options.docs.excludes 59 except AttributeError: 60 exclude_names = [] 61 else: 62 exclude_names = exclude_names.replace(',', ' ').split() 63 64 excludes = [] 65 for pkg in exclude_names: 66 excludes.append("--exclude") 67 excludes.append('^' + re.escape(pkg)) 68 69 # call epydoc in-process 70 sys_argv = sys.argv 71 try: 72 sys.argv = [ 73 sys.argv[0] + "::epydoc", 74 "-v", 75 "--inheritance", "listed", 76 "--output", os.path.abspath(docs_dir), 77 "--name", "%s %s" % (easy.options.setup.name, easy.options.setup.version), 78 "--url", easy.options.setup.url, 79 "--graph", "umlclasstree", 80 ] + excludes + support.toplevel_packages() + include_names 81 sys.stderr.write("Running '%s'\n" % ("' '".join(sys.argv))) 82 cli.cli() 83 finally: 84 sys.argv = sys_argv
85