From b5f007c31671b7b567c9f2f9021f0b4fdb377bcc Mon Sep 17 00:00:00 2001
From: Alexandru Fikl <alexfikl@gmail.com>
Date: Mon, 16 Aug 2021 15:49:26 -0500
Subject: [PATCH] add doctest to Table.latex

---
 pytools/__init__.py | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/pytools/__init__.py b/pytools/__init__.py
index 6d2bdfc..ad21b25 100644
--- a/pytools/__init__.py
+++ b/pytools/__init__.py
@@ -1695,11 +1695,29 @@ class Table:
         return output.getvalue().rstrip(csv_kwargs["lineterminator"])
 
     def latex(self, skip_lines=0, hline_after=None):
+        r"""Returns a string containing the rows of a LaTeX representation of
+        the table.
+
+        :arg skip_lines: number of lines to skip at the start of the table.
+        :arg hline_after: list of row indices after which to add an ``hline``
+            (the indices must subtract *skip_lines*, if non-zero).
+
+        .. doctest::
+
+            >>> tbl = Table()
+            >>> tbl.add_row([0, "skipped"])
+            >>> tbl.add_row([1, "apple"])
+            >>> tbl.add_row([2, "pear"])
+            >>> print(tbl.latex(skip_lines=1))
+            1 & apple \\
+            2 & pear \\
+        """
         if hline_after is None:
             hline_after = []
+
         lines = []
         for row_nr, row in enumerate(self.rows[skip_lines:]):
-            lines.append(f"{' & '.join(row)} \\")
+            lines.append(fr"{' & '.join(row)} \\")
             if row_nr in hline_after:
                 lines.append(r"\hline")
 
-- 
GitLab