From: Rok G. <svn...@pl...> - 2008-11-09 09:58:03
|
Author: garbas Date: Sun Nov 9 09:57:50 2008 New Revision: 75333 Added: collective.sphinx.includedoc/ collective.sphinx.includedoc/branches/ collective.sphinx.includedoc/tags/ collective.sphinx.includedoc/trunk/ collective.sphinx.includedoc/trunk/CHANGES.txt collective.sphinx.includedoc/trunk/CONTRIBUTORS.txt collective.sphinx.includedoc/trunk/MANIFEST.in collective.sphinx.includedoc/trunk/README.txt collective.sphinx.includedoc/trunk/bootstrap.py collective.sphinx.includedoc/trunk/buildout.cfg collective.sphinx.includedoc/trunk/collective/ collective.sphinx.includedoc/trunk/collective/__init__.py collective.sphinx.includedoc/trunk/collective/sphinx/ collective.sphinx.includedoc/trunk/collective/sphinx/__init__.py collective.sphinx.includedoc/trunk/collective/sphinx/includedoc/ collective.sphinx.includedoc/trunk/collective/sphinx/includedoc/__init__.py collective.sphinx.includedoc/trunk/setup.cfg collective.sphinx.includedoc/trunk/setup.py Log: collective.sphinx.includedoc - extension for sphinx Added: collective.sphinx.includedoc/trunk/CHANGES.txt ============================================================================== --- (empty file) +++ collective.sphinx.includedoc/trunk/CHANGES.txt Sun Nov 9 09:57:50 2008 @@ -0,0 +1,4 @@ +0.1 (xxxx-xx-xx) +================== + + - Created recipe with ZopeSkel [Rok Garbas]. Added: collective.sphinx.includedoc/trunk/CONTRIBUTORS.txt ============================================================================== --- (empty file) +++ collective.sphinx.includedoc/trunk/CONTRIBUTORS.txt Sun Nov 9 09:57:50 2008 @@ -0,0 +1,2 @@ +Rok Garbas, Author + Added: collective.sphinx.includedoc/trunk/MANIFEST.in ============================================================================== --- (empty file) +++ collective.sphinx.includedoc/trunk/MANIFEST.in Sun Nov 9 09:57:50 2008 @@ -0,0 +1,3 @@ +recursive-include collective * +global-exclude *pyc + Added: collective.sphinx.includedoc/trunk/README.txt ============================================================================== --- (empty file) +++ collective.sphinx.includedoc/trunk/README.txt Sun Nov 9 09:57:50 2008 @@ -0,0 +1,17 @@ +.. contents:: + +.. Note to recipe author! + --------------------- + Update the following URLs to point to your: + + - code repository + - bug tracker + - questions/comments feedback mail + (do not set a real mail, to avoid spams) + + Or remove it if not used. + +- Code repository: http://svn.somewhere.com/... +- Questions and comments to somemailing_list +- Report bugs at http://bug.somewhere.com/.. + Added: collective.sphinx.includedoc/trunk/bootstrap.py ============================================================================== --- (empty file) +++ collective.sphinx.includedoc/trunk/bootstrap.py Sun Nov 9 09:57:50 2008 @@ -0,0 +1,52 @@ +############################################################################## +# +# Copyright (c) 2006 Zope Corporation and Contributors. +# All Rights Reserved. +# +# This software is subject to the provisions of the Zope Public License, +# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. +# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED +# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS +# FOR A PARTICULAR PURPOSE. +# +############################################################################## +"""Bootstrap a buildout-based project + +Simply run this script in a directory containing a buildout.cfg. +The script accepts buildout command-line options, so you can +use the -c option to specify an alternate configuration file. + +$Id$ +""" + +import os, shutil, sys, tempfile, urllib2 + +tmpeggs = tempfile.mkdtemp() + +ez = {} +exec urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py' + ).read() in ez +ez['use_setuptools'](to_dir=tmpeggs, download_delay=0) + +import pkg_resources + +cmd = 'from setuptools.command.easy_install import main; main()' +if sys.platform == 'win32': + cmd = '"%s"' % cmd # work around spawn lamosity on windows + +ws = pkg_resources.working_set +assert os.spawnle( + os.P_WAIT, sys.executable, sys.executable, + '-c', cmd, '-mqNxd', tmpeggs, 'zc.buildout', + dict(os.environ, + PYTHONPATH= + ws.find(pkg_resources.Requirement.parse('setuptools')).location + ), + ) == 0 + +ws.add_entry(tmpeggs) +ws.require('zc.buildout') +import zc.buildout.buildout +zc.buildout.buildout.main(sys.argv[1:] + ['bootstrap']) +shutil.rmtree(tmpeggs) Added: collective.sphinx.includedoc/trunk/buildout.cfg ============================================================================== --- (empty file) +++ collective.sphinx.includedoc/trunk/buildout.cfg Sun Nov 9 09:57:50 2008 @@ -0,0 +1,8 @@ +[buildout] +develop = . +parts = test + +[test] +recipe = zc.recipe.testrunner +eggs = collective.sphinx.includedoc [tests] + Added: collective.sphinx.includedoc/trunk/collective/__init__.py ============================================================================== --- (empty file) +++ collective.sphinx.includedoc/trunk/collective/__init__.py Sun Nov 9 09:57:50 2008 @@ -0,0 +1,6 @@ +# See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages +try: + __import__('pkg_resources').declare_namespace(__name__) +except ImportError: + from pkgutil import extend_path + __path__ = extend_path(__path__, __name__) Added: collective.sphinx.includedoc/trunk/collective/sphinx/__init__.py ============================================================================== --- (empty file) +++ collective.sphinx.includedoc/trunk/collective/sphinx/__init__.py Sun Nov 9 09:57:50 2008 @@ -0,0 +1,6 @@ +# See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages +try: + __import__('pkg_resources').declare_namespace(__name__) +except ImportError: + from pkgutil import extend_path + __path__ = extend_path(__path__, __name__) Added: collective.sphinx.includedoc/trunk/collective/sphinx/includedoc/__init__.py ============================================================================== --- (empty file) +++ collective.sphinx.includedoc/trunk/collective/sphinx/includedoc/__init__.py Sun Nov 9 09:57:50 2008 @@ -0,0 +1,76 @@ +# -*- coding: utf-8 -*- + +import os +import sys +import textwrap +from docutils.nodes import section +from docutils.parsers.rst import Directive +from docutils.statemachine import ViewList, StringList, string2lines +from sphinx.ext.autodoc import prepare_docstring + + +TABLE_COLS = ['Name', 'Required', 'Searchable', 'Type', 'Storage'] + +class IncludeDocDirective(Directive): + """ + """ + required_arguments = 1 + has_content = False + + def __init__(self, + directive, + arguments, + options, # ignored + content, # ignored + lineno, # ignored + content_offset, # ignored + block_text, # ignored + state, + state_machine, # ignored + ): + assert directive == 'includedoc' + assert len(arguments) == 1 + assert len(arguments[0].split(':')) == 2 + self.module, self.doc = arguments[0].split(':') + self.state = state + self.lineno = lineno + + def run(self): + + module = _resolve_dotted_name(self.module) + if not getattr(module, '__file__', None): + raise 'No module found for: ' + self.module + + module_path = os.path.abspath(os.path.dirname(module.__file__)) + doc_path = module_path + self.doc + + if not os.path.isfile(doc_path): + raise 'No doc found for: ' + doc_path + + result = ViewList() + result.append(u'', '<includedoc>') + #for i, line in enumerate(get_doc(what, self.module+':'+self+doc, todoc, options, env)): + for i, line in enumerate(prepare_docstring(open(doc_path).read())): + result.append(line, '%s:docstring of %s' % (self.doc, self.module), i) + result.append(u'', '<includedoc>') + + node = section() + surrounding_title_styles = self.state.memo.title_styles + surrounding_section_level = self.state.memo.section_level + self.state.memo.title_styles = [] + self.state.memo.section_level = 0 + self.state.nested_parse(result, 0, node, match_titles=1) + self.state.memo.title_styles = surrounding_title_styles + self.state.memo.section_level = surrounding_section_level + + return node.children + +def _resolve_dotted_name(dotted): + tokens = dotted.split('.') + path, name = tokens[:-1], tokens[-1] + thing = __import__('.'.join(path), {}, {}, [str(name)]) + return getattr(thing, name) + +def setup(app): + app.add_directive('includedoc', IncludeDocDirective, + 0, (1, 0, 1) ) Added: collective.sphinx.includedoc/trunk/setup.cfg ============================================================================== --- (empty file) +++ collective.sphinx.includedoc/trunk/setup.cfg Sun Nov 9 09:57:50 2008 @@ -0,0 +1,3 @@ +[egg_info] +tag_build = dev +tag_svn_revision = true Added: collective.sphinx.includedoc/trunk/setup.py ============================================================================== --- (empty file) +++ collective.sphinx.includedoc/trunk/setup.py Sun Nov 9 09:57:50 2008 @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +""" +This module contains the tool of collective.sphinx.includedoc +""" +import os +from setuptools import setup, find_packages + +def read(*rnames): + return open(os.path.join(os.path.dirname(__file__), *rnames)).read() + +version = '0.1b1' + +long_description = ( + read('README.txt') + + '\n' + + 'Contributors\n' + '************\n' + + '\n' + + read('CONTRIBUTORS.txt') + + '\n' + + 'Change history\n' + '**************\n' + + '\n' + + read('CHANGES.txt') + + '\n' + + 'Download\n' + '********\n' + ) +setup(name='collective.sphinx.includedoc', + version=version, + description="Sphinx extension for includingi doctests", + long_description=long_description, + # Get more strings from http://www.python.org/pypi?%3Aaction=list_classifiers + classifiers=[ + "Intended Audience :: Developers", + "Programming Language :: Python", + "License :: OSI Approved :: GNU General Public License (GPL)", + ], + keywords='zope archetypes sphinx documentation', + author='Rok Garbas', + author_email='ro...@ga...', + url='http://', + license='GPL', + packages=find_packages(exclude=['ez_setup']), + namespace_packages=['collective', 'collective.sphinx'], + include_package_data=True, + zip_safe=False, + install_requires=['docutils', 'Sphinx', 'zc.recipe.egg'], + ) |