From 26feeb970b5ac98747d5a0321d23be01bbf024f8 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Sat, 14 Sep 2024 11:14:55 +0200 Subject: update readme + time.txt --- readme.md | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) (limited to 'readme.md') diff --git a/readme.md b/readme.md index 1375c5e..b63392b 100644 --- a/readme.md +++ b/readme.md @@ -7,20 +7,16 @@ Please see [style.md](./style.md) for writing style and ## Compilation -- 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]. -- A [makefile](./makefile) is used to compile other files (e.g. plantuml - diagrams, [time report](#time-report)) -- These documents use fonts loaded using `fontspec`, please see - [style.md](./style.md) for download links. - -## Time report - -The time report document includes generated LaTeX code which can be compiled -from [time.txt](./time.txt) using [time2tex.py](./time2tex.py). The -[makefile](./makefile) includes a rule that does this, so `make timerep.pdf` -should be used to compile this document specifically. +Requirements: + +- A LaTeX distribution that includes the XeLaTeX compiler +- PlantUML +- Python 3 (timerep only) +- Fonts (see see [style.md](./style.md) for download links) + +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 -- cgit v1.2.3 From c9d4ba22a8b6d0d5fb1062701eda8b1af554d422 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Sat, 14 Sep 2024 20:41:10 +0200 Subject: WIP requirements --- .gitignore | 1 + latexmkrc | 8 ++++++-- readme.md | 11 +++-------- reqs.toml | 31 +++++++++++++++++++++++++++++++ reqs2tex.py | 27 +++++++++++++++++++++++++++ requirements.tex | 11 +++++++++++ time2tex.py | 34 +++++++++++++++++++--------------- 7 files changed, 98 insertions(+), 25 deletions(-) create mode 100644 reqs.toml create mode 100755 reqs2tex.py create mode 100644 requirements.tex (limited to 'readme.md') 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 ") + print("usage: time2tex.py time.txt") exit(1) - main() + main(sys.argv[1]) -- cgit v1.2.3 From b31ebef3db3765eef8e0492897e870a9fa4cd32b Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Mon, 16 Sep 2024 18:48:23 +0200 Subject: fix cross-reference links to external file --- example.tex | 4 ++-- projdoc.cls | 1 + readme.md | 6 ++++++ requirements.tex | 1 - scripts/reqs2tex.py | 13 +++++-------- 5 files changed, 14 insertions(+), 11 deletions(-) (limited to 'readme.md') diff --git a/example.tex b/example.tex index ee1377a..e0d21c0 100644 --- a/example.tex +++ b/example.tex @@ -3,7 +3,7 @@ % with the [draft] option. this replaces all images with placeholders. \input{meta.tex} -\input{reqs.aux} +\externaldocument{reqs}[./requirements.pdf] \title{Example Document} @@ -174,7 +174,7 @@ the glossary that is automatically printed after \codeinline{\end{document}}. \subsubsection{Requirements} Requirements are referenced like \codeinline{\label}s: -e.g.~\cref{req:audio:handle:id,req:audio:async-api:id}. +e.g.~\cref{req:audio:handle,req:audio:async-api}. \end{document} diff --git a/projdoc.cls b/projdoc.cls index c11fe61..8a592e3 100644 --- a/projdoc.cls +++ b/projdoc.cls @@ -40,6 +40,7 @@ \RequirePackage{tabularx} \RequirePackage{booktabs} \RequirePackage{needspace} +\RequirePackage{xr-hyper} \RequirePackage{hyperref} \RequirePackage{microtype} \RequirePackage{xcolor} diff --git a/readme.md b/readme.md index 818d445..7b58cfd 100644 --- a/readme.md +++ b/readme.md @@ -18,6 +18,12 @@ 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]. +## TODO + +- Requirement cross-references are broken (they print both the label and the + path to the other document, should be label only). Interesting: + `\creflabelformat` and `\@templabel` (inside #2 of `\creflabelformat`). + [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/requirements.tex b/requirements.tex index 39e5831..1b51220 100644 --- a/requirements.tex +++ b/requirements.tex @@ -6,6 +6,5 @@ \begin{document} - \end{document} diff --git a/scripts/reqs2tex.py b/scripts/reqs2tex.py index c5ab3dd..667eeb6 100755 --- a/scripts/reqs2tex.py +++ b/scripts/reqs2tex.py @@ -69,18 +69,15 @@ def convert(data): return reqs def req2aux(req): - # TODO: this is a dead-end solution, newlabel only works for in-document anchors, not external links + ref = tex.label2ref(req['label']) out = [ - tex.scmd('newlabel', f"req:{req['label']}:id", tex.group(req['id'], req['id'], '', './requirements.pdf', '')), - tex.scmd('newlabel', f"req:{req['label']}:id@cref", tex.group(f"[requirement][][]{req['id']}", '')), + tex.cmd('newlabel', f"{ref}", tex.group(req['id'], req['id'], 'ggg', 'hhh', 'iii')), + tex.cmd('newlabel', f"{ref}@cref", tex.group(f"[requirement][aaa][bbb]{req['id']}", '[ccc][ddd][eee]fff')), ] - return "\n".join([tex.auxout(line) for line in out]) + return "\n".join(out) def fmt_aux(data): - out = "" - out += tex.cmd('makeatletter') - out += "\n".join([req2aux(req) for req in data]) - out += tex.cmd('makeatother') + out = "\n".join([req2aux(req) for req in data]) return out def fmt_tex(data): -- cgit v1.2.3 From 6b034454f35819999cc26cfe472d537bf1eb3fbf Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Wed, 18 Sep 2024 13:40:39 +0200 Subject: fix requirement cross-references --- example.tex | 2 -- projdoc.cls | 83 +++++++++++++++++++++++++++++++++++++++++++++++------ readme.md | 6 ---- scripts/reqs2tex.py | 16 +++++++++-- 4 files changed, 88 insertions(+), 19 deletions(-) (limited to 'readme.md') diff --git a/example.tex b/example.tex index e0d21c0..24c525b 100644 --- a/example.tex +++ b/example.tex @@ -3,8 +3,6 @@ % with the [draft] option. this replaces all images with placeholders. \input{meta.tex} -\externaldocument{reqs}[./requirements.pdf] - \title{Example Document} \begin{document} diff --git a/projdoc.cls b/projdoc.cls index fe8c8bc..23f3ea9 100644 --- a/projdoc.cls +++ b/projdoc.cls @@ -145,13 +145,13 @@ % \cref{} is used \makeatletter \NewDocumentCommand{\customlabel}{omm}{% - \begingroup - \cref@constructprefix{#1}{\cref@result}% - \protected@edef\@currentlabel{#3}% - \protected@edef\@currentlabelname{#3}% - \protected@edef\cref@currentlabel{[#1][][\cref@result]#3} - \label[#1]{#2}% - \endgroup + \begingroup + \cref@constructprefix{#1}{\cref@result}% + \protected@edef\@currentlabel{#3}% + \protected@edef\@currentlabelname{#3}% + \protected@edef\cref@currentlabel{[#1][][\cref@result]#3} + \label[#1]{#2}% + \endgroup } \makeatother @@ -215,6 +215,9 @@ selection={recorded and deps and see}, ] +% requirements +\externaldocument{reqs}[./requirements.pdf] + % default document header/trailer \makeatletter \def\projdoc@header{ @@ -293,8 +296,8 @@ \def\UrlRight{\hbox{\,}}% } \DefineVerbatimEnvironment{blockcode}{Verbatim}{ - tabsize=2, - obeytabs, + tabsize=2, + obeytabs, } % scale down image if it exceeds page margins @@ -321,3 +324,65 @@ \crefname{test}{test}{tests} \Crefname{test}{Test}{Tests} +% fix cleveref showing filename to external cross-reference +% see +% edited from cleveref source +\makeatletter +\def\cref@getref#1#2{% + \expandafter\let\expandafter#2\csname r@#1@cref\endcsname% + \expandafter\expandafter\expandafter\def% + \expandafter\expandafter\expandafter#2% + \expandafter\expandafter\expandafter{% + \expandafter\@firstoffive#2}}% +\def\cpageref@getref#1#2{% + \expandafter\let\expandafter#2\csname r@#1@cref\endcsname% + \expandafter\expandafter\expandafter\def% + \expandafter\expandafter\expandafter#2% + \expandafter\expandafter\expandafter{% + \expandafter\@secondoffive#2}}% +\AtBeginDocument{% + \def\label@noarg#1{% + \cref@old@label{#1}% + \@bsphack% + \edef\@tempa{{page}{\the\c@page}}% + \setcounter{page}{1}% + \edef\@tempb{\thepage}% + \expandafter\setcounter\@tempa% + \cref@constructprefix{page}{\cref@result}% + \protected@write\@auxout{}{% + \string\newlabel{#1@cref}{% + {\cref@currentlabel}% + {[\@tempb][\arabic{page}][\cref@result]\thepage}% + {}% + {}% + {}% + }% + }% + \@esphack% + }% + \def\label@optarg[#1]#2{% + \cref@old@label{#2}% + \@bsphack% + \edef\@tempa{{page}{\the\c@page}}% + \setcounter{page}{1}% + \edef\@tempb{\thepage}% + \expandafter\setcounter\@tempa% + \cref@constructprefix{page}{\cref@result}% + \protected@edef\cref@currentlabel{% + \expandafter\cref@override@label@type% + \cref@currentlabel\@nil{#1}% + }% + \protected@write\@auxout{}{% + \string\newlabel{#2@cref}{% + {\cref@currentlabel}% + {[\@tempb][\arabic{page}][\cref@result]\thepage}% + {}% + {}% + {}% + }% + }% + \@esphack% + }% +} +\makeatother + diff --git a/readme.md b/readme.md index 7b58cfd..818d445 100644 --- a/readme.md +++ b/readme.md @@ -18,12 +18,6 @@ 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]. -## TODO - -- Requirement cross-references are broken (they print both the label and the - path to the other document, should be label only). Interesting: - `\creflabelformat` and `\@templabel` (inside #2 of `\creflabelformat`). - [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/scripts/reqs2tex.py b/scripts/reqs2tex.py index 700d05f..8a6976a 100755 --- a/scripts/reqs2tex.py +++ b/scripts/reqs2tex.py @@ -101,8 +101,20 @@ def fmt_aux(data): for item in data: ref = label2ref(item[KEY.LABEL]) out += [ - tex.cmd('newlabel', f"{ref}", tex.group(item[KEY.ID], item[KEY.ID], 'ggg', 'hhh', 'iii')), - tex.cmd('newlabel', f"{ref}@cref", tex.group(f"[requirement][aaa][bbb]{item[KEY.ID]}", '[ccc][ddd][eee]fff')), + tex.cmd('newlabel', f"{ref}", tex.group( + item[KEY.ID], + '', + '', + ref, + '', + )), + tex.cmd('newlabel', f"{ref}@cref", tex.group( + f"[requirement][][]{item[KEY.ID]}", + '[][][]', + '', + '', + './requirements.pdf', + )), ] return "\n".join(out) -- cgit v1.2.3 From 6b3fa9ceaf539b1bdcddf6284326a67c127d93a4 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Wed, 18 Sep 2024 16:05:07 +0200 Subject: update readme --- readme.md | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'readme.md') diff --git a/readme.md b/readme.md index 818d445..ece6512 100644 --- a/readme.md +++ b/readme.md @@ -3,20 +3,35 @@ systems programming in c++ minor project documentation Please see [style.md](./style.md) for writing style and -[contributing.md](./contributing.md) for coding and git standards. +[contributing.md](./contributing.md) for coding and git standards. There is +also [an example document](./example.tex) which may be used to copy/paste LaTeX +snippets for specific formatting. ## Compilation -Requirements: - -- A LaTeX distribution that includes the XeLaTeX compiler and latexmk +Prerequisites: +- A LaTeX distribution that includes XeLaTeX and latexmk - PlantUML - Python 3 - Fonts (see see [style.md](./style.md) for download links) -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]. +All documents are compiled using latexmk, and this repository contains +additional configuration files for the following editors: +- [Visual Studio Code][vscode] + [LaTeX Workshop][latexworkshop] +- (Neo)Vim + [VimTeX][vimtex] (source `.vimrc` to fix custom verb command + highlighting) + +## Special files + +- `time.txt` contains tracked time for each team member. This file is + automatically converted using [time2tex](scripts/time2tex.py) when compiling + [timerep.tex](./timerep.tex). +- `reqs.toml` contains the project requirements. This file is converted using + [reqs2tex](scripts/reqs2tex.py) for [requirements.tex](./requirements.tex) + and also generates an `.aux` file for cross-referencing the requirements from + other documents. +- `sources.bib` contains all bibliography entries / references +- `glossary.bib` contains all glossary entries [vscode]: https://code.visualstudio.com [latexworkshop]: https://marketplace.visualstudio.com/items?itemName=James-Yu.latex-workshop -- cgit v1.2.3