%%
%% This is file `reqdoc.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% reqdoc.dtx  (with options: `package')
%% 
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{reqdoc}[2012/01/28 v0.3 Semantic Requirement Documents]
\DeclareOption{showmeta}{\PassOptionsToPackage{\CurrentOption}{metakeys}}
\newif\if@deps\@depsfalse
\DeclareOption{recorddeps}{\@depstrue}
\ProcessOptions
\RequirePackage{sref}
\RequirePackage{longtable}
\newif\ifreqsnum\reqsnumfalse
\addmetakey{reqs}{numbering}
\addmetakey[R]{reqs}{prefix}
\def\reqs@no{no}
\newenvironment{requirements}[1][]%
{\metasetkeys{reqs}{#1}\ifx\reqs@numbering\reqs@no\reqsnumfalse\else\reqsnumtrue\fi}{}
\addmetakey{req}{id}
\addmetakey{req}{prio}
\addmetakey{req}{refs}
\addmetakey{req}{num}
\newcounter{reqnum}[section]
\def\req@do@refs#1#2{\let\@tmpop=\relax\@for\@I:=#1\do{\@tmpop\req@do@ref{\@I}\let\@tmpop=#2}}
\def\req@do@ref#1{\sref@hlink@ifh{#1}{\req@ref{#1}{number}}}
\def\req@def@aux#1#2#3{\expandafter\xdef\csname req@#1@#2\endcsname{#3}}
\def\req@write@aux#1#2#3{\protected@write\@auxout{}{\string\req@def@aux{#1}{#2}{\thesection.#3}}}
\def\req@def#1#2#3{\req@def@aux{#1}{#2}{#3}\req@write@aux{#1}{#2}{#3}}
\def\req@ref#1#2{\csname req@#1@#2\endcsname}
\def\print@req@prio{\ifx\req@prio\@empty\else(Priority: \req@prio)\fi}
\def\print@req@label{\sref@target@ifh\req@id{\reqs@prefix\arabic{reqnum}: }}
\def\print@req@refs{\ifx\req@refs\@empty\else\hfill [from~\req@do@refs{\req@refs}{,}]\fi}
\newenvironment{requirement}[1][]%
{\metasetkeys{req}{#1}\stepcounter{reqnum}
\ifreqsnum\ifx\req@id\@empty\else\req@def\req@id{number}\thereqnum\fi
\noindent\textbf{\print@req@label}\fi
\newcommand{\reqnote}[1]{\par\noindent Note: ##1}
\print@req@prio}
{\medskip\print@req@refs}
\newenvironment{reqtable}[1][]{\metasetkeys{reqs}{#1}
\begin{center}\begin{longtable}{|l|l|p{6cm}|p{5cm}|l|}\hline
\# & Prio & Requirement & Notes & Refs\\\hline\hline}
{\end{longtable}\end{center}}
\newcommand{\reqline}[3][]%
{\metasetkeys{req}{#1}\stepcounter{reqnum}
\req@def\req@id{number}\thereqnum% remember the number for reference
\textbf{\sref@target@ifh\req@id{\reqs@prefix\arabic{reqnum}}}&
\req@prio &#2&#3&\req@do@refs\req@refs{,}\tabularnewline\hline}
\newcommand{\importreqs}[1]{\req@dep@write{"#1.tex"}{IMPORTREQS}\makeatletter\input{#1.aux}\makeatother}
\newcommand{\rinput}[1]{\req@dep@write{"#1.tex"}{[dt="input"]}\bgroup\@depsfalse\input{#1}\egroup}
\if@deps\newwrite\req@depfile
\immediate\openout\req@depfile=\jobname.deps
\AtEndDocument{\closeout\req@depfile}
\renewcommand{\importmodule}[2][]{\req@dep@write{"#1.tex"}{[dt="importmodule"]}\def\@test{#1}%
\ifx\@test\@empty\else\requiremodules{#1}\fi
\expandafter\gdef\csname#2@cd@file@base\endcsname{#1}
\activate@defs{#2}\export@defs{#2}}
\fi
\def\req@dep@write#1#2{\if@deps\protected@write\req@depfile{}{#1 #2}\fi}
\endinput
%%
%% End of file `reqdoc.sty'.
