Commit 5d8f715d authored by Marten Kenbeek's avatar Marten Kenbeek
Browse files

Updated collection script to include docstrings.

parent ceed4afb
# contents of runpytest.py
#!/usr/bin/env python
import sys
import pytest
......@@ -10,7 +10,7 @@ class MyPlugin:
def pytest_collection_modifyitems(self, items):
for item in items:
self.collected.append(item.nodeid)
self.collected.append((item.nodeid, item._obj.__doc__))
my_plugin = MyPlugin()
......@@ -20,7 +20,7 @@ file = open("test-coursera.tex", "w+")
currentname = ""
file.write("\\documentclass[preview]{standalone}\n \\begin{document}\n")
for nodeid in my_plugin.collected:
for nodeid, docstring in my_plugin.collected:
id = nodeid.split("::")
filename = id[0].replace("_", "\\_")
......@@ -31,5 +31,20 @@ for nodeid in my_plugin.collected:
currentname = filename
file.write("\\subsection{" + filename + "}\n\\begin{itemize}\n")
file.write("\\item " + functionname + "\n")
itemize = False
for line in docstring.splitlines(keepends=True):
if line.startswith(" -") and not itemize:
itemize = True
file.write(" \\begin{itemize}\n")
elif not line.startswith(" -") and itemize:
itemize = False
file.write(" \\end{itemize}\n")
if line.startswith(" -"):
line = line.replace(" - ", " \\item ")
file.write(line.replace("_", "\\_"))
if itemize:
file.write(" \\end{itemize}\n")
file.write("\n")
print(nodeid)
print(docstring)
file.write("\\end{itemize}\n\\end{document}\n")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment