Skip to content

Commit

Permalink
Merge pull request #25 from thclark/fix-issue-#12
Browse files Browse the repository at this point in the history
Alter print methods to use __str__
  • Loading branch information
thclark committed May 3, 2022
2 parents 8352ed2 + 766951f commit 721e1be
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 8 deletions.
21 changes: 19 additions & 2 deletions docs/source/quick_start.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ The following RstCloth code: ::
d.h2('Code -- shebang')
d.codeblock('#!/usr/bin/env')

d.print_content()
print(str(d))

Would result in the following reStructuredText: ::

Expand Down Expand Up @@ -61,5 +61,22 @@ Example 2
]
)
doc.print_content()
print(str(doc))
Would result in the following reStructuredText: ::

================
Example Document
================


+-----------+-----------+-----------+
|Column 1 |Column 2 |Column 3 |
+===========+===========+===========+
|1 |2 |3 |
+-----------+-----------+-----------+
|4 |5 |6 |
+-----------+-----------+-----------+
|7 |8 |9 |
+-----------+-----------+-----------+

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "rstcloth"
version = "0.3.2"
version = "0.4.0"
description = "A simple Python API for generating RestructuredText."
authors = ["Tom Clark"]
license = "MIT"
Expand Down
4 changes: 2 additions & 2 deletions rstcloth/cloth.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@


class Cloth(object):
def print_content(self):
print("\n".join(self._data)) # noqa: T001
def __str__(self):
return "\n".join(self._data)

def write(self, filename):
"""
Expand Down
5 changes: 2 additions & 3 deletions rstcloth/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,9 +413,8 @@ def write(self, outputfile=None):
for line in self.output:
f.write(line + "\n")

def print_table(self):
for line in self.output:
print(line) # noqa: T001
def __str__(self):
return "\n".join(self.output)


###################################
Expand Down

0 comments on commit 721e1be

Please sign in to comment.