summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2020-04-22 00:32:55 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2020-04-22 00:32:55 -0400
commite1256ccb5a78d8cb3b4f2ab9904d80693b6959c9 (patch)
tree8af8f150e8c84bfd671e22b6bd988e96d6fc1f1c
parenta6f04d8f8d999a1440a34307d3646a33b2b23d74 (diff)
downloadcmd2-git-e1256ccb5a78d8cb3b4f2ab9904d80693b6959c9.tar.gz
Updated docs
-rw-r--r--cmd2/cmd2.py4
-rw-r--r--cmd2/table_creator.py8
-rw-r--r--cmd2/utils.py19
-rw-r--r--docs/api/index.rst1
-rw-r--r--docs/api/table_creator.rst35
-rw-r--r--docs/api/utils.rst1
6 files changed, 54 insertions, 14 deletions
diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py
index e0c28941..4db95678 100644
--- a/cmd2/cmd2.py
+++ b/cmd2/cmd2.py
@@ -1748,7 +1748,7 @@ class Cmd(cmd.Cmd):
:param line: the line being parsed
:return: the completed Statement
:raises: Cmd2ShlexError if a shlex error occurs (e.g. No closing quotation)
- EmptyStatement when the resulting Statement is blank
+ :raises: EmptyStatement when the resulting Statement is blank
"""
while True:
try:
@@ -1807,7 +1807,7 @@ class Cmd(cmd.Cmd):
:param line: the line being parsed
:return: parsed command line as a Statement
:raises: Cmd2ShlexError if a shlex error occurs (e.g. No closing quotation)
- EmptyStatement when the resulting Statement is blank
+ :raises: EmptyStatement when the resulting Statement is blank
"""
used_macros = []
orig_line = None
diff --git a/cmd2/table_creator.py b/cmd2/table_creator.py
index 28d16db7..b17bf452 100644
--- a/cmd2/table_creator.py
+++ b/cmd2/table_creator.py
@@ -21,12 +21,14 @@ SPACE = ' '
class HorizontalAlignment(Enum):
+ """Horizontal alignment of text in a cell"""
LEFT = 1
CENTER = 2
RIGHT = 3
class VerticalAlignment(Enum):
+ """Vertical alignment of text in a cell"""
TOP = 1
MIDDLE = 2
BOTTOM = 3
@@ -54,7 +56,7 @@ class Column:
:param max_data_lines: maximum lines allowed in a data cell. If line count exceeds this, then the final
line displayed will be truncated with an ellipsis. (defaults to INFINITY)
:raises: ValueError if width is less than 1
- ValueError if max_data_lines is less than 1
+ :raises: ValueError if max_data_lines is less than 1
"""
self.header = header
@@ -369,8 +371,8 @@ class TableCreator:
and a right row border. (Defaults to blank)
:return: row string
:raises: ValueError if data isn't the same length as self.cols
- TypeError if fill_char is more than one character (not including ANSI style sequences)
- ValueError if fill_char, pre_line, inter_cell, or post_line contains an unprintable
+ :raises: TypeError if fill_char is more than one character (not including ANSI style sequences)
+ :raises: ValueError if fill_char, pre_line, inter_cell, or post_line contains an unprintable
character like a newline
"""
class Cell:
diff --git a/cmd2/utils.py b/cmd2/utils.py
index 0749f32b..3fd9e3ac 100644
--- a/cmd2/utils.py
+++ b/cmd2/utils.py
@@ -704,6 +704,7 @@ def basic_complete(text: str, line: str, begidx: int, endidx: int, match_against
class TextAlignment(Enum):
+ """Horizontal text alignment"""
LEFT = 1
CENTER = 2
RIGHT = 3
@@ -728,8 +729,8 @@ def align_text(text: str, alignment: TextAlignment, *, fill_char: str = ' ',
portions are replaced by a '…' character. Defaults to False.
:return: aligned text
:raises: TypeError if fill_char is more than one character (not including ANSI style sequences)
- ValueError if text or fill_char contains an unprintable character
- ValueError if width is less than 1
+ :raises: ValueError if text or fill_char contains an unprintable character
+ :raises: ValueError if width is less than 1
"""
import io
import shutil
@@ -858,8 +859,8 @@ def align_left(text: str, *, fill_char: str = ' ', width: Optional[int] = None,
replaced by a '…' character. Defaults to False.
:return: left-aligned text
:raises: TypeError if fill_char is more than one character (not including ANSI style sequences)
- ValueError if text or fill_char contains an unprintable character
- ValueError if width is less than 1
+ :raises: ValueError if text or fill_char contains an unprintable character
+ :raises: ValueError if width is less than 1
"""
return align_text(text, TextAlignment.LEFT, fill_char=fill_char, width=width,
tab_width=tab_width, truncate=truncate)
@@ -881,8 +882,8 @@ def align_center(text: str, *, fill_char: str = ' ', width: Optional[int] = None
replaced by a '…' character. Defaults to False.
:return: centered text
:raises: TypeError if fill_char is more than one character (not including ANSI style sequences)
- ValueError if text or fill_char contains an unprintable character
- ValueError if width is less than 1
+ :raises: ValueError if text or fill_char contains an unprintable character
+ :raises: ValueError if width is less than 1
"""
return align_text(text, TextAlignment.CENTER, fill_char=fill_char, width=width,
tab_width=tab_width, truncate=truncate)
@@ -904,8 +905,8 @@ def align_right(text: str, *, fill_char: str = ' ', width: Optional[int] = None,
replaced by a '…' character. Defaults to False.
:return: right-aligned text
:raises: TypeError if fill_char is more than one character (not including ANSI style sequences)
- ValueError if text or fill_char contains an unprintable character
- ValueError if width is less than 1
+ :raises: ValueError if text or fill_char contains an unprintable character
+ :raises: ValueError if width is less than 1
"""
return align_text(text, TextAlignment.RIGHT, fill_char=fill_char, width=width,
tab_width=tab_width, truncate=truncate)
@@ -930,7 +931,7 @@ def truncate_line(line: str, max_width: int, *, tab_width: int = 4) -> str:
:param tab_width: any tabs in the text will be replaced with this many spaces
:return: line that has a display width less than or equal to width
:raises: ValueError if text contains an unprintable character like a newline
- ValueError if max_width is less than 1
+ :raises: ValueError if max_width is less than 1
"""
import io
from . import ansi
diff --git a/docs/api/index.rst b/docs/api/index.rst
index aa3371b9..2bb1be2c 100644
--- a/docs/api/index.rst
+++ b/docs/api/index.rst
@@ -28,6 +28,7 @@ This documentation is for ``cmd2`` version |version|.
history
plugin
py_bridge
+ table_creator
constants
**Modules**
diff --git a/docs/api/table_creator.rst b/docs/api/table_creator.rst
new file mode 100644
index 00000000..00dd70ba
--- /dev/null
+++ b/docs/api/table_creator.rst
@@ -0,0 +1,35 @@
+cmd2.table_creator
+==================
+
+.. autoclass:: cmd2.table_creator.HorizontalAlignment
+ :members:
+ :undoc-members:
+
+.. autoclass:: cmd2.table_creator.VerticalAlignment
+ :members:
+ :undoc-members:
+
+.. autoclass:: cmd2.table_creator.Column
+ :members:
+
+ .. automethod:: __init__
+
+.. autoclass:: cmd2.table_creator.TableCreator
+ :members:
+
+ .. automethod:: __init__
+
+.. autoclass:: cmd2.table_creator.SimpleTable
+ :members:
+
+ .. automethod:: __init__
+
+.. autoclass:: cmd2.table_creator.BorderedTable
+ :members:
+
+ .. automethod:: __init__
+
+.. autoclass:: cmd2.table_creator.AlternatingTable
+ :members:
+
+ .. automethod:: __init__
diff --git a/docs/api/utils.rst b/docs/api/utils.rst
index 8121fea8..d9166401 100644
--- a/docs/api/utils.rst
+++ b/docs/api/utils.rst
@@ -50,6 +50,7 @@ Text Alignment
.. autoclass:: cmd2.utils.TextAlignment
:members:
+ :undoc-members:
.. autofunction:: cmd2.utils.align_text