diff options
author | Tom Rondeau <tom@trondeau.com> | 2014-07-07 12:18:00 -0400 |
---|---|---|
committer | Tom Rondeau <tom@trondeau.com> | 2014-07-07 12:18:00 -0400 |
commit | 597b93798a804cde1783d6d2ab53b348d57c44cd (patch) | |
tree | b65e73bb0de634ff5d209b15971ebdabf369a45c /docs/sphinx | |
parent | 1151e5502ccd440ebd89599cf7e4be4fb5ed8334 (diff) |
Removing trailing/extra whitespaces before release.
We should be more careful about letting these into the code in the future. In emacs, we can use (add-hook 'before-save-hook 'delete-trailing-whitespace).
Diffstat (limited to 'docs/sphinx')
-rw-r--r-- | docs/sphinx/CMakeLists.txt | 8 | ||||
-rw-r--r-- | docs/sphinx/README | 2 | ||||
-rw-r--r-- | docs/sphinx/gnuradio_sphinx.py | 64 | ||||
-rw-r--r-- | docs/sphinx/hieroglyph/errors.py | 18 | ||||
-rw-r--r-- | docs/sphinx/hieroglyph/nodes.py | 534 | ||||
-rw-r--r-- | docs/sphinx/hieroglyph/test/__init__.py | 1 | ||||
-rw-r--r-- | docs/sphinx/hieroglyph/test/test_hierglyph.py | 528 | ||||
-rw-r--r-- | docs/sphinx/hieroglyph/test/test_nodes.py | 772 | ||||
-rw-r--r-- | docs/sphinx/hieroglyph/version.py | 6 | ||||
-rw-r--r-- | docs/sphinx/source/analog/get_blocks.py | 4 | ||||
-rw-r--r-- | docs/sphinx/source/atsc/index.rst | 8 | ||||
-rw-r--r-- | docs/sphinx/source/blocks/get_blocks.py | 4 | ||||
-rw-r--r-- | docs/sphinx/source/gr/index.rst | 2 | ||||
-rw-r--r-- | docs/sphinx/source/index.rst | 18 | ||||
-rw-r--r-- | docs/sphinx/source/pmt/index.rst | 2 | ||||
-rw-r--r-- | docs/sphinx/source/trellis/index.rst | 4 |
16 files changed, 987 insertions, 988 deletions
diff --git a/docs/sphinx/CMakeLists.txt b/docs/sphinx/CMakeLists.txt index 38d77fb3aa..23cb460517 100644 --- a/docs/sphinx/CMakeLists.txt +++ b/docs/sphinx/CMakeLists.txt @@ -1,17 +1,17 @@ # Copyright 2012 Free Software Foundation, Inc. -# +# # This file is part of GNU Radio -# +# # GNU Radio is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3, or (at your option) # any later version. -# +# # GNU Radio is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with GNU Radio; see the file COPYING. If not, write to # the Free Software Foundation, Inc., 51 Franklin Street, diff --git a/docs/sphinx/README b/docs/sphinx/README index 0ae3a43f84..7d2c977d3b 100644 --- a/docs/sphinx/README +++ b/docs/sphinx/README @@ -15,7 +15,7 @@ benefits. First, the Sphinx documentation looks nice and is formatted in such a way that Python users of GNU Radio can easy see the module structure and hierarchy. It also not only takes the Doxygen documentation from C++, but it also allows us to take any Python files -and include their documentation. +and include their documentation. The end result is two manuals: one for Python and one for C++ users without having to duplicate comments, markup, or documentation. diff --git a/docs/sphinx/gnuradio_sphinx.py b/docs/sphinx/gnuradio_sphinx.py index 8b52ed3ba6..22b96c32e7 100644 --- a/docs/sphinx/gnuradio_sphinx.py +++ b/docs/sphinx/gnuradio_sphinx.py @@ -30,7 +30,7 @@ def fix_signature(app, what, name, obj, options, signature, return_annotation): SWIG produces signature at the top of docstrings of the form 'blah(int arg1, float arg2) -> return_type' and if the string is long it breaks it over multiple lines. - + Sphinx gets confused if it is broken over multiple lines. fix_signature and remove_lines get around this problem. """ @@ -107,31 +107,31 @@ common_block_members =[ 'to_basic_block', 'unique_id', 'make', - 'alias', - 'is_set_max_noutput_items', - 'max_noutput_items', - 'max_output_buffer', - 'message_ports_in', - 'message_ports_out', - 'min_output_buffer', - 'pc_input_buffers_full', - 'pc_input_buffers_full_var', - 'pc_noutput_items', - 'pc_noutput_items_var', - 'pc_nproduced', - 'pc_nproduced_var', - 'pc_output_buffers_full', - 'pc_output_buffers_full_var', - 'pc_work_time', - 'pc_work_time_var', - 'processor_affinity', - 'set_block_alias', - 'set_max_noutput_items', - 'unset_max_noutput_items', - 'set_max_output_buffer', - 'set_min_output_buffer', - 'set_processor_affinity', - 'symbol_name', + 'alias', + 'is_set_max_noutput_items', + 'max_noutput_items', + 'max_output_buffer', + 'message_ports_in', + 'message_ports_out', + 'min_output_buffer', + 'pc_input_buffers_full', + 'pc_input_buffers_full_var', + 'pc_noutput_items', + 'pc_noutput_items_var', + 'pc_nproduced', + 'pc_nproduced_var', + 'pc_output_buffers_full', + 'pc_output_buffers_full_var', + 'pc_work_time', + 'pc_work_time_var', + 'processor_affinity', + 'set_block_alias', + 'set_max_noutput_items', + 'unset_max_noutput_items', + 'set_max_output_buffer', + 'set_min_output_buffer', + 'set_processor_affinity', + 'symbol_name', 'unset_processor_affinity', 'disconnect_all', 'index', @@ -159,14 +159,14 @@ class OldBlockDocumenter(FunctionDocumenter): objtype = 'oldblock' directivetype = 'function' # Don't want to use this for generic functions for give low priority. - priority = -10 - + priority = -10 + def __init__(self, *args, **kwargs): super(OldBlockDocumenter, self).__init__(*args, **kwargs) # Get class name bits = self.name.split('.') if len(bits) != 3 or bits[0] != 'gnuradio': - raise ValueError("expected name to be of form gnuradio.x.y but it is {0}".format(self.name)) + raise ValueError("expected name to be of form gnuradio.x.y but it is {0}".format(self.name)) sptr_name = 'gnuradio.{0}.{0}_{1}_sptr'.format(bits[1], bits[2]) # Create a Class Documenter to create documentation for the classes members. self.classdoccer = ClassDocumenter(self.directive, sptr_name, indent=self.content_indent) @@ -191,8 +191,8 @@ class BlockDocumenter(FunctionDocumenter): objtype = 'block' directivetype = 'function' # Don't want to use this for generic functions for give low priority. - priority = -10 - + priority = -10 + def __init__(self, *args, **kwargs): super(BlockDocumenter, self).__init__(*args, **kwargs) # Get class name @@ -215,7 +215,7 @@ class PyBlockDocumenter(ClassDocumenter): """ objtype = 'pyblock' directivetype = 'class' - + def __init__(self, *args, **kwargs): super(PyBlockDocumenter, self).__init__(*args, **kwargs) self.options.members = ALL diff --git a/docs/sphinx/hieroglyph/errors.py b/docs/sphinx/hieroglyph/errors.py index 334b097d8a..9c1d2213b2 100644 --- a/docs/sphinx/hieroglyph/errors.py +++ b/docs/sphinx/hieroglyph/errors.py @@ -1,10 +1,10 @@ -
-from sphinx.errors import ExtensionError
-
-__author__ = 'rjs'
-
-class HieroglyphError(ExtensionError):
- '''
- An exception type specific to the Hieroglyph Sphinx extension.
- '''
+ +from sphinx.errors import ExtensionError + +__author__ = 'rjs' + +class HieroglyphError(ExtensionError): + ''' + An exception type specific to the Hieroglyph Sphinx extension. + ''' pass
\ No newline at end of file diff --git a/docs/sphinx/hieroglyph/nodes.py b/docs/sphinx/hieroglyph/nodes.py index e583ce04d7..f0c08b5621 100644 --- a/docs/sphinx/hieroglyph/nodes.py +++ b/docs/sphinx/hieroglyph/nodes.py @@ -1,267 +1,267 @@ -__author__ = 'Robert Smallshire'
-
-class Node(object):
-
- def __init__(self, indent=None, lines=None, parent=None):
- if indent is not None:
- self.indent = indent
- else:
- self.indent = 0
-
- if lines is not None:
- self.lines = lines
- else:
- self.lines = []
-
- self._parent = parent
-
- self.children = []
-
- parent = property(lambda self: self._parent)
-
- def add_child(self, child):
- assert(child.parent is self)
- self.children.append(child)
-
-
- def __repr__(self):
- return "Node(" + repr(self.indent) + ", " + repr(self.lines) + ", children=" + repr(self.children) + ")"
-
-
- def render_rst(self, *args, **kwargs):
- result = []
- prefix = ' ' * self.indent
- result.extend(prefix + line for line in self.lines)
- for child in self.children:
- result.extend(child.render_rst())
- return result
-
-
-
-class Arg(Node):
-
- def __init__(self, indent, child_indent, name):
- super(Arg, self).__init__(indent)
- self.child_indent = child_indent
- self.name = name
- self.type = None
-
-
- def __repr__(self):
- return "Arg(" + repr(self.name) + ", " + repr(self.type) + ", children=" + repr(self.children) + ")"
-
-
- def render_rst(self, *args, **kwargs):
- result = []
- indent = ' ' * self.indent
-
- # Render the param description
- description = []
- for child in self.children:
- child_lines = child.render_rst()
- description.extend(child_lines)
-
- dedent = self.child_indent - self.indent
-
- name = self.name.replace('*', r'\*')
-
- first_description = description[0].lstrip() if len(description) else ''
- if not first_description:
- # TODO: Emit a warning about a missing argument description
- pass
-
- result.append("{indent}:param {name}: {first_description}".format(indent=indent, name=name,
- first_description=first_description))
-
- dedented_body = [line[dedent:] for line in description[1:]]
-
- result.extend(dedented_body)
-
- # If a type was specified render the type
- if self.type is not None:
- result.append("{indent}:type {name}: {type}".format(indent=indent, name=self.name, type=self.type))
- result.append('')
-
- ensure_terminal_blank(result)
-
- return result
-
-
-
-class Raises(Node):
-
- def __init__(self, indent=None):
- super(Raises, self).__init__(indent=indent)
-
- def __repr__(self):
- return "Raises(" + repr(self.indent) + ", children=" + repr(self.children) + ")"
-
-
- def render_rst(self, *args, **kwargs):
- result = []
- indent = ' ' * self.indent
- result.append(indent + ':raises:')
- for child in self.children:
- result.extend(child.render_rst(only_child=len(self.children) == 1))
-
- ensure_terminal_blank(result)
-
- return result
-
-
-class Except(Node):
-
- def __init__(self, indent, type):
- super(Except, self).__init__(indent=indent)
- #self.child_indent = child_indent
- self.type = type
-
-
- def __repr__(self):
- return "Except(" + repr(self.type) + ", children=" + repr(self.children) + ")"
-
-
- def render_rst(self, only_child=False, *args, **kwargs):
- result = []
- indent = ' ' * self.indent
-
- # Render the param description
- description = []
- for child in self.children:
- child_lines = child.render_rst()
- description.extend(child_lines)
-
- #dedent = self.child_indent - self.indent
- bullet = '* ' if not only_child else ''
-
- first_description = description[0].lstrip() if len(description) else ''
- result.append("{indent}{bullet}{type} - {first_description}".format(indent=indent,
- bullet=bullet, type=self.type,
- first_description=first_description))
-
- #dedented_body = [' ' * len(bullet) + line[dedent:] for line in description[1:]]
- #result.extend(dedented_body)
- result.extend(description[1:])
- ensure_terminal_blank(result)
-
- return result
-
-
-
-class Returns(Node):
-
- def __init__(self, indent):
- super(Returns, self).__init__(indent=indent)
- self.title = 'Returns'
- self.line = ''
-
-
- def __repr__(self):
- return "Returns(" + str(self.indent) + ", children=" + str(self.children) + ")"
-
-
- def render_rst(self, *args, **kwargs):
- result = []
- indent = ' ' * self.indent
-
- # Render the param description
- description = [self.line] if self.line else []
- for child in self.children:
- child_lines = child.render_rst()
- description.extend(child_lines)
-
- self.render_title(description, indent, result)
-
- result.extend(description[1:])
-
- ensure_terminal_blank(result)
- return result
-
-
- def render_title(self, description, indent, result):
- result.append(
- "{indent}:returns: {first_description}".format(indent=indent,
- first_description=description[0].lstrip()))
-
-
-
-class Warning(Node):
-
- def __init__(self, indent):
- super(Warning, self).__init__(indent=indent)
-
- def __repr__(self):
- return "Warning(" + repr(self.indent) + ", children=" + str(self.children) + ")"
-
- def render_rst(self, *args, **kwargs):
- # TODO: Factor out the commonality between this and Note below
- result = []
- indent = ' ' * self.indent
-
- # Render the param description
- description = [self.line] if self.line else []
- for child in self.children:
- child_lines = child.render_rst()
- description.extend(child_lines)
-
- # Fix the indent on the first line
- if len(description) > 1 and len(description[1].strip()) != 0:
- body_indent = len(description[1]) - len(description[1].strip())
- else:
- body_indent = self.indent + 4
-
- if len(description) > 0:
- description[0] = ' ' * body_indent + description[0]
-
- result.append(indent + ".. warning::")
- result.append(indent + '')
- result.extend(description)
-
- ensure_terminal_blank(result)
- return result
-
-
-class Note(Node):
-
- def __init__(self, indent):
- super(Note, self).__init__(indent=indent)
- self.line = ''
-
-
- def __repr__(self):
- return "Note(" + repr(self.indent) + ", children=" + str(self.children) + ")"
-
-
- def render_rst(self, *args, **kwargs):
- # TODO: Factor out the commonality between this and Warning above
- result = []
- indent = ' ' * self.indent
-
- # Render the param description
- description = [self.line] if self.line else []
- for child in self.children:
- child_lines = child.render_rst()
- description.extend(child_lines)
-
- # Fix the indent on the first line
- if len(description) > 1 and len(description[1].strip()) != 0:
- body_indent = len(description[1]) - len(description[1].strip())
- else:
- body_indent = self.indent + 4
-
- if len(description) > 0:
- description[0] = ' ' * body_indent + description[0]
-
- result.append(indent + ".. note::")
- result.append(indent + '')
- result.extend(description)
-
- ensure_terminal_blank(result)
- return result
-
-
-def ensure_terminal_blank(result):
- '''If the description didn't end with a blank line add one here.'''
- if len(result) > 0:
- if len(result[-1].strip()) != 0:
- result.append('')
+__author__ = 'Robert Smallshire' + +class Node(object): + + def __init__(self, indent=None, lines=None, parent=None): + if indent is not None: + self.indent = indent + else: + self.indent = 0 + + if lines is not None: + self.lines = lines + else: + self.lines = [] + + self._parent = parent + + self.children = [] + + parent = property(lambda self: self._parent) + + def add_child(self, child): + assert(child.parent is self) + self.children.append(child) + + + def __repr__(self): + return "Node(" + repr(self.indent) + ", " + repr(self.lines) + ", children=" + repr(self.children) + ")" + + + def render_rst(self, *args, **kwargs): + result = [] + prefix = ' ' * self.indent + result.extend(prefix + line for line in self.lines) + for child in self.children: + result.extend(child.render_rst()) + return result + + + +class Arg(Node): + + def __init__(self, indent, child_indent, name): + super(Arg, self).__init__(indent) + self.child_indent = child_indent + self.name = name + self.type = None + + + def __repr__(self): + return "Arg(" + repr(self.name) + ", " + repr(self.type) + ", children=" + repr(self.children) + ")" + + + def render_rst(self, *args, **kwargs): + result = [] + indent = ' ' * self.indent + + # Render the param description + description = [] + for child in self.children: + child_lines = child.render_rst() + description.extend(child_lines) + + dedent = self.child_indent - self.indent + + name = self.name.replace('*', r'\*') + + first_description = description[0].lstrip() if len(description) else '' + if not first_description: + # TODO: Emit a warning about a missing argument description + pass + + result.append("{indent}:param {name}: {first_description}".format(indent=indent, name=name, + first_description=first_description)) + + dedented_body = [line[dedent:] for line in description[1:]] + + result.extend(dedented_body) + + # If a type was specified render the type + if self.type is not None: + result.append("{indent}:type {name}: {type}".format(indent=indent, name=self.name, type=self.type)) + result.append('') + + ensure_terminal_blank(result) + + return result + + + +class Raises(Node): + + def __init__(self, indent=None): + super(Raises, self).__init__(indent=indent) + + def __repr__(self): + return "Raises(" + repr(self.indent) + ", children=" + repr(self.children) + ")" + + + def render_rst(self, *args, **kwargs): + result = [] + indent = ' ' * self.indent + result.append(indent + ':raises:') + for child in self.children: + result.extend(child.render_rst(only_child=len(self.children) == 1)) + + ensure_terminal_blank(result) + + return result + + +class Except(Node): + + def __init__(self, indent, type): + super(Except, self).__init__(indent=indent) + #self.child_indent = child_indent + self.type = type + + + def __repr__(self): + return "Except(" + repr(self.type) + ", children=" + repr(self.children) + ")" + + + def render_rst(self, only_child=False, *args, **kwargs): + result = [] + indent = ' ' * self.indent + + # Render the param description + description = [] + for child in self.children: + child_lines = child.render_rst() + description.extend(child_lines) + + #dedent = self.child_indent - self.indent + bullet = '* ' if not only_child else '' + + first_description = description[0].lstrip() if len(description) else '' + result.append("{indent}{bullet}{type} - {first_description}".format(indent=indent, + bullet=bullet, type=self.type, + first_description=first_description)) + + #dedented_body = [' ' * len(bullet) + line[dedent:] for line in description[1:]] + #result.extend(dedented_body) + result.extend(description[1:]) + ensure_terminal_blank(result) + + return result + + + +class Returns(Node): + + def __init__(self, indent): + super(Returns, self).__init__(indent=indent) + self.title = 'Returns' + self.line = '' + + + def __repr__(self): + return "Returns(" + str(self.indent) + ", children=" + str(self.children) + ")" + + + def render_rst(self, *args, **kwargs): + result = [] + indent = ' ' * self.indent + + # Render the param description + description = [self.line] if self.line else [] + for child in self.children: + child_lines = child.render_rst() + description.extend(child_lines) + + self.render_title(description, indent, result) + + result.extend(description[1:]) + + ensure_terminal_blank(result) + return result + + + def render_title(self, description, indent, result): + result.append( + "{indent}:returns: {first_description}".format(indent=indent, + first_description=description[0].lstrip())) + + + +class Warning(Node): + + def __init__(self, indent): + super(Warning, self).__init__(indent=indent) + + def __repr__(self): + return "Warning(" + repr(self.indent) + ", children=" + str(self.children) + ")" + + def render_rst(self, *args, **kwargs): + # TODO: Factor out the commonality between this and Note below + result = [] + indent = ' ' * self.indent + + # Render the param description + description = [self.line] if self.line else [] + for child in self.children: + child_lines = child.render_rst() + description.extend(child_lines) + + # Fix the indent on the first line + if len(description) > 1 and len(description[1].strip()) != 0: + body_indent = len(description[1]) - len(description[1].strip()) + else: + body_indent = self.indent + 4 + + if len(description) > 0: + description[0] = ' ' * body_indent + description[0] + + result.append(indent + ".. warning::") + result.append(indent + '') + result.extend(description) + + ensure_terminal_blank(result) + return result + + +class Note(Node): + + def __init__(self, indent): + super(Note, self).__init__(indent=indent) + self.line = '' + + + def __repr__(self): + return "Note(" + repr(self.indent) + ", children=" + str(self.children) + ")" + + + def render_rst(self, *args, **kwargs): + # TODO: Factor out the commonality between this and Warning above + result = [] + indent = ' ' * self.indent + + # Render the param description + description = [self.line] if self.line else [] + for child in self.children: + child_lines = child.render_rst() + description.extend(child_lines) + + # Fix the indent on the first line + if len(description) > 1 and len(description[1].strip()) != 0: + body_indent = len(description[1]) - len(description[1].strip()) + else: + body_indent = self.indent + 4 + + if len(description) > 0: + description[0] = ' ' * body_indent + description[0] + + result.append(indent + ".. note::") + result.append(indent + '') + result.extend(description) + + ensure_terminal_blank(result) + return result + + +def ensure_terminal_blank(result): + '''If the description didn't end with a blank line add one here.''' + if len(result) > 0: + if len(result[-1].strip()) != 0: + result.append('') diff --git a/docs/sphinx/hieroglyph/test/__init__.py b/docs/sphinx/hieroglyph/test/__init__.py index fd249423f2..c9b674ead2 100644 --- a/docs/sphinx/hieroglyph/test/__init__.py +++ b/docs/sphinx/hieroglyph/test/__init__.py @@ -1,2 +1 @@ __author__ = 'rjs' -
\ No newline at end of file diff --git a/docs/sphinx/hieroglyph/test/test_hierglyph.py b/docs/sphinx/hieroglyph/test/test_hierglyph.py index 42947cb0c7..4f86db5784 100644 --- a/docs/sphinx/hieroglyph/test/test_hierglyph.py +++ b/docs/sphinx/hieroglyph/test/test_hierglyph.py @@ -1,264 +1,264 @@ -import unittest
-from hieroglyph.hieroglyph import first_paragraph_indent, gather_lines, unindent
-
-__author__ = 'Robert Smallshire'
-
-class UnindentTests(unittest.TestCase):
-
- def test_zero_lines(self):
- source = []
- expected = []
- actual = unindent(source)
- self.assertEqual(actual, expected)
-
- def test_one_zero_indent_line(self):
- source = ["First line"]
- expected = [(0, "First line")]
- actual = unindent(source)
- self.assertEqual(actual, expected)
-
- def test_two_zero_indent_lines(self):
- source = ["First line",
- "Second line"]
- expected = [(0, "First line"),
- (0, "Second line")]
- actual = unindent(source)
- self.assertEqual(actual, expected)
-
- def test_two_indented_lines(self):
- source = [" First line",
- " Second line"]
- expected = [(4, "First line"),
- (6, "Second line")]
- actual = unindent(source)
- self.assertEqual(actual, expected)
-
- def test_whitespace_line(self):
- source = [" "]
- expected = [(4, "")]
- actual = unindent(source)
- self.assertEqual(actual, expected)
-
- def test_tab_line(self):
- source = ["\tHello"]
- expected = [(1, "Hello")]
- actual = unindent(source)
- self.assertEqual(actual, expected)
-
-
-class FirstParagraphIndentTests(unittest.TestCase):
-
- def test_zero_lines(self):
- source = []
- expected = []
- actual = first_paragraph_indent(source)
- self.assertEqual(actual, expected)
-
- def test_single_line_non_indented_comment(self):
- source = [(0, "A single line comment")]
- expected = [(0, "A single line comment")]
- actual = first_paragraph_indent(source)
- self.assertEqual(actual, expected)
-
- def test_single_line_indented_comment(self):
- source = [(4, "A single line comment")]
- expected = [(4, "A single line comment")]
- actual = first_paragraph_indent(source)
- self.assertEqual(actual, expected)
-
- def test_double_line_non_indented_comment(self):
- source = [(0, "The first line"),
- (0, "The second line")]
- expected = [(0, "The first line"),
- (0, "The second line")]
- actual = first_paragraph_indent(source)
- self.assertEqual(actual, expected)
-
- def test_double_line_indented_comment(self):
- source = [(4, "The first line"),
- (4, "The second line")]
- expected = [(4, "The first line"),
- (4, "The second line")]
- actual = first_paragraph_indent(source)
- self.assertEqual(actual, expected)
-
- def test_first_line_indent(self):
- source = [(4, "The first line"),
- (0, "The second line")]
- expected = [(4, "The first line"),
- (0, "The second line")]
- actual = first_paragraph_indent(source)
- self.assertEqual(actual, expected)
-
- def test_first_line_non_indent(self):
- source = [(0, "The first line"),
- (4, "The second line")]
- expected = [(4, "The first line"),
- (4, "The second line")]
- actual = first_paragraph_indent(source)
- self.assertEqual(actual, expected)
-
- def test_increasing_indent(self):
- source = [(0, "The first line"),
- (4, "The second line"),
- (8, "The third line")]
- expected = [(4, "The first line"),
- (4, "The second line"),
- (8, "The third line")]
- actual = first_paragraph_indent(source)
- self.assertEqual(actual, expected)
-
- def test_separate_paragraphs(self):
- source = [(0, "This is the first paragraph"),
- (0, ""),
- (4, "This is the second paragraph")]
- expected = [(0, "This is the first paragraph"),
- (0, ""),
- (4, "This is the second paragraph")]
- actual = first_paragraph_indent(source)
- self.assertEqual(actual, expected)
-
- def test_separate_paragraphs_indented(self):
- source = [(4, "This is the first paragraph"),
- (4, ""),
- (8, "This is the second paragraph")]
- expected = [(4, "This is the first paragraph"),
- (4, ""),
- (8, "This is the second paragraph")]
- actual = first_paragraph_indent(source)
- self.assertEqual(actual, expected)
-
- def test_separated_lines_first_line_non_indented(self):
- source = [(0, "The first line"),
- (0, ""),
- (4, "The third line")]
- expected = [(0, "The first line"),
- (0, ""),
- (4, "The third line")]
- actual = first_paragraph_indent(source)
- self.assertEqual(actual, expected)
-
- def test_separated_lines_first_line_indented(self):
- source = [(4, "The first line"),
- (4, ""),
- (4, "The third line")]
- expected = [(4, "The first line"),
- (4, ""),
- (4, "The third line")]
- actual = first_paragraph_indent(source)
- self.assertEqual(actual, expected)
-
-class GatherLinesTests(unittest.TestCase):
-
- def test_empty(self):
- source = []
- expected = []
- actual = gather_lines(source)
- self.assertEqual(actual, expected)
-
- def test_one_liner(self):
- source = [(0, 'One liner')]
- expected = [(0, ['One liner'])]
- actual = gather_lines(source)
- self.assertEqual(actual, expected)
-
- def test_two_liner(self):
- source = [(0, 'First line'),
- (0, 'Second line')]
- expected = [(0, ['First line',
- 'Second line'])]
- actual = gather_lines(source)
- self.assertEqual(actual, expected)
-
- def test_separated_lines(self):
- source = [(0, 'First line'),
- (0, ''),
- (0, 'Third line')]
- expected = [(0, ['First line',
- '']),
- (0, ['Third line'])]
- actual = gather_lines(source)
- self.assertEqual(actual, expected)
-
- def test_separated_multi_lines(self):
- source = [(0, 'First line'),
- (0, 'Second line'),
- (0, ''),
- (0, 'Fourth line'),
- (0, 'Fifth line')]
- expected = [(0, ['First line',
- 'Second line',
- '']),
- (0, ['Fourth line',
- 'Fifth line'])]
- actual = gather_lines(source)
- self.assertEqual(actual, expected)
-
-
- def test_indented_lines(self):
- source = [(0, 'First line'),
- (4, 'Second line')]
- expected = [(0, ['First line']),
- (4, ['Second line'])]
- actual = gather_lines(source)
- self.assertEqual(actual, expected)
-
- def test_dedented_lines(self):
- source = [(4, 'First line'),
- (0, 'Second line')]
- expected = [(4, ['First line']),
- (0, ['Second line'])]
- actual = gather_lines(source)
- self.assertEqual(actual, expected)
-
- def test_indented_multi_lines(self):
- source = [(0, 'First line'),
- (0, 'Second line'),
- (4, 'Third line'),
- (4, 'Fourth line')]
- expected = [(0, ['First line',
- 'Second line']),
- (4, ['Third line',
- 'Fourth line'])]
- actual = gather_lines(source)
- self.assertEqual(actual, expected)
-
- def test_dedented_multi_lines(self):
- source = [(4, 'First line'),
- (4, 'Second line'),
- (0, 'Third line'),
- (0, 'Fourth line')]
- expected = [(4, ['First line',
- 'Second line']),
- (0, ['Third line',
- 'Fourth line'])]
- actual = gather_lines(source)
- self.assertEqual(actual, expected)
-
- def test_indented_separated_multi_lines(self):
- source = [(0, 'First line'),
- (0, 'Second line'),
- (0, ''),
- (4, 'Fourth line'),
- (4, 'Fifth line')]
- expected = [(0, ['First line',
- 'Second line',
- '']),
- (4, ['Fourth line',
- 'Fifth line'])]
- actual = gather_lines(source)
- self.assertEqual(actual, expected)
-
- def test_dedented_separated_multi_lines(self):
- source = [(4, 'First line'),
- (4, 'Second line'),
- (4, ''),
- (0, 'Fourth line'),
- (0, 'Fifth line')]
- expected = [(4, ['First line',
- 'Second line',
- '']),
- (0, ['Fourth line',
- 'Fifth line'])]
- actual = gather_lines(source)
- self.assertEqual(actual, expected)
+import unittest +from hieroglyph.hieroglyph import first_paragraph_indent, gather_lines, unindent + +__author__ = 'Robert Smallshire' + +class UnindentTests(unittest.TestCase): + + def test_zero_lines(self): + source = [] + expected = [] + actual = unindent(source) + self.assertEqual(actual, expected) + + def test_one_zero_indent_line(self): + source = ["First line"] + expected = [(0, "First line")] + actual = unindent(source) + self.assertEqual(actual, expected) + + def test_two_zero_indent_lines(self): + source = ["First line", + "Second line"] + expected = [(0, "First line"), + (0, "Second line")] + actual = unindent(source) + self.assertEqual(actual, expected) + + def test_two_indented_lines(self): + source = [" First line", + " Second line"] + expected = [(4, "First line"), + (6, "Second line")] + actual = unindent(source) + self.assertEqual(actual, expected) + + def test_whitespace_line(self): + source = [" "] + expected = [(4, "")] + actual = unindent(source) + self.assertEqual(actual, expected) + + def test_tab_line(self): + source = ["\tHello"] + expected = [(1, "Hello")] + actual = unindent(source) + self.assertEqual(actual, expected) + + +class FirstParagraphIndentTests(unittest.TestCase): + + def test_zero_lines(self): + source = [] + expected = [] + actual = first_paragraph_indent(source) + self.assertEqual(actual, expected) + + def test_single_line_non_indented_comment(self): + source = [(0, "A single line comment")] + expected = [(0, "A single line comment")] + actual = first_paragraph_indent(source) + self.assertEqual(actual, expected) + + def test_single_line_indented_comment(self): + source = [(4, "A single line comment")] + expected = [(4, "A single line comment")] + actual = first_paragraph_indent(source) + self.assertEqual(actual, expected) + + def test_double_line_non_indented_comment(self): + source = [(0, "The first line"), + (0, "The second line")] + expected = [(0, "The first line"), + (0, "The second line")] + actual = first_paragraph_indent(source) + self.assertEqual(actual, expected) + + def test_double_line_indented_comment(self): + source = [(4, "The first line"), + (4, "The second line")] + expected = [(4, "The first line"), + (4, "The second line")] + actual = first_paragraph_indent(source) + self.assertEqual(actual, expected) + + def test_first_line_indent(self): + source = [(4, "The first line"), + (0, "The second line")] + expected = [(4, "The first line"), + (0, "The second line")] + actual = first_paragraph_indent(source) + self.assertEqual(actual, expected) + + def test_first_line_non_indent(self): + source = [(0, "The first line"), + (4, "The second line")] + expected = [(4, "The first line"), + (4, "The second line")] + actual = first_paragraph_indent(source) + self.assertEqual(actual, expected) + + def test_increasing_indent(self): + source = [(0, "The first line"), + (4, "The second line"), + (8, "The third line")] + expected = [(4, "The first line"), + (4, "The second line"), + (8, "The third line")] + actual = first_paragraph_indent(source) + self.assertEqual(actual, expected) + + def test_separate_paragraphs(self): + source = [(0, "This is the first paragraph"), + (0, ""), + (4, "This is the second paragraph")] + expected = [(0, "This is the first paragraph"), + (0, ""), + (4, "This is the second paragraph")] + actual = first_paragraph_indent(source) + self.assertEqual(actual, expected) + + def test_separate_paragraphs_indented(self): + source = [(4, "This is the first paragraph"), + (4, ""), + (8, "This is the second paragraph")] + expected = [(4, "This is the first paragraph"), + (4, ""), + (8, "This is the second paragraph")] + actual = first_paragraph_indent(source) + self.assertEqual(actual, expected) + + def test_separated_lines_first_line_non_indented(self): + source = [(0, "The first line"), + (0, ""), + (4, "The third line")] + expected = [(0, "The first line"), + (0, ""), + (4, "The third line")] + actual = first_paragraph_indent(source) + self.assertEqual(actual, expected) + + def test_separated_lines_first_line_indented(self): + source = [(4, "The first line"), + (4, ""), + (4, "The third line")] + expected = [(4, "The first line"), + (4, ""), + (4, "The third line")] + actual = first_paragraph_indent(source) + self.assertEqual(actual, expected) + +class GatherLinesTests(unittest.TestCase): + + def test_empty(self): + source = [] + expected = [] + actual = gather_lines(source) + self.assertEqual(actual, expected) + + def test_one_liner(self): + source = [(0, 'One liner')] + expected = [(0, ['One liner'])] + actual = gather_lines(source) + self.assertEqual(actual, expected) + + def test_two_liner(self): + source = [(0, 'First line'), + (0, 'Second line')] + expected = [(0, ['First line', + 'Second line'])] + actual = gather_lines(source) + self.assertEqual(actual, expected) + + def test_separated_lines(self): + source = [(0, 'First line'), + (0, ''), + (0, 'Third line')] + expected = [(0, ['First line', + '']), + (0, ['Third line'])] + actual = gather_lines(source) + self.assertEqual(actual, expected) + + def test_separated_multi_lines(self): + source = [(0, 'First line'), + (0, 'Second line'), + (0, ''), + (0, 'Fourth line'), + (0, 'Fifth line')] + expected = [(0, ['First line', + 'Second line', + '']), + (0, ['Fourth line', + 'Fifth line'])] + actual = gather_lines(source) + self.assertEqual(actual, expected) + + + def test_indented_lines(self): + source = [(0, 'First line'), + (4, 'Second line')] + expected = [(0, ['First line']), + (4, ['Second line'])] + actual = gather_lines(source) + self.assertEqual(actual, expected) + + def test_dedented_lines(self): + source = [(4, 'First line'), + (0, 'Second line')] + expected = [(4, ['First line']), + (0, ['Second line'])] + actual = gather_lines(source) + self.assertEqual(actual, expected) + + def test_indented_multi_lines(self): + source = [(0, 'First line'), + (0, 'Second line'), + (4, 'Third line'), + (4, 'Fourth line')] + expected = [(0, ['First line', + 'Second line']), + (4, ['Third line', + 'Fourth line'])] + actual = gather_lines(source) + self.assertEqual(actual, expected) + + def test_dedented_multi_lines(self): + source = [(4, 'First line'), + (4, 'Second line'), + (0, 'Third line'), + (0, 'Fourth line')] + expected = [(4, ['First line', + 'Second line']), + (0, ['Third line', + 'Fourth line'])] + actual = gather_lines(source) + self.assertEqual(actual, expected) + + def test_indented_separated_multi_lines(self): + source = [(0, 'First line'), + (0, 'Second line'), + (0, ''), + (4, 'Fourth line'), + (4, 'Fifth line')] + expected = [(0, ['First line', + 'Second line', + '']), + (4, ['Fourth line', + 'Fifth line'])] + actual = gather_lines(source) + self.assertEqual(actual, expected) + + def test_dedented_separated_multi_lines(self): + source = [(4, 'First line'), + (4, 'Second line'), + (4, ''), + (0, 'Fourth line'), + (0, 'Fifth line')] + expected = [(4, ['First line', + 'Second line', + '']), + (0, ['Fourth line', + 'Fifth line'])] + actual = gather_lines(source) + self.assertEqual(actual, expected) diff --git a/docs/sphinx/hieroglyph/test/test_nodes.py b/docs/sphinx/hieroglyph/test/test_nodes.py index 4cc17b4771..12cd25a03e 100644 --- a/docs/sphinx/hieroglyph/test/test_nodes.py +++ b/docs/sphinx/hieroglyph/test/test_nodes.py @@ -1,386 +1,386 @@ -import unittest
-from hieroglyph.nodes import Node, Arg, Raises, Except, Returns, Warning, Note
-
-__author__ = 'Robert Smallshire'
-
-class NodeTests(unittest.TestCase):
-
- def test_create_default_node(self):
- node = Node()
- self.assertEqual(node.indent, 0)
- self.assertEqual(node.lines, [])
- self.assertIsNone(node.parent)
-
- def test_create_with_indent(self):
- node = Node(indent=4)
- self.assertEqual(node.indent, 4)
- self.assertEqual(node.lines, [])
- self.assertIsNone(node.parent)
-
- def test_create_with_lines(self):
- node = Node(lines= ['First', 'Second', 'Third'])
- self.assertEqual(node.indent, 0)
- self.assertEqual(node.lines, ['First', 'Second', 'Third'])
- self.assertIsNone(node.parent)
-
- def test_repr(self):
- node = Node(5, ['One', 'Two', 'Three'])
- actual = repr(node)
- expected = "Node(5, ['One', 'Two', 'Three'], children=[])"
- self.assertEqual(expected, actual)
-
- def test_add_one_child(self):
- node = Node()
- child = Node(parent=node)
- node.add_child(child)
- self.assertIs(node.children[0], child)
-
- def test_add_two_children(self):
- node = Node()
- child0 = Node(parent=node)
- child1 = Node(parent=node)
- node.add_child(child0)
- node.add_child(child1)
- self.assertIs(node.children[0], child0)
- self.assertIs(node.children[1], child1)
-
- def test_render_rst_empty(self):
- node = Node()
- rst = node.render_rst()
- self.assertEqual(len(rst), 0)
-
- def test_render_rst_indent(self):
- node = Node(indent=4)
- rst = node.render_rst()
- self.assertEqual(len(rst), 0)
-
- def test_render_rst_lines(self):
- node = Node(lines= ['First',
- 'Second',
- 'Third'])
- rst = node.render_rst()
- self.assertEqual(rst, ['First',
- 'Second',
- 'Third'])
-
- def test_render_rst_indented_lines(self):
- node = Node(indent=3, lines= ['First',
- 'Second',
- 'Third'])
- rst = node.render_rst()
- self.assertEqual(rst, [' First',
- ' Second',
- ' Third'])
-
- def test_render_rst_with_child(self):
- node = Node(indent=4, lines=["Parent"])
- child = Node(indent=8, lines=["Child"], parent=node)
- node.add_child(child)
- rst = node.render_rst()
- self.assertEqual(rst, [' Parent',
- ' Child'])
-
- def test_render_rst_with_children(self):
- node = Node(indent=4, lines=["Parent"])
- child_a = Node(indent=8, lines=["ChildA"], parent=node)
- node.add_child(child_a)
- child_b = Node(indent=6, lines=["ChildB"], parent=node)
- node.add_child(child_b)
- rst = node.render_rst()
- self.assertEqual(rst, [' Parent',
- ' ChildA',
- ' ChildB'])
-
-
-class ArgTests(unittest.TestCase):
-
- def test_create(self):
- node = Arg(5, 10, 'foo')
- self.assertEqual(node.indent, 5)
- self.assertEqual(node.child_indent, 10)
- self.assertEqual(node.name, 'foo')
- self.assertEqual(node.lines, [])
- self.assertIsNone(node.parent)
-
- def test_set_type(self):
- node = Arg(5, 10, 'foo')
- node.type = 'str'
- self.assertEqual(node.type, 'str')
-
- def test_add_one_child(self):
- node = Arg(5, 10, 'foo')
- child = Node(parent=node)
- node.add_child(child)
- self.assertIs(node.children[0], child)
-
- def test_add_two_children(self):
- node = Arg(5, 10, 'foo')
- child0 = Node(parent=node)
- child1 = Node(parent=node)
- node.add_child(child0)
- node.add_child(child1)
- self.assertIs(node.children[0], child0)
- self.assertIs(node.children[1], child1)
-
- def test_repr(self):
- node = Arg(5, 10, 'foo')
- actual = repr(node)
- expected = "Arg('foo', None, children=[])"
- self.assertEqual(expected, actual)
-
- def test_render_rst_empty(self):
- node = Arg(5, 10, 'bar')
- rst = node.render_rst()
- self.assertEqual(rst, [' :param bar: ',
- ''])
-
- def test_render_rst_with_child(self):
- node = Arg(5, 10, 'bar')
- child = Node(indent=10, lines=["Description"], parent=node)
- node.add_child(child)
- rst = node.render_rst()
- self.assertEqual(rst, [' :param bar: Description',
- ''])
-
- def test_render_rst_with_children(self):
- node = Arg(5, 10, 'bar')
- child_a = Node(indent=10, lines=["ChildA"], parent=node)
- node.add_child(child_a)
- child_b = Node(indent=10, lines=["ChildB"], parent=node)
- node.add_child(child_b)
- rst = node.render_rst()
- self.assertEqual(rst, [' :param bar: ChildA',
- ' ChildB',
- ''])
-
- def test_render_rst_with_type(self):
- node = Arg(5, 10, 'bar')
- node.type = 'str'
- rst = node.render_rst()
- self.assertEqual(rst, [' :param bar: ',
- ' :type bar: str',
- ''])
-
-
-class RaisesTests(unittest.TestCase):
-
- def test_create_default_node(self):
- node = Raises()
- self.assertEqual(node.indent, 0)
- self.assertEqual(node.lines, [])
- self.assertIsNone(node.parent)
-
- def test_create_with_indent(self):
- node = Raises(indent=4)
- self.assertEqual(node.indent, 4)
- self.assertEqual(node.lines, [])
- self.assertIsNone(node.parent)
-
- def test_repr(self):
- node = Raises(5)
- actual = repr(node)
- expected = "Raises(5, children=[])"
- self.assertEqual(expected, actual)
-
- def test_add_one_child(self):
- node = Raises()
- child = Node(parent=node)
- node.add_child(child)
- self.assertIs(node.children[0], child)
-
- def test_add_two_children(self):
- node = Raises()
- child0 = Node(parent=node)
- child1 = Node(parent=node)
- node.add_child(child0)
- node.add_child(child1)
- self.assertIs(node.children[0], child0)
- self.assertIs(node.children[1], child1)
-
- def test_render_rst_empty(self):
- node = Raises()
- rst = node.render_rst()
- self.assertEqual(rst, [':raises:',
- ''])
-
- def test_render_rst_indent(self):
- node = Raises(indent=5)
- rst = node.render_rst()
- self.assertEqual(rst, [' :raises:',
- ''])
-
- def test_render_rst_with_child(self):
- node = Raises(5)
- child = Node(indent=10, lines=["Description"], parent=node)
- node.add_child(child)
- rst = node.render_rst()
- self.assertEqual(rst, [' :raises:',
- ' Description',
- ''])
-
- def test_render_rst_with_children(self):
- node = Raises(5)
- child_a = Node(indent=10, lines=["ChildA"], parent=node)
- node.add_child(child_a)
- child_b = Node(indent=10, lines=["ChildB"], parent=node)
- node.add_child(child_b)
- rst = node.render_rst()
- self.assertEqual(rst, [' :raises:',
- ' ChildA',
- ' ChildB',
- ''])
-
-
-class ExceptTests(unittest.TestCase):
-
- def test_create(self):
- node = Except(5, 'FooError')
- self.assertEqual(node.indent, 5)
- self.assertEqual(node.type, 'FooError')
- self.assertEqual(node.lines, [])
- self.assertIsNone(node.parent)
-
- def test_add_one_child(self):
- node = Except(5, 'FooError')
- child = Node(parent=node)
- node.add_child(child)
- self.assertIs(node.children[0], child)
-
- def test_add_two_children(self):
- node = Except(5, 'FooError')
- child0 = Node(parent=node)
- child1 = Node(parent=node)
- node.add_child(child0)
- node.add_child(child1)
- self.assertIs(node.children[0], child0)
- self.assertIs(node.children[1], child1)
-
- def test_repr(self):
- node = Except(5,'FooError')
- actual = repr(node)
- expected = "Except('FooError', children=[])"
- self.assertEqual(expected, actual)
-
- def test_render_rst_empty(self):
- node = Except(5, 'FooError')
- rst = node.render_rst()
- self.assertEqual(rst, [' * FooError - ',
- ''])
-
- def test_render_rst_indent(self):
- node = Except(5, 'FooError')
- rst = node.render_rst()
- self.assertEqual(rst, [' * FooError - ',
- ''])
-
- def test_render_rst_with_child(self):
- node = Except(5, 'FooError')
- child = Node(indent=10, lines=["Description"], parent=node)
- node.add_child(child)
- rst = node.render_rst()
- self.assertEqual(rst, [' * FooError - Description',
- ''])
-
- def test_render_rst_with_children(self):
- node = Except(5, 'FooError')
- child_a = Node(indent=10, lines=["ChildA"], parent=node)
- node.add_child(child_a)
- child_b = Node(indent=10, lines=["ChildB"], parent=node)
- node.add_child(child_b)
- rst = node.render_rst()
- self.assertEqual(rst, [' * FooError - ChildA',
- ' ChildB',
- ''])
-
-class ReturnsTests(unittest.TestCase):
-
- def test_create(self):
- node = Returns(5)
- self.assertEqual(node.indent, 5)
- self.assertEqual(node.lines, [])
- self.assertIsNone(node.parent)
-
- def test_add_one_child(self):
- node = Returns(5)
- child = Node(parent=node)
- node.add_child(child)
- self.assertIs(node.children[0], child)
-
- def test_add_two_children(self):
- node = Returns(5)
- child0 = Node(parent=node)
- child1 = Node(parent=node)
- node.add_child(child0)
- node.add_child(child1)
- self.assertIs(node.children[0], child0)
- self.assertIs(node.children[1], child1)
-
- def test_repr(self):
- node = Returns(5)
- actual = repr(node)
- expected = "Returns(5, children=[])"
- self.assertEqual(expected, actual)
-
- # TODO test_render_rst
-
-class WarningTests(unittest.TestCase):
-
- def test_create(self):
- node = Warning(5)
- self.assertEqual(node.indent, 5)
- self.assertEqual(node.lines, [])
- self.assertIsNone(node.parent)
-
- def test_add_one_child(self):
- node = Warning(5)
- child = Node(parent=node)
- node.add_child(child)
- self.assertIs(node.children[0], child)
-
- def test_add_two_children(self):
- node = Warning(5)
- child0 = Node(parent=node)
- child1 = Node(parent=node)
- node.add_child(child0)
- node.add_child(child1)
- self.assertIs(node.children[0], child0)
- self.assertIs(node.children[1], child1)
-
- def test_repr(self):
- node = Warning(5)
- actual = repr(node)
- expected = "Warning(5, children=[])"
- self.assertEqual(expected, actual)
-
- # TODO test_render_rst
-
-class NoteTests(unittest.TestCase):
-
- def test_create(self):
- node = Note(5)
- self.assertEqual(node.indent, 5)
- self.assertEqual(node.lines, [])
- self.assertIsNone(node.parent)
-
- def test_add_one_child(self):
- node = Note(5)
- child = Node(parent=node)
- node.add_child(child)
- self.assertIs(node.children[0], child)
-
- def test_add_two_children(self):
- node = Note(5)
- child0 = Node(parent=node)
- child1 = Node(parent=node)
- node.add_child(child0)
- node.add_child(child1)
- self.assertIs(node.children[0], child0)
- self.assertIs(node.children[1], child1)
-
- def test_repr(self):
- node = Note(5)
- actual = repr(node)
- expected = "Note(5, children=[])"
- self.assertEqual(expected, actual)
-
- # TODO test_render_rst
+import unittest +from hieroglyph.nodes import Node, Arg, Raises, Except, Returns, Warning, Note + +__author__ = 'Robert Smallshire' + +class NodeTests(unittest.TestCase): + + def test_create_default_node(self): + node = Node() + self.assertEqual(node.indent, 0) + self.assertEqual(node.lines, []) + self.assertIsNone(node.parent) + + def test_create_with_indent(self): + node = Node(indent=4) + self.assertEqual(node.indent, 4) + self.assertEqual(node.lines, []) + self.assertIsNone(node.parent) + + def test_create_with_lines(self): + node = Node(lines= ['First', 'Second', 'Third']) + self.assertEqual(node.indent, 0) + self.assertEqual(node.lines, ['First', 'Second', 'Third']) + self.assertIsNone(node.parent) + + def test_repr(self): + node = Node(5, ['One', 'Two', 'Three']) + actual = repr(node) + expected = "Node(5, ['One', 'Two', 'Three'], children=[])" + self.assertEqual(expected, actual) + + def test_add_one_child(self): + node = Node() + child = Node(parent=node) + node.add_child(child) + self.assertIs(node.children[0], child) + + def test_add_two_children(self): + node = Node() + child0 = Node(parent=node) + child1 = Node(parent=node) + node.add_child(child0) + node.add_child(child1) + self.assertIs(node.children[0], child0) + self.assertIs(node.children[1], child1) + + def test_render_rst_empty(self): + node = Node() + rst = node.render_rst() + self.assertEqual(len(rst), 0) + + def test_render_rst_indent(self): + node = Node(indent=4) + rst = node.render_rst() + self.assertEqual(len(rst), 0) + + def test_render_rst_lines(self): + node = Node(lines= ['First', + 'Second', + 'Third']) + rst = node.render_rst() + self.assertEqual(rst, ['First', + 'Second', + 'Third']) + + def test_render_rst_indented_lines(self): + node = Node(indent=3, lines= ['First', + 'Second', + 'Third']) + rst = node.render_rst() + self.assertEqual(rst, [' First', + ' Second', + ' Third']) + + def test_render_rst_with_child(self): + node = Node(indent=4, lines=["Parent"]) + child = Node(indent=8, lines=["Child"], parent=node) + node.add_child(child) + rst = node.render_rst() + self.assertEqual(rst, [' Parent', + ' Child']) + + def test_render_rst_with_children(self): + node = Node(indent=4, lines=["Parent"]) + child_a = Node(indent=8, lines=["ChildA"], parent=node) + node.add_child(child_a) + child_b = Node(indent=6, lines=["ChildB"], parent=node) + node.add_child(child_b) + rst = node.render_rst() + self.assertEqual(rst, [' Parent', + ' ChildA', + ' ChildB']) + + +class ArgTests(unittest.TestCase): + + def test_create(self): + node = Arg(5, 10, 'foo') + self.assertEqual(node.indent, 5) + self.assertEqual(node.child_indent, 10) + self.assertEqual(node.name, 'foo') + self.assertEqual(node.lines, []) + self.assertIsNone(node.parent) + + def test_set_type(self): + node = Arg(5, 10, 'foo') + node.type = 'str' + self.assertEqual(node.type, 'str') + + def test_add_one_child(self): + node = Arg(5, 10, 'foo') + child = Node(parent=node) + node.add_child(child) + self.assertIs(node.children[0], child) + + def test_add_two_children(self): + node = Arg(5, 10, 'foo') + child0 = Node(parent=node) + child1 = Node(parent=node) + node.add_child(child0) + node.add_child(child1) + self.assertIs(node.children[0], child0) + self.assertIs(node.children[1], child1) + + def test_repr(self): + node = Arg(5, 10, 'foo') + actual = repr(node) + expected = "Arg('foo', None, children=[])" + self.assertEqual(expected, actual) + + def test_render_rst_empty(self): + node = Arg(5, 10, 'bar') + rst = node.render_rst() + self.assertEqual(rst, [' :param bar: ', + '']) + + def test_render_rst_with_child(self): + node = Arg(5, 10, 'bar') + child = Node(indent=10, lines=["Description"], parent=node) + node.add_child(child) + rst = node.render_rst() + self.assertEqual(rst, [' :param bar: Description', + '']) + + def test_render_rst_with_children(self): + node = Arg(5, 10, 'bar') + child_a = Node(indent=10, lines=["ChildA"], parent=node) + node.add_child(child_a) + child_b = Node(indent=10, lines=["ChildB"], parent=node) + node.add_child(child_b) + rst = node.render_rst() + self.assertEqual(rst, [' :param bar: ChildA', + ' ChildB', + '']) + + def test_render_rst_with_type(self): + node = Arg(5, 10, 'bar') + node.type = 'str' + rst = node.render_rst() + self.assertEqual(rst, [' :param bar: ', + ' :type bar: str', + '']) + + +class RaisesTests(unittest.TestCase): + + def test_create_default_node(self): + node = Raises() + self.assertEqual(node.indent, 0) + self.assertEqual(node.lines, []) + self.assertIsNone(node.parent) + + def test_create_with_indent(self): + node = Raises(indent=4) + self.assertEqual(node.indent, 4) + self.assertEqual(node.lines, []) + self.assertIsNone(node.parent) + + def test_repr(self): + node = Raises(5) + actual = repr(node) + expected = "Raises(5, children=[])" + self.assertEqual(expected, actual) + + def test_add_one_child(self): + node = Raises() + child = Node(parent=node) + node.add_child(child) + self.assertIs(node.children[0], child) + + def test_add_two_children(self): + node = Raises() + child0 = Node(parent=node) + child1 = Node(parent=node) + node.add_child(child0) + node.add_child(child1) + self.assertIs(node.children[0], child0) + self.assertIs(node.children[1], child1) + + def test_render_rst_empty(self): + node = Raises() + rst = node.render_rst() + self.assertEqual(rst, [':raises:', + '']) + + def test_render_rst_indent(self): + node = Raises(indent=5) + rst = node.render_rst() + self.assertEqual(rst, [' :raises:', + '']) + + def test_render_rst_with_child(self): + node = Raises(5) + child = Node(indent=10, lines=["Description"], parent=node) + node.add_child(child) + rst = node.render_rst() + self.assertEqual(rst, [' :raises:', + ' Description', + '']) + + def test_render_rst_with_children(self): + node = Raises(5) + child_a = Node(indent=10, lines=["ChildA"], parent=node) + node.add_child(child_a) + child_b = Node(indent=10, lines=["ChildB"], parent=node) + node.add_child(child_b) + rst = node.render_rst() + self.assertEqual(rst, [' :raises:', + ' ChildA', + ' ChildB', + '']) + + +class ExceptTests(unittest.TestCase): + + def test_create(self): + node = Except(5, 'FooError') + self.assertEqual(node.indent, 5) + self.assertEqual(node.type, 'FooError') + self.assertEqual(node.lines, []) + self.assertIsNone(node.parent) + + def test_add_one_child(self): + node = Except(5, 'FooError') + child = Node(parent=node) + node.add_child(child) + self.assertIs(node.children[0], child) + + def test_add_two_children(self): + node = Except(5, 'FooError') + child0 = Node(parent=node) + child1 = Node(parent=node) + node.add_child(child0) + node.add_child(child1) + self.assertIs(node.children[0], child0) + self.assertIs(node.children[1], child1) + + def test_repr(self): + node = Except(5,'FooError') + actual = repr(node) + expected = "Except('FooError', children=[])" + self.assertEqual(expected, actual) + + def test_render_rst_empty(self): + node = Except(5, 'FooError') + rst = node.render_rst() + self.assertEqual(rst, [' * FooError - ', + '']) + + def test_render_rst_indent(self): + node = Except(5, 'FooError') + rst = node.render_rst() + self.assertEqual(rst, [' * FooError - ', + '']) + + def test_render_rst_with_child(self): + node = Except(5, 'FooError') + child = Node(indent=10, lines=["Description"], parent=node) + node.add_child(child) + rst = node.render_rst() + self.assertEqual(rst, [' * FooError - Description', + '']) + + def test_render_rst_with_children(self): + node = Except(5, 'FooError') + child_a = Node(indent=10, lines=["ChildA"], parent=node) + node.add_child(child_a) + child_b = Node(indent=10, lines=["ChildB"], parent=node) + node.add_child(child_b) + rst = node.render_rst() + self.assertEqual(rst, [' * FooError - ChildA', + ' ChildB', + '']) + +class ReturnsTests(unittest.TestCase): + + def test_create(self): + node = Returns(5) + self.assertEqual(node.indent, 5) + self.assertEqual(node.lines, []) + self.assertIsNone(node.parent) + + def test_add_one_child(self): + node = Returns(5) + child = Node(parent=node) + node.add_child(child) + self.assertIs(node.children[0], child) + + def test_add_two_children(self): + node = Returns(5) + child0 = Node(parent=node) + child1 = Node(parent=node) + node.add_child(child0) + node.add_child(child1) + self.assertIs(node.children[0], child0) + self.assertIs(node.children[1], child1) + + def test_repr(self): + node = Returns(5) + actual = repr(node) + expected = "Returns(5, children=[])" + self.assertEqual(expected, actual) + + # TODO test_render_rst + +class WarningTests(unittest.TestCase): + + def test_create(self): + node = Warning(5) + self.assertEqual(node.indent, 5) + self.assertEqual(node.lines, []) + self.assertIsNone(node.parent) + + def test_add_one_child(self): + node = Warning(5) + child = Node(parent=node) + node.add_child(child) + self.assertIs(node.children[0], child) + + def test_add_two_children(self): + node = Warning(5) + child0 = Node(parent=node) + child1 = Node(parent=node) + node.add_child(child0) + node.add_child(child1) + self.assertIs(node.children[0], child0) + self.assertIs(node.children[1], child1) + + def test_repr(self): + node = Warning(5) + actual = repr(node) + expected = "Warning(5, children=[])" + self.assertEqual(expected, actual) + + # TODO test_render_rst + +class NoteTests(unittest.TestCase): + + def test_create(self): + node = Note(5) + self.assertEqual(node.indent, 5) + self.assertEqual(node.lines, []) + self.assertIsNone(node.parent) + + def test_add_one_child(self): + node = Note(5) + child = Node(parent=node) + node.add_child(child) + self.assertIs(node.children[0], child) + + def test_add_two_children(self): + node = Note(5) + child0 = Node(parent=node) + child1 = Node(parent=node) + node.add_child(child0) + node.add_child(child1) + self.assertIs(node.children[0], child0) + self.assertIs(node.children[1], child1) + + def test_repr(self): + node = Note(5) + actual = repr(node) + expected = "Note(5, children=[])" + self.assertEqual(expected, actual) + + # TODO test_render_rst diff --git a/docs/sphinx/hieroglyph/version.py b/docs/sphinx/hieroglyph/version.py index d060125c0f..b35385b6b8 100644 --- a/docs/sphinx/hieroglyph/version.py +++ b/docs/sphinx/hieroglyph/version.py @@ -1,3 +1,3 @@ -'''Specification of the hieroglyph version'''
-
-__version__ = '0.6'
+'''Specification of the hieroglyph version''' + +__version__ = '0.6' diff --git a/docs/sphinx/source/analog/get_blocks.py b/docs/sphinx/source/analog/get_blocks.py index a288393132..f5fc902a8a 100644 --- a/docs/sphinx/source/analog/get_blocks.py +++ b/docs/sphinx/source/analog/get_blocks.py @@ -18,7 +18,7 @@ class Block(object): Checks if doxyxml produced objects correspond to a new style gnuradio block. """ - + @classmethod def includes(cls, item): if not isinstance(item, DoxyClass): @@ -33,7 +33,7 @@ class Group(object): """ Checks if doxyxml produced objects correspond to a group. """ - + @classmethod def includes(cls, item): if not isinstance(item, DoxyGroup): diff --git a/docs/sphinx/source/atsc/index.rst b/docs/sphinx/source/atsc/index.rst index 2371f24569..a8a54ad337 100644 --- a/docs/sphinx/source/atsc/index.rst +++ b/docs/sphinx/source/atsc/index.rst @@ -8,7 +8,7 @@ Signal Processing Blocks .. autosummary:: :nosignatures: - + gnuradio.atsc.bit_timing_loop gnuradio.atsc.deinterleaver gnuradio.atsc.depad @@ -32,7 +32,7 @@ Constants .. autosummary:: :nosignatures: - + gnuradio.atsc.ATSC_DATA_SEGMENT_LENGTH gnuradio.atsc.ATSC_DATA_SEGMENT_RATE gnuradio.atsc.ATSC_DSEGS_PER_FIELD @@ -58,5 +58,5 @@ Sizes gnuradio.atsc.sizeof_atsc_mpeg_packet_rs_encoded gnuradio.atsc.sizeof_atsc_mpeg_packet_rs_encoded_pad gnuradio.atsc.sizeof_atsc_soft_data_segment - gnuradio.atsc.sizeof_atsc_soft_data_segment_pad - + gnuradio.atsc.sizeof_atsc_soft_data_segment_pad + diff --git a/docs/sphinx/source/blocks/get_blocks.py b/docs/sphinx/source/blocks/get_blocks.py index 4ff9b1d10b..18c334c8c6 100644 --- a/docs/sphinx/source/blocks/get_blocks.py +++ b/docs/sphinx/source/blocks/get_blocks.py @@ -18,7 +18,7 @@ class Block(object): Checks if doxyxml produced objects correspond to a new style gnuradio block. """ - + @classmethod def includes(cls, item): if not isinstance(item, DoxyClass): @@ -33,7 +33,7 @@ class Group(object): """ Checks if doxyxml produced objects correspond to a group. """ - + @classmethod def includes(cls, item): if not isinstance(item, DoxyGroup): diff --git a/docs/sphinx/source/gr/index.rst b/docs/sphinx/source/gr/index.rst index 7df7114340..b3e341f47b 100644 --- a/docs/sphinx/source/gr/index.rst +++ b/docs/sphinx/source/gr/index.rst @@ -5,7 +5,7 @@ gnuradio.gr .. autosummary:: :nosignatures: - + gnuradio.gr.top_block gnuradio.gr.hier_block2 gnuradio.gr.block_detail diff --git a/docs/sphinx/source/index.rst b/docs/sphinx/source/index.rst index 491aaad4ce..3830d58c24 100644 --- a/docs/sphinx/source/index.rst +++ b/docs/sphinx/source/index.rst @@ -27,7 +27,7 @@ Core Framework gnuradio.wxgui .. toctree:: - :hidden: + :hidden: gnuradio.gr <gr/index> pmt <pmt/index> @@ -51,12 +51,12 @@ Hardware Interfaces .. autosummary:: :nosignatures: - + gnuradio.uhd gnuradio.fcd .. toctree:: - :hidden: + :hidden: gnuradio.uhd <uhd> gnuradio.fcd <fcd> @@ -72,7 +72,7 @@ Utilities gnuradio.eng_option .. toctree:: - :hidden: + :hidden: gnuradio.plot_data <plot_data> gnuradio.eng_notation <eng_notation/index> @@ -91,7 +91,7 @@ Framework Extensions gnuradio.vocoder .. toctree:: - :hidden: + :hidden: gnuradio.atsc <atsc/index> gnuradio.noaa <noaa> @@ -102,10 +102,10 @@ Framework Extensions .. Use this to add to the toctree but not displayed .. It's mostly to get rid of warnings - + .. toctree:: - :hidden: - + :hidden: + runtime_contents <gr/contents> atsc_blks <atsc/blks> digital_blocks <digital/blocks> @@ -163,4 +163,4 @@ Framework Extensions pmt_list <pmt/list> pmt_pair <pmt/pair> pmt_symbol <pmt/symbol> - + diff --git a/docs/sphinx/source/pmt/index.rst b/docs/sphinx/source/pmt/index.rst index 2d10378857..fd90a3d605 100644 --- a/docs/sphinx/source/pmt/index.rst +++ b/docs/sphinx/source/pmt/index.rst @@ -318,7 +318,7 @@ Misc ---- .. autosummary:: - :nosignatures: + :nosignatures: pmt.is_null pmt.cvar diff --git a/docs/sphinx/source/trellis/index.rst b/docs/sphinx/source/trellis/index.rst index 8a451a9130..be929e971c 100644 --- a/docs/sphinx/source/trellis/index.rst +++ b/docs/sphinx/source/trellis/index.rst @@ -17,7 +17,7 @@ Signal Processing Blocks .. autosummary:: :nosignatures: - + gnuradio.trellis.constellation_metrics_cf gnuradio.trellis.encoder_bb gnuradio.trellis.encoder_bi @@ -87,4 +87,4 @@ Constants gnuradio.trellis.TRELLIS_MIN_SUM gnuradio.trellis.TRELLIS_SUM_PRODUCT - + |