aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--latexmkrc8
-rw-r--r--readme.md11
-rw-r--r--reqs.toml31
-rwxr-xr-xreqs2tex.py27
-rw-r--r--requirements.tex11
-rwxr-xr-xtime2tex.py34
7 files changed, 98 insertions, 25 deletions
diff --git a/.gitignore b/.gitignore
index dfaa9e7..74caed0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -32,3 +32,4 @@
# generated files
time.tex
+reqs.tex
diff --git a/latexmkrc b/latexmkrc
index 293cf09..2ce20fa 100644
--- a/latexmkrc
+++ b/latexmkrc
@@ -14,7 +14,6 @@ $clean_ext .= ' %R.ist %R.xdy bbl run.xml';
push @file_not_found, '^Package .* No file `([^\\\']*)\\\'';
push @generated_exts, 'glo', 'gls', 'glg';
-
add_cus_dep('aux', 'glstex', 0, 'bib2gls');
sub bib2gls {
return system "bib2gls '$_[0]'";
@@ -27,6 +26,11 @@ sub plantuml {
add_cus_dep('txt', 'tex', 0, 'time2tex');
sub time2tex {
- return system "./time2tex.py '$_[0].txt' > '$_[0].tex'";
+ return system "python3 time2tex.py '$_[0].txt'";
+}
+
+add_cus_dep('toml', 'tex', 0, 'reqs2tex');
+sub reqs2tex {
+ return system "python3 reqs2tex.py '$_[0].toml'";
}
diff --git a/readme.md b/readme.md
index b63392b..818d445 100644
--- a/readme.md
+++ b/readme.md
@@ -9,20 +9,15 @@ Please see [style.md](./style.md) for writing style and
Requirements:
-- A LaTeX distribution that includes the XeLaTeX compiler
+- A LaTeX distribution that includes the XeLaTeX compiler and latexmk
- PlantUML
-- Python 3 (timerep only)
+- Python 3
- Fonts (see see [style.md](./style.md) for download links)
-A `latexmkrc` file is provided for copmilation with `latexmk`. The documents
+A `latexmkrc` file is provided for copmilation with latexmk. The documents
should also compile under [Visual Studio Code][vscode] using the [LaTeX
Workshop extension][latexworkshop], as well as [VimTeX][vimtex].
-## Requirements
-
-TODO: how to store + cross-reference requirements w/o extra latex compilation
-runs
-
[vscode]: https://code.visualstudio.com
[latexworkshop]: https://marketplace.visualstudio.com/items?itemName=James-Yu.latex-workshop
[vimtex]: https://github.com/lervag/vimtex
diff --git a/reqs.toml b/reqs.toml
new file mode 100644
index 0000000..5e00dd9
--- /dev/null
+++ b/reqs.toml
@@ -0,0 +1,31 @@
+[audio.async-api]
+type = 'system'
+priority = 'must'
+description = '''
+The public audio \gls{api} supports starting audio samples asynchronously
+(i.e.~fire and forget).
+'''
+
+[audio.handle]
+type = 'system'
+priority = 'must'
+description = '''
+The public audio \gls{api} allows the game programmer to control (i.e.~play,
+pause and stop) audio samples after they are created/initialized.
+'''
+
+[audio.stream-mix]
+type = 'system'
+priority = 'must'
+description = '''
+The audio system supports playing multiple audio streams simultaniously.
+'''
+
+[aux.license]
+type = 'system'
+priority = 'must'
+description = '''
+External libraries must have a license that is MIT-compatible, or one that
+allows linking against MIT code.
+'''
+
diff --git a/reqs2tex.py b/reqs2tex.py
new file mode 100755
index 0000000..68c8f40
--- /dev/null
+++ b/reqs2tex.py
@@ -0,0 +1,27 @@
+#!/bin/python3
+import sys, tomllib
+
+def fmt(data):
+ print(data)
+ return f"""
+\\makeatletter
+\\makeatother
+"""
+
+def main(input_file):
+ data = {}
+ with open(input_file, "rb") as file:
+ data = tomllib.load(file)
+
+ output = fmt(data)
+
+ output_file = input_file.removesuffix(".toml") + ".tex"
+ with open(output_file, "w+") as file:
+ file.write(output)
+
+if __name__ == "__main__":
+ if len(sys.argv) != 2:
+ print("usage: reqs2tex.py reqs.toml")
+ exit(1)
+ main(sys.argv[1])
+
diff --git a/requirements.tex b/requirements.tex
new file mode 100644
index 0000000..39e5831
--- /dev/null
+++ b/requirements.tex
@@ -0,0 +1,11 @@
+\documentclass{projdoc}
+\input{meta.tex}
+\input{reqs.tex}
+
+\title{Requirements}
+
+\begin{document}
+
+
+\end{document}
+
diff --git a/time2tex.py b/time2tex.py
index fe3091f..6e3de9c 100755
--- a/time2tex.py
+++ b/time2tex.py
@@ -24,12 +24,12 @@ def fmt_percentage(fac):
def fmt_member_overview(times):
# calculations
out = ""
- members = {}
+ tracked = {}
total_time = 0
for time in times:
- if not time["name"] in members:
- members[time["name"]] = 0
- members[time["name"]] += time["duration"]
+ if not time["name"] in tracked:
+ tracked[time["name"]] = 0
+ tracked[time["name"]] += time["duration"]
total_time += time["duration"]
# begin table
@@ -38,8 +38,9 @@ def fmt_member_overview(times):
out += r"\textbf{Member} & \textbf{Tracked} &\\\midrule{}"
# member overview
- for name, tracked in members.items():
- out += f"{name} & {fmt_duration(tracked)} & {fmt_percentage(tracked / total_time)}\\\\"
+ members = sorted(list(set(time["name"] for time in times)))
+ for name in members:
+ out += f"{name} & {fmt_duration(tracked[name])} & {fmt_percentage(tracked[name] / total_time)}\\\\"
out += r"\midrule{}"
# sum
@@ -58,7 +59,7 @@ def fmt_weekly_overview(times):
weeks = []
member_totals = {}
total_time = sum(time["duration"] for time in times)
- members = list(set(time["name"] for time in times))
+ members = sorted(list(set(time["name"] for time in times)))
time_start = min(time["date"] for time in times)
time_end = max(time["date"] for time in times)
week_start = time_start - timedelta(days=time_start.weekday()) # round down to nearest monday
@@ -86,6 +87,7 @@ def fmt_weekly_overview(times):
# begin table
out += r"\begin{table}\centering"
+ out += r"\fitimg{"
out += f"\\begin{{tabular}}{{l{'r@{~}l' * len(members)}@{{\\qquad}}r}}\\toprule"
out += r"\textbf{\#}"
for member in members:
@@ -105,6 +107,7 @@ def fmt_weekly_overview(times):
# end table
out += r"\bottomrule\end{tabular}"
+ out += r"}" # \fitimg
out += r"\caption{Tracked time per week}\label{tab:time-weekly}"
out += r"\end{table}"
@@ -170,17 +173,15 @@ def parse(content):
return out
def fmt(times):
- # TODO: Task overview
- print(f"""
+ return f"""
\\section{{Overviews}}\n
\\subsection{{Members}}\n
{fmt_member_overview(times)}
\\subsection{{Weekly}}\n
{fmt_weekly_overview(times)}
-""")
+"""
-def main():
- input_file = sys.argv[1]
+def main(input_file):
content = ""
with open(input_file, "r") as file:
content = file.read()
@@ -189,12 +190,15 @@ def main():
except Exception as e:
print(f"{input_file}: {e}")
exit(1)
+ output = fmt(parsed)
- fmt(parsed)
+ output_file = input_file.removesuffix(".txt") + ".tex"
+ with open(output_file, "w+") as file:
+ file.write(output)
if __name__ == "__main__":
if len(sys.argv) != 2:
- print("usage: time2tex <input>")
+ print("usage: time2tex.py time.txt")
exit(1)
- main()
+ main(sys.argv[1])