aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-09-18 14:54:48 +0200
committerLoek Le Blansch <loek@pipeframe.xyz>2024-09-18 14:54:48 +0200
commit0027f5df316892f121bb9f4b5b6b641646273ff0 (patch)
tree56edc328fd757ef1f22fa7aef99a7dd8bb3284bf
parentf2e1083970107994a031a394198fde039bdf3b77 (diff)
add requirements + improve generated reqs.tex
-rw-r--r--projdoc.cls7
-rw-r--r--reqs.toml39
-rw-r--r--requirements.tex1
-rwxr-xr-xscripts/reqs2tex.py15
-rw-r--r--scripts/tex.py10
5 files changed, 54 insertions, 18 deletions
diff --git a/projdoc.cls b/projdoc.cls
index 7420d38..fccf8c1 100644
--- a/projdoc.cls
+++ b/projdoc.cls
@@ -215,8 +215,11 @@
selection={recorded and deps and see},
]
-% requirements
-\externaldocument{reqs}[requirements.pdf]
+% allow cross-references to requirements.pdf from all documents except
+% requirements.pdf itself
+\IfEq*{\jobname}{requirements}{}{
+ \externaldocument{reqs}[requirements.pdf]
+}
% default document header/trailer
\makeatletter
diff --git a/reqs.toml b/reqs.toml
index c05cf71..6645ea4 100644
--- a/reqs.toml
+++ b/reqs.toml
@@ -10,33 +10,46 @@
# (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}).
-[audio.async-api]
+[audio]
# Requirement type ('system' | 'user')
-type = 'system'
+type = 'user'
# MoSCoW priority ('must' | 'should' | 'could' | 'will not')
priority = 'must'
# Requirement body. Supports LaTeX formatting. (tip: use single quotes so
# backslash doesn't act as an escape character)
description = '''
-The public audio \gls{api} supports starting audio samples asynchronously
-(i.e.~fire and forget).
+The engine allows the game programmer to easily start, pause and stop
+background music, while simultaniously playing sound effects.
'''
-# Definition of done (user requirements only). If 'done' is a string, it is
-# treated as LaTeX code (like description), if it is a list of strings, each
-# item is treated as the ID of another requirement.
+# Definition of done. If 'done' is a string, it is treated as LaTeX code, if it
+# 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',
+]
#done = 'When I feel like it'
-#done = [ 'audio.handle', 'audio.stream-mix' ]
# Requirements that are no longer applicable should set `deleted` to `true`.
# This will make sure the requirements are numbered consistently across
# different document revisions.
#deleted = true
+[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.
+pause, resume and stop) audio samples after they are created/initialized.
'''
[audio.stream-mix]
@@ -46,6 +59,14 @@ description = '''
The audio system supports playing multiple audio streams simultaniously.
'''
+[audio.volume]
+type = 'system'
+priority = 'must'
+description = '''
+The public audio \gls{api} allows the game programmer to control the volume of
+audio samples.
+'''
+
[aux.license]
type = 'system'
priority = 'must'
diff --git a/requirements.tex b/requirements.tex
index 2936272..cbaba81 100644
--- a/requirements.tex
+++ b/requirements.tex
@@ -6,6 +6,7 @@
\projdoc@description@labelindent=0pt
\projdoc@setdescriptionstyle
\makeatother
+\setcounter{secnumdepth}{1}
\title{Requirements}
diff --git a/scripts/reqs2tex.py b/scripts/reqs2tex.py
index 82b0aae..ff9f3bb 100755
--- a/scripts/reqs2tex.py
+++ b/scripts/reqs2tex.py
@@ -122,7 +122,7 @@ def fmt_tex(data):
out = ""
for item in data:
out += tex.join(
- tex.cmd('subsection', item[KEY.ID]),
+ tex.cmd('subsection', f"{item[KEY.ID]}: {item[KEY.LABEL]}".upper()),
tex.withatletter(
tex.cmd('cref@constructprefix', 'requirement', r'\cref@result'),
tex.pedef('@currentlabel', item[KEY.ID]),
@@ -130,12 +130,13 @@ def fmt_tex(data):
tex.pedef('cref@currentlabel', tex.group(['requirement'], [''], [r'\cref@result']) + item[KEY.ID]),
),
tex.cmd('label', ['requirement'], label2ref(item[KEY.LABEL])),
- tex.cmd('par'),
- tex.env('description', tex.join(
- tex.cmd('item', ['Priority']) + item[KEY.PRIORITY].title(),
- tex.cmd('item', ['Requirement']) + item[KEY.DESCRIPTION],
- (tex.cmd('item', ['Definition of done']) + item[KEY.DONE] if item[KEY.DONE] is not None else ""),
- ))
+ tex.cmd('parbox', tex.cmd('linewidth'),
+ tex.env('description', tex.join(
+ tex.cmd('item', ['Priority']) + item[KEY.PRIORITY].title(),
+ tex.cmd('item', ['Requirement']) + item[KEY.DESCRIPTION],
+ (tex.cmd('item', ['Definition of done']) + item[KEY.DONE] if item[KEY.DONE] is not None else ""),
+ )),
+ )
)
return out
diff --git a/scripts/tex.py b/scripts/tex.py
index e8fc65b..07d275a 100644
--- a/scripts/tex.py
+++ b/scripts/tex.py
@@ -69,3 +69,13 @@ def explist(*items):
out += explist(*item)
return out
+def sec(level, heading):
+ level = max(min(3, level), 0)
+ section = [
+ 'section',
+ 'subsection',
+ 'subsubsection',
+ 'paragraph',
+ ][level]
+ return cmd(section, heading)
+