From f63057474a461fe814458c66515e281700f296df Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Thu, 19 Sep 2024 09:52:35 +0200 Subject: fix requirement ordering in reqs2tex --- reqs.toml | 27 +++++++++------------- scripts/reqs2tex.py | 65 ++++++++++++++++++++++++++++------------------------- 2 files changed, 45 insertions(+), 47 deletions(-) diff --git a/reqs.toml b/reqs.toml index 6645ea4..35c7a96 100644 --- a/reqs.toml +++ b/reqs.toml @@ -1,15 +1,10 @@ # This is a TOML file containing all project requirements. The reqs2tex script # can be used to generate the files necessary to compile requirements.tex and # cross-reference the requirements from other documents. -# -# Note that TOML has a hash table structure, so keys used for defining -# requirement properties cannot be used for requirement IDs. The properties are: -# label, type, id, index, deleted, done, description, priority # This is the requirement cross-reference ID. Requirements can be -# (cross-)referenced from LaTeX by prefixing this ID with `req:` and -# substituting dots for colons (i.e. this requirement is referenced as -# \cref{req:audio:async-api}). +# (cross-)referenced from LaTeX by prefixing this ID with `req:` (i.e. this +# requirement is referenced as \cref{req:audio}). [audio] # Requirement type ('system' | 'user') type = 'user' @@ -25,10 +20,10 @@ background music, while simultaniously playing sound effects. # is a list of strings, each item is treated as the ID of another requirement, # and the references are checked before LaTeX runs. done = [ - 'audio.async-api', - 'audio.handle', - 'audio.stream-mix', - 'audio.volume', + 'audio:async-api', + 'audio:handle', + 'audio:stream-mix', + 'audio:volume', ] #done = 'When I feel like it' # Requirements that are no longer applicable should set `deleted` to `true`. @@ -36,7 +31,7 @@ done = [ # different document revisions. #deleted = true -[audio.async-api] +[audio:async-api] type = 'system' priority = 'must' description = ''' @@ -44,7 +39,7 @@ The public audio \gls{api} supports starting audio samples asynchronously (i.e.~fire and forget). ''' -[audio.handle] +[audio:handle] type = 'system' priority = 'must' description = ''' @@ -52,14 +47,14 @@ The public audio \gls{api} allows the game programmer to control (i.e.~play, pause, resume and stop) audio samples after they are created/initialized. ''' -[audio.stream-mix] +[audio:stream-mix] type = 'system' priority = 'must' description = ''' The audio system supports playing multiple audio streams simultaniously. ''' -[audio.volume] +[audio:volume] type = 'system' priority = 'must' description = ''' @@ -67,7 +62,7 @@ The public audio \gls{api} allows the game programmer to control the volume of audio samples. ''' -[aux.license] +[aux:license] type = 'system' priority = 'must' description = ''' diff --git a/scripts/reqs2tex.py b/scripts/reqs2tex.py index e5f063d..1863b0d 100755 --- a/scripts/reqs2tex.py +++ b/scripts/reqs2tex.py @@ -1,9 +1,9 @@ #!/bin/python3 -import sys, tomllib, tex +import sys, tomllib, tex, re from enum import StrEnum def label2ref(*labels): - return ",".join(["req:" + label.replace('.', ':') for label in labels]) + return ",".join(["req:" + label for label in labels]) class KEY(StrEnum): LABEL = 'label' @@ -25,27 +25,6 @@ class REQ_PRIORITY(StrEnum): COULD = 'could' WONT = 'will not' -def flatten(data): - out = [] - for key, value in data.items(): - # this item is a requirement - if key == KEY.DESCRIPTION: - out.append(data) - - # skip over reserved keys - if key in KEY: continue - - # recursively flatten other requirements - items = flatten(value) - # and prefix them with the current key - for item in items: - if KEY.LABEL in item: - item[KEY.LABEL] = f"{key}.{item[KEY.LABEL]}" - else: - item[KEY.LABEL] = f"{key}" - out += items - return out - id_counter = 0 def make_id(item): global id_counter @@ -79,8 +58,7 @@ def sanitize(item, ids): die("definition of done includes unknown requirement(s)") item[KEY.DONE] = tex.cmd('Cref', label2ref(*item[KEY.DONE])) -def convert(data): - reqs = flatten(data) +def convert(reqs): all_ids = [item[KEY.LABEL] for item in reqs] index = 0 for item in reqs: @@ -94,6 +72,9 @@ def convert(data): # skip deleted requirements (but process for make_id) reqs = [item for item in reqs if item[KEY.DELETED] == False] + # sort by label + reqs = sorted(reqs, key=lambda req: req[KEY.LABEL]) + return reqs def fmt_aux(data): @@ -145,20 +126,42 @@ def fmt_tex(data): ) return out +def tomlload(content): + # replace requirement labels with temp value + label_map = dict() + label_idx = 0 + lines = content.split("\n") + for index, line in enumerate(lines): + match = re.search(r"^\s*\[(.+)\]", line) + if match is None: continue + lines[index] = f"[{label_idx}]" + label_map[str(label_idx)] = match.group(1) + label_idx += 1 + content = "\n".join(lines) + + # load TOML and replace temporary labels with real labels + data_dict = tomllib.loads(content) + data_list = [] + for key, value in data_dict.items(): + value[KEY.LABEL] = label_map[key] + data_list.append(value) + + return data_list + def main(input_file): - data = {} - with open(input_file, "rb") as file: - data = tomllib.load(file) + data = [] + with open(input_file, "r") as file: + data = tomlload(file.read()) - requirements = convert(data) + items = convert(data) output_aux = input_file.removesuffix(".toml") + ".aux" with open(output_aux, "w+") as file: - file.write(fmt_aux(requirements)) + file.write(fmt_aux(items)) output_tex = input_file.removesuffix(".toml") + ".tex" with open(output_tex, "w+") as file: - file.write(fmt_tex(requirements)) + file.write(fmt_tex(items)) if __name__ == "__main__": if len(sys.argv) != 2: -- cgit v1.2.3 From 43597e2e405276868aac640175e50931513a1ae0 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Thu, 19 Sep 2024 09:53:21 +0200 Subject: update time.txt --- time.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/time.txt b/time.txt index 509ed5b..afbfa38 100644 --- a/time.txt +++ b/time.txt @@ -34,6 +34,7 @@ loek: 2024-09-17 2h25m docs :: requirements loek: 2024-09-18 2h20m docs :: requirements loek: 2024-09-18 1h50m research :: audio loek: 2024-09-18 1h05m integration :: PR merge +loek: 2024-09-19 30m docs :: requirements max: 2024-09-02 1h project kickoff max: 2024-09-02 45m first project meeting -- cgit v1.2.3 From e99bf20eff8eb26a5b6f5ec31b7ba1dfc6480931 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Thu, 19 Sep 2024 12:20:58 +0200 Subject: update time.txt --- time.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/time.txt b/time.txt index afbfa38..1566870 100644 --- a/time.txt +++ b/time.txt @@ -35,6 +35,7 @@ loek: 2024-09-18 2h20m docs :: requirements loek: 2024-09-18 1h50m research :: audio loek: 2024-09-18 1h05m integration :: PR merge loek: 2024-09-19 30m docs :: requirements +loek: 2024-09-19 15m project meeting max: 2024-09-02 1h project kickoff max: 2024-09-02 45m first project meeting -- cgit v1.2.3 From 6655651c11bafde04122a451f35ed4bb9ed1808f Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Thu, 19 Sep 2024 14:51:47 +0200 Subject: update time.txt --- time.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/time.txt b/time.txt index 1566870..5f07bac 100644 --- a/time.txt +++ b/time.txt @@ -36,6 +36,8 @@ loek: 2024-09-18 1h50m research :: audio loek: 2024-09-18 1h05m integration :: PR merge loek: 2024-09-19 30m docs :: requirements loek: 2024-09-19 15m project meeting +loek: 2024-09-19 1h30m project meeting +loek: 2024-09-19 45m project meeting max: 2024-09-02 1h project kickoff max: 2024-09-02 45m first project meeting -- cgit v1.2.3 From b5ad864b5f020a73e4e0a068302cd22209f01fbb Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Thu, 19 Sep 2024 17:27:21 +0200 Subject: remove version from documents --- contributing.md | 4 ---- latexmkrc | 2 +- meta.tex | 1 - plan.tex | 8 -------- projdoc.cls | 11 ++++++++--- 5 files changed, 9 insertions(+), 17 deletions(-) diff --git a/contributing.md b/contributing.md index c11c834..db58388 100644 --- a/contributing.md +++ b/contributing.md @@ -2,10 +2,6 @@ This document is an extension of the [crêpe engine contribution guidelines][crepe-engine-contrib]. Rules in this document override those in the other document. -# Versioning - -- TODO: discuss w/ group - # Code style - Indent using tabs diff --git a/latexmkrc b/latexmkrc index 880f859..d2c3cdc 100644 --- a/latexmkrc +++ b/latexmkrc @@ -2,7 +2,7 @@ use File::Spec::Functions; -$pdflatex = "xelatex --interaction=nonstopmode %O %S"; +$pdflatex = "xelatex --interaction=nonstopmode --shell-escape %O %S"; $pdf_mode = 1; $dvi_mode = 0; $postscript_mode = 0; diff --git a/meta.tex b/meta.tex index cad4b81..db7c7b1 100644 --- a/meta.tex +++ b/meta.tex @@ -1,6 +1,5 @@ \organization{Avans University of Applied Sciences} \project{Project cr\^epe} -\version{0.0} \author{% Loek Le Blansch\and% Wouter Boerenkamps\and% diff --git a/plan.tex b/plan.tex index 076ce11..6ebd73a 100644 --- a/plan.tex +++ b/plan.tex @@ -1,15 +1,7 @@ \documentclass{projdoc} \input{meta.tex} -% @Jaro: Zie hieronder -% Version 0.0 seems not right -% I'm also missing a 'version table' -% Shall we use this version system?: -% Version numbers after the comma indicate an interim version and version numbers -% before the comma indicate versions ready for publication - \title{Project Plan} -\version{0.1} \begin{document} \tablestables diff --git a/projdoc.cls b/projdoc.cls index fe6317b..ee94835 100644 --- a/projdoc.cls +++ b/projdoc.cls @@ -164,8 +164,6 @@ \def\project#1{\def\@project{#1}} \let\@organization\relax \def\organization#1{\def\@organization{#1}} -\let\@version\relax -\def\version#1{\def\@version{#1}} \def\@maketitle{% \centering% \parskip=0pt% @@ -195,8 +193,15 @@ }% \vfill\flushright% \par{% - \par{\strut{}Version \@version\strut}% \par{\strut\@date\strut}% + \begingroup% + \endlinechar=\m@ne\everyeof{\noexpand}% + \edef\x{% + \endgroup% + \def\noexpand\commit{\@@input|"git rev-parse --short HEAD" }% + }% + \x% + \par{\strut\footnotesize({\ttfamily\commit})\strut}% }% \par\vspace*{2in}% } -- cgit v1.2.3 From 41ac21680ef13e2db543ff56728ecffe504d6850 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Thu, 19 Sep 2024 17:27:51 +0200 Subject: update time.txt --- time.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/time.txt b/time.txt index 5f07bac..165e927 100644 --- a/time.txt +++ b/time.txt @@ -38,6 +38,7 @@ loek: 2024-09-19 30m docs :: requirements loek: 2024-09-19 15m project meeting loek: 2024-09-19 1h30m project meeting loek: 2024-09-19 45m project meeting +loek: 2024-09-19 15m docs :: remove versioning max: 2024-09-02 1h project kickoff max: 2024-09-02 45m first project meeting -- cgit v1.2.3