[Python-modules-commits] [python-bcdoc] 02/07: Imported Upstream version 0.16.0

Takaki Taniguchi takaki at moszumanska.debian.org
Wed Nov 25 13:08:40 UTC 2015


This is an automated email from the git hooks/post-receive script.

takaki pushed a commit to branch master
in repository python-bcdoc.

commit 8f55b207dfcd6491aec68057b33aff46ac2376a5
Author: TANIGUCHI Takaki <takaki at asis.media-as.org>
Date:   Wed Nov 25 21:56:36 2015 +0900

    Imported Upstream version 0.16.0
---
 PKG-INFO                         | 25 +++-------
 bcdoc.egg-info/PKG-INFO          | 25 +++-------
 bcdoc.egg-info/SOURCES.txt       |  1 +
 bcdoc.egg-info/requires.txt      |  7 ++-
 bcdoc/__init__.py                |  2 +-
 bcdoc/{__init__.py => compat.py} |  8 +++-
 bcdoc/docevents.py               | 77 +++++++++++++++++--------------
 bcdoc/restdoc.py                 | 99 ++++++++++++++++++++++++++++++++++++++++
 bcdoc/style.py                   | 60 ++++++++++++++++++++++++
 requirements.txt                 |  2 +-
 setup.py                         | 32 +++++--------
 11 files changed, 240 insertions(+), 98 deletions(-)

diff --git a/PKG-INFO b/PKG-INFO
index af3ac34..69c0b11 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,23 +1,11 @@
 Metadata-Version: 1.1
 Name: bcdoc
-Version: 0.12.2
+Version: 0.16.0
 Summary: ReST document generation tools for botocore.
 Home-page: https://github.com/botocore/bcdoc
-Author: Mitch Garnaat
-Author-email: mitch at garnaat.com
-License: Copyright 2012-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
-
-Licensed under the Apache License, Version 2.0 (the "License"). You
-may not use this file except in compliance with the License. A copy of
-the License is located at
-
-    http://aws.amazon.com/apache2.0/
-
-or in the "license" file accompanying this file. This file is
-distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
-ANY KIND, either express or implied. See the License for the specific
-language governing permissions and limitations under the License.
-
+Author: Amazon Web Services
+Author-email: UNKNOWN
+License: Apache License 2.0
 Description: bcdoc
         =====
         
@@ -39,6 +27,5 @@ Classifier: Programming Language :: Python
 Classifier: Programming Language :: Python :: 2.6
 Classifier: Programming Language :: Python :: 2.7
 Classifier: Programming Language :: Python :: 3
-Classifier: Programming Language :: Python :: 3.0
-Classifier: Programming Language :: Python :: 3.1
-Classifier: Programming Language :: Python :: 3.2
+Classifier: Programming Language :: Python :: 3.3
+Classifier: Programming Language :: Python :: 3.4
diff --git a/bcdoc.egg-info/PKG-INFO b/bcdoc.egg-info/PKG-INFO
index af3ac34..69c0b11 100644
--- a/bcdoc.egg-info/PKG-INFO
+++ b/bcdoc.egg-info/PKG-INFO
@@ -1,23 +1,11 @@
 Metadata-Version: 1.1
 Name: bcdoc
-Version: 0.12.2
+Version: 0.16.0
 Summary: ReST document generation tools for botocore.
 Home-page: https://github.com/botocore/bcdoc
-Author: Mitch Garnaat
-Author-email: mitch at garnaat.com
-License: Copyright 2012-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
-
-Licensed under the Apache License, Version 2.0 (the "License"). You
-may not use this file except in compliance with the License. A copy of
-the License is located at
-
-    http://aws.amazon.com/apache2.0/
-
-or in the "license" file accompanying this file. This file is
-distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
-ANY KIND, either express or implied. See the License for the specific
-language governing permissions and limitations under the License.
-
+Author: Amazon Web Services
+Author-email: UNKNOWN
+License: Apache License 2.0
 Description: bcdoc
         =====
         
@@ -39,6 +27,5 @@ Classifier: Programming Language :: Python
 Classifier: Programming Language :: Python :: 2.6
 Classifier: Programming Language :: Python :: 2.7
 Classifier: Programming Language :: Python :: 3
-Classifier: Programming Language :: Python :: 3.0
-Classifier: Programming Language :: Python :: 3.1
-Classifier: Programming Language :: Python :: 3.2
+Classifier: Programming Language :: Python :: 3.3
+Classifier: Programming Language :: Python :: 3.4
diff --git a/bcdoc.egg-info/SOURCES.txt b/bcdoc.egg-info/SOURCES.txt
index 3d5ddf2..f20c659 100644
--- a/bcdoc.egg-info/SOURCES.txt
+++ b/bcdoc.egg-info/SOURCES.txt
@@ -5,6 +5,7 @@ requirements.txt
 setup.cfg
 setup.py
 bcdoc/__init__.py
+bcdoc/compat.py
 bcdoc/docevents.py
 bcdoc/docstringparser.py
 bcdoc/restdoc.py
diff --git a/bcdoc.egg-info/requires.txt b/bcdoc.egg-info/requires.txt
index e4e44a4..c6dbdce 100644
--- a/bcdoc.egg-info/requires.txt
+++ b/bcdoc.egg-info/requires.txt
@@ -1,2 +1,5 @@
-six>=1.1.0
-docutils>=0.10
\ No newline at end of file
+six>=1.8.0,<2.0.0
+docutils>=0.10
+
+[:python_version=="2.6"]
+ordereddict==1.1
\ No newline at end of file
diff --git a/bcdoc/__init__.py b/bcdoc/__init__.py
index 56923d0..b687f69 100644
--- a/bcdoc/__init__.py
+++ b/bcdoc/__init__.py
@@ -10,4 +10,4 @@
 # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
 # ANY KIND, either express or implied. See the License for the specific
 # language governing permissions and limitations under the License.
-__version__ = '0.12.2'
+__version__ = '0.16.0'
diff --git a/bcdoc/__init__.py b/bcdoc/compat.py
similarity index 67%
copy from bcdoc/__init__.py
copy to bcdoc/compat.py
index 56923d0..ee6d7c9 100644
--- a/bcdoc/__init__.py
+++ b/bcdoc/compat.py
@@ -1,4 +1,4 @@
-# Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+# Copyright 2012-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
 #
 # Licensed under the Apache License, Version 2.0 (the "License"). You
 # may not use this file except in compliance with the License. A copy of
@@ -10,4 +10,8 @@
 # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
 # ANY KIND, either express or implied. See the License for the specific
 # language governing permissions and limitations under the License.
-__version__ = '0.12.2'
+try:
+    from collections import OrderedDict
+except ImportError:
+    # Python2.6 we use the 3rd party back port.
+    from ordereddict import OrderedDict
diff --git a/bcdoc/docevents.py b/bcdoc/docevents.py
index 4dde8ef..fb3d87f 100644
--- a/bcdoc/docevents.py
+++ b/bcdoc/docevents.py
@@ -13,21 +13,24 @@
 
 
 DOC_EVENTS = {
-    'doc-breadcrumbs': '.%s.%s',
-    'doc-title': '.%s.%s',
-    'doc-description': '.%s.%s',
-    'doc-synopsis-start': '.%s.%s',
-    'doc-synopsis-option': '.%s.%s.%s',
-    'doc-synopsis-end': '.%s.%s',
-    'doc-options-start': '.%s.%s',
-    'doc-option': '.%s.%s.%s',
-    'doc-option-example': '.%s.%s.%s',
-    'doc-options-end': '.%s.%s',
-    'doc-examples': '.%s.%s',
-    'doc-output': '.%s.%s',
-    'doc-subitems-start': '.%s.%s',
-    'doc-subitem': '.%s.%s.%s',
-    'doc-subitems-end': '.%s.%s',
+    'doc-breadcrumbs': '.%s',
+    'doc-title': '.%s',
+    'doc-description': '.%s',
+    'doc-synopsis-start': '.%s',
+    'doc-synopsis-option': '.%s.%s',
+    'doc-synopsis-end': '.%s',
+    'doc-options-start': '.%s',
+    'doc-option': '.%s.%s',
+    'doc-option-example': '.%s.%s',
+    'doc-options-end': '.%s',
+    'doc-examples': '.%s',
+    'doc-output': '.%s',
+    'doc-subitems-start': '.%s',
+    'doc-subitem': '.%s.%s',
+    'doc-subitems-end': '.%s',
+    'doc-relateditems-start': '.%s',
+    'doc-relateditem': '.%s.%s',
+    'doc-relateditems-end': '.%s'
     }
 
 
@@ -43,13 +46,13 @@ def generate_events(session, help_command):
                                DOC_EVENTS[event_name])
     # Now generate the documentation events
     fire_event(session, 'doc-breadcrumbs', help_command.event_class,
-               help_command.name, help_command=help_command)
+               help_command=help_command)
     fire_event(session, 'doc-title', help_command.event_class,
-               help_command.name, help_command=help_command)
+               help_command=help_command)
     fire_event(session, 'doc-description', help_command.event_class,
-               help_command.name, help_command=help_command)
+               help_command=help_command)
     fire_event(session, 'doc-synopsis-start', help_command.event_class,
-               help_command.name, help_command=help_command)
+               help_command=help_command)
     if help_command.arg_table:
         for arg_name in help_command.arg_table:
             # An argument can set an '_UNDOCUMENTED' attribute
@@ -60,40 +63,46 @@ def generate_events(session, help_command):
                        '_UNDOCUMENTED', False):
                 continue
             fire_event(session, 'doc-synopsis-option',
-                       help_command.event_class,
-                       help_command.name, arg_name,
+                       help_command.event_class, arg_name,
                        arg_name=arg_name, help_command=help_command)
     fire_event(session, 'doc-synopsis-end', help_command.event_class,
-               help_command.name, help_command=help_command)
+               help_command=help_command)
     fire_event(session, 'doc-options-start', help_command.event_class,
-               help_command.name, help_command=help_command)
+               help_command=help_command)
     if help_command.arg_table:
         for arg_name in help_command.arg_table:
             if getattr(help_command.arg_table[arg_name],
                        '_UNDOCUMENTED', False):
                 continue
             fire_event(session, 'doc-option', help_command.event_class,
-                       help_command.name, arg_name,
-                       arg_name=arg_name, help_command=help_command)
+                       arg_name, arg_name=arg_name, help_command=help_command)
             fire_event(session, 'doc-option-example',
                        help_command.event_class,
-                       help_command.name, arg_name,
-                       arg_name=arg_name, help_command=help_command)
+                       arg_name, arg_name=arg_name, help_command=help_command)
     fire_event(session, 'doc-options-end', help_command.event_class,
-               help_command.name, help_command=help_command)
+               help_command=help_command)
     fire_event(session, 'doc-subitems-start', help_command.event_class,
-               help_command.name, help_command=help_command)
+               help_command=help_command)
     if help_command.command_table:
         for command_name in sorted(help_command.command_table.keys()):
             if hasattr(help_command.command_table[command_name],
                        '_UNDOCUMENTED'):
                 continue
             fire_event(session, 'doc-subitem', help_command.event_class,
-                       help_command.name, command_name,
-                       command_name=command_name, help_command=help_command)
+                       command_name, command_name=command_name,
+                       help_command=help_command)
     fire_event(session, 'doc-subitems-end', help_command.event_class,
-               help_command.name, help_command=help_command)
+               help_command=help_command)
     fire_event(session, 'doc-examples', help_command.event_class,
-               help_command.name, help_command=help_command)
+               help_command=help_command)
     fire_event(session, 'doc-output', help_command.event_class,
-               help_command.name, help_command=help_command)
+               help_command=help_command)
+    fire_event(session, 'doc-relateditems-start', help_command.event_class,
+               help_command=help_command)
+    if help_command.related_items:
+        for related_item in sorted(help_command.related_items):
+            fire_event(session, 'doc-relateditem', help_command.event_class,
+                       related_item, help_command=help_command,
+                       related_item=related_item)
+    fire_event(session, 'doc-relateditems-end', help_command.event_class,
+               help_command=help_command)
diff --git a/bcdoc/restdoc.py b/bcdoc/restdoc.py
index 11fe0fe..34d493e 100644
--- a/bcdoc/restdoc.py
+++ b/bcdoc/restdoc.py
@@ -11,6 +11,8 @@
 # ANY KIND, either express or implied. See the License for the specific
 # language governing permissions and limitations under the License.
 import logging
+
+from bcdoc.compat import OrderedDict
 from bcdoc.docstringparser import DocStringParser
 from bcdoc.style import ReSTStyle
 
@@ -98,3 +100,100 @@ class ReSTDocument(object):
         if self._last_doc_string is not None:
             start, end = self._last_doc_string
             del self._writes[start:end]
+
+
+class DocumentStructure(ReSTDocument):
+    def __init__(self, name, section_names=None, target='man'):
+        """Provides a Hierarichial structure to a ReSTDocument
+
+        You can write to it similiar to as you can to a ReSTDocument but
+        has an innate structure for more orginaztion and abstraction.
+
+        :param name: The name of the document
+        :param section_names: A list of sections to be included
+            in the document.
+        :parma target: The target documentation of the Document structure
+        """
+        super(DocumentStructure, self).__init__(target=target)
+        self._name = name
+        self._structure = OrderedDict()
+        self._path = [self._name]
+        if section_names is not None:
+            self._generate_structure(section_names)
+
+    @property
+    def name(self):
+        """The name of the document structure"""
+        return self._name
+
+    @property
+    def path(self):
+        """
+        A list of where to find a particular document structure in the
+        overlying document structure.
+        """
+        return self._path
+
+    @path.setter
+    def path(self, value):
+        self._path = value
+
+    @property
+    def available_sections(self):
+        return list(self._structure)
+
+    def _generate_structure(self, section_names):
+        for section_name in section_names:
+            self.add_new_section(section_name)
+
+    def add_new_section(self, name):
+        """Adds a new section to the current document structure
+
+        This document structure will be considered a section to the
+        current document structure but will in itself be an entirely
+        new document structure that can be written to and have sections
+        as well
+
+        :param name: The name of the section.
+        :rtype: DocumentStructure
+        :returns: A new document structure to add to but lives as a section
+            to the document structure it was instantiated from.
+        """
+        # Add a new section
+        section = self.__class__(name=name, target=self.target)
+        section.path = self.path + [name]
+        # Indent the section apporpriately as well
+        section.style.indentation = self.style.indentation
+        section.translation_map = self.translation_map
+        section.hrefs = self.hrefs
+        self._structure[name] = section
+        return section
+
+    def get_section(self, name):
+        """Retrieve a section"""
+        return self._structure[name]
+
+    def delete_section(self, name):
+        """Delete a section"""
+        del self._structure[name]
+
+    def flush_structure(self):
+        """Flushes a doc structure to a ReSTructed string
+
+        The document is flushed out in a DFS style where sections and their
+        subsections' values are added to the string as they are visited.
+        """
+        # We are at the root flush the links at the beginning of the
+        # document
+        if len(self.path) == 1:
+            if self.hrefs:
+                self.style.new_paragraph()
+                for refname, link in self.hrefs.items():
+                    self.style.link_target_definition(refname, link)
+        value = self.getvalue()
+        for name, section in self._structure.items():
+            value += section.flush_structure()
+        return value
+
+    def getvalue(self):
+        return ''.join(self._writes).encode('utf-8')
diff --git a/bcdoc/style.py b/bcdoc/style.py
index 87708b9..6e30f00 100644
--- a/bcdoc/style.py
+++ b/bcdoc/style.py
@@ -24,6 +24,14 @@ class BaseStyle(object):
         self._indent = 0
         self.keep_data = True
 
+    @property
+    def indentation(self):
+        return self._indent
+
+    @indentation.setter
+    def indentation(self, value):
+        self._indent = value
+
     def new_paragraph(self):
         return '\n%s' % self.spaces()
 
@@ -196,6 +204,14 @@ class ReSTStyle(BaseStyle):
     def link_target_definition(self, refname, link):
         self.doc.writeln('.. _%s: %s' % (refname, link))
 
+    def sphinx_reference_label(self, label, text=None):
+        if text is None:
+            text = label
+        if self.doc.target == 'html':
+            self.doc.write(':ref:`%s <%s>`' % (text, label))
+        else:
+            self.doc.write(text)
+
     def end_a(self):
         self.doc.do_translation = False
         if self.a_href:
@@ -306,3 +322,47 @@ class ReSTStyle(BaseStyle):
             else:
                 self.doc.writeln('  %s' % item)
 
+    def hidden_toctree(self):
+        if self.doc.target == 'html':
+            self.doc.write('\n.. toctree::\n')
+            self.doc.write('  :maxdepth: 1\n')
+            self.doc.write('  :hidden:\n\n')
+
+    def hidden_tocitem(self, item):
+        if self.doc.target == 'html':
+            self.tocitem(item)
+
+    def table_of_contents(self, title=None, depth=None):
+        self.doc.write('.. contents:: ')
+        if title is not None:
+            self.doc.writeln(title)
+        if depth is not None:
+            self.doc.writeln('   :depth: %s' % depth)
+
+    def start_sphinx_py_class(self, class_name):
+        self.new_paragraph()
+        self.doc.write('.. py:class:: %s' % class_name)
+        self.indent()
+        self.new_paragraph()
+
+    def end_sphinx_py_class(self):
+        self.dedent()
+        self.new_paragraph()
+
+    def start_sphinx_py_method(self, method_name, parameters=None):
+        self.new_paragraph()
+        content = '.. py:method:: %s' % method_name
+        if parameters is not None:
+            content += '(%s)' % parameters
+        self.doc.write(content)
+        self.indent()
+        self.new_paragraph()
+
+    def end_sphinx_py_method(self):
+        self.dedent()
+        self.new_paragraph()
+
+    def write_py_doc_string(self, docstring):
+        docstring_lines = docstring.splitlines()
+        for docstring_line in docstring_lines:
+            self.doc.writeln(docstring_line)
diff --git a/requirements.txt b/requirements.txt
index 7136dd4..2fd360f 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,2 +1,2 @@
-six==1.1.0
+six>=1.8.0,<2.0.0
 docutils>=0.10
diff --git a/setup.py b/setup.py
index 29fc892..e119fe9 100644
--- a/setup.py
+++ b/setup.py
@@ -1,35 +1,28 @@
 #!/usr/bin/env python
+import sys
 
-"""
-distutils/setuptools install script.
-"""
 
-try:
-    from setuptools import setup
-    setup
-except ImportError:
-    from distutils.core import setup
+from setuptools import setup
 
-packages = [
-    'bcdoc',
-]
 
-requires = ['six>=1.1.0',
+requires = ['six>=1.8.0,<2.0.0',
             'docutils>=0.10']
 
 
 setup(
     name='bcdoc',
-    version='0.12.2',
+    version='0.16.0',
     description='ReST document generation tools for botocore.',
     long_description=open('README.rst').read(),
-    author='Mitch Garnaat',
-    author_email='mitch at garnaat.com',
+    author='Amazon Web Services',
     url='https://github.com/botocore/bcdoc',
-    packages=packages,
+    packages=['bcdoc'],
     package_dir={'bcdoc': 'bcdoc'},
     install_requires=requires,
-    license=open("LICENSE.txt").read(),
+    extras_require={
+        ':python_version=="2.6"': ['ordereddict==1.1'],
+    },
+    license='Apache License 2.0',
     classifiers=(
         'Development Status :: 3 - Alpha',
         'Intended Audience :: Developers',
@@ -40,8 +33,7 @@ setup(
         'Programming Language :: Python :: 2.6',
         'Programming Language :: Python :: 2.7',
         'Programming Language :: Python :: 3',
-        'Programming Language :: Python :: 3.0',
-        'Programming Language :: Python :: 3.1',
-        'Programming Language :: Python :: 3.2',
+        'Programming Language :: Python :: 3.3',
+        'Programming Language :: Python :: 3.4',
     ),
 )

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-bcdoc.git



More information about the Python-modules-commits mailing list