Commit 49aa78bb authored by Andreas Zwinkau's avatar Andreas Zwinkau

initial

parents
NAME=pflichtenheft
default: $(NAME).pdf
all: $(NAME).pdf
build/%.pdf: %.tex sty/*.sty
mkdir -p build
latexmk -pdf -g -f -auxdir=build -outdir=build $<
%.pdf: build/%.pdf
mv $< $@ # atomic!
cp $@ $<
cp $@ ~/Dropbox/ # store latest version in Dropbox
.PHONY: show clean distclean
show: $(NAME)_debug.pdf
xdg-open $<
clean:
rm -f *.tmp *.tui *.log *.tuc *.mp *.bbl *.blg *.fls *.idx *.aux *.out *.fdb_latexmk *.ilg *.ind
rm -rf build
distclean: clean
rm -f $(NAME).pdf
# Pflichtenheft
Eine Vorlage für Pflichtenhefte.
Primäres Feature sind exzessives Querverweise.
\documentclass[parskip=full]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[german]{babel}
\usepackage{hyperref}
\hypersetup{
pdftitle={Pflichtenheft},
bookmarks=true,
}
\usepackage{csquotes}
% cross referencing
\usepackage{sty/rdfref-user}
\usepackage{sty/rdfref-query}
\newcommand\partOf[1]{\AddProperty{doc:partOf}{#1}}
\newcommand\tests[1]{\AddProperty{pfl:tests}{#1}}
\newcommand\test[2]{\subsection{#1}\rdflabel{#2}
Testing: \Bind{#2}{pfl:tests}{?f}{ \GetVal{?f} }}
\newcommand\functionality[2]{\subsection{#1}\rdflabel{#2}
Tested by: \Bind{?t}{pfl:tests}{#2}{ \GetVal{?t} }}
\begin{document}
\section{Funktionen}
\rdflabel{sec:funktionen}
\subsection{Muss}
\rdflabel{sec:muss}
\partOf{sec:funktionen}
\functionality{Foo}{fnc:foo}
\functionality{Bar}{fnc:bar}
\subsection{Kann}
\rdflabel{sec:kann}
\partOf{sec:funktionen}
\section{Tests}
\rdflabel{sec:tests}
\test{First Start}{tst:first}
\tests{fnc:bar}
\end{document}
\ProvidesPackage{rdfref-core}
\RequirePackage{etoolbox,xstring}
\def\Nil{}%
\def\First#1#2{#1}
\def\Second#1#2{#2}
\def\parsecolon#1:#2\relax{\ifx#2\Nil\Nil\else#1\fi}%
\newcommand\RdfPrefix[1]{%
\parsecolon#1:\Nil\relax%
}
\newcommand\AddTriple[3]{%
%\edef\rdf@object{#3}
\immediate\write\@auxout{\noexpand\LoadTriple{#1}{#2}{\expandafter\detokenize\expandafter{#3}}}%
%\immediate\write\@auxout{\noexpand\LoadTriple{#1}{#2}{\rdf@object}}
}
% If we need to write something expanded, like \thepage
\newcommand\AddTripleEx[3]{%
% \edef\rdf@object{#3}%
% \immediate\write\@auxout{\noexpand\LoadTriple{#1}{#2}{\rdf@object}}%
\protected@write\@auxout{}{\protect\LoadTriple{#1}{#2}{#3}}
}
\newcommand\SetProperty[3]{%
\protected@csxdef{rdf@#1@#2}{#3}%
}
\newcommand\IfProperty[2]{%
\ifcsdef{rdf@#1@#2}%
}
\newcommand\GetProperty[2]{%
\IfProperty{#1}{#2}{%
\csuse{rdf@#1@#2}%
}{%
\PropertyNotDef{#1}{#2}%
}%
}
\newcommand\PropertyNotDef[2]{%
???%
%\typeout{rdf warning: subject #1 has no property #2}%
}
\edef\Hash{\string#}
\newcommand\Prefix[2]{%
%\edef\fuf{Prefix #2}
\ifcsdef{rdfprefix@#1}{%
\IfStrEq{\csuse{rdfprefix@#1}}{#2}{%
\typeout{Prefix #1 already exists for #2}%
}{\typeout{Prefix clash, uri #2 has already prefix \csuse{rdfprefix@#1}, #1 provided}%
}}{%
\csgdef{rdfprefix@#1}{#2}%
}
}
\newcommand\SubjectListAdd[2]{%
\listcsgadd{sbjlst@#1}{#2}%
}
\newcommand\MapSubjectList[2]{%
\def\do##1{#2}%
\ifcsdef{sbjlst@#1}{%
\dolistcsloop{sbjlst@#1}%
}{}%
}
\newcommand\PropertyListAdd[3]{%
\listcsgadd{prprtlst@#2}{{#1}{#3}}%
}
\newcommand\MapPropertyList[2]{%
\def\do##1{#2}%
\ifcsdef{prprtlst@#1}{%
\dolistcsloop{prprtlst@#1}%
}{}%
}
\newcommand\LoadTriple[3]{%
\SetProperty{#1}{#2}{#3}%
\SubjectListAdd{#1}{#2}%
\PropertyListAdd{#1}{#2}{#3}%
}
\ProvidesPackage{rdfref-query}
\RequirePackage{sty/rdfref-core}
\def\Var#1{Variable: #1}
\def\Value#1{Value: #1}
\newcommand\BindVal[2]{%
\IfBeginWith{#2}{?}{%
\ifcsdef{rdfquery@#2}{\def#1{\Value{\csuse{rdfquery@#2}}}}{\def#1{\Var{#2}}}%
}{\def#1{\Value{#2}}}%
}
\newcommand\SaveVal[2]{%
\csedef{rdfquery@#1}{#2}%
}
\newcommand\GetValProperty[2]{%
\expandafter\GetProperty\expandafter{\GetVal{#1}}{#2}%
}
\newcommand\GetVal[1]{%
\csuse{rdfquery@#1}%
}
\newcommand\QueryType[3]{%
\bgroup%
\def\Var##1{v}%
\def\Value##1{l}%
\xdef\qtype{#1#2#3}%
\egroup%
}
\newcommand\DeclareQueryProcessor[2]{%
\long\csgdef{rdfquery@proc@#1}##1{%
\long\def\continue{##1}%
#2}%
}
\DeclareQueryProcessor{vlv}{%
% why we redefine \Value and \Var? I should write comments next time
\def\Value##1{##1}%
\def\Var##1{##1}%
\MapPropertyList\predicate{%
\SaveVal\subject{\ifx\\##1\\\else\First##1\fi}%
\SaveVal\object{\ifx\\##1\\\else\Second##1\fi}%
\continue
}%
}
\DeclareQueryProcessor{vll}{%
% this is first querry processor after two years, I have no idea what
% needs to be done
\def\Value##1{##1}
\def\Var##1{##1}
\MapPropertyList\predicate{%
% only do action if searched \object is equal to current objeect
\IfStrEq{\object}{\ifx\\##1\\\else\Second##1\fi}{%
% ##1 is variable passed by \do, two tokens are here:
\SaveVal\subject{\ifx\\##1\\\else\First##1\fi}%
\SaveVal\object{\ifx\\##1\\\else\Second##1\fi}%
\continue}{}%
}%
}
\DeclareQueryProcessor{llv}{%
\def\Value##1{##1}%
\def\Var##1{##1}%
\IfProperty{\subject}{\predicate}{%
\SaveVal\object{\GetProperty{\subject}{\predicate}}
\continue}{}
}%
\DeclareQueryProcessor{lvv}{%
\def\Value##1{##1}%
\def\Var##1{##1}%
\MapSubjectList\subject{%
\SaveVal\predicate{##1}%
\SaveVal\object{\GetProperty{\subject}{##1}}%
\continue%
}%
}
\DeclareQueryProcessor{lvl}{%
\def\Value##1{##1}%
\def\Var##1{##1}%
\MapSubjectList\subject{%
\IfStrEq{\GetProperty{\subject}{##1}}{\object}{%
\SaveVal\predicate{##1}%
\continue%
}{}%
}%
}
\DeclareQueryProcessor{lll}{%
\def\Value##1{##1}%
\def\Var##1{##1}%
\IfStrEq{\GetProperty{\subject}{\predicate}}{\object}{\continue}{Neshoduj\'i se}
}
\newcommand\Bind[4]{%
\bgroup%
\BindVal\subject{#1}%
\BindVal\predicate{#2}%
\BindVal\object{#3}%
\QueryType\subject\predicate\object%
\ifcsdef{rdfquery@proc@\qtype}{\csuse{rdfquery@proc@\qtype}{#4}}{\typeout{\detokenize{Neznám procesor} \qtype}}%
\egroup%
}
% what is the purpose of this command?
\newcommand\OptionalBind[3]{%
%\bgroup%
\BindVal\subject{#1}%
\BindVal\predicate{#2}%
\BindVal\object{#3}%
\QueryType\subject\predicate\object%
\ifcsdef{rdfquery@proc@\qtype}{\csuse{rdfquery@proc@\qtype}{}}{\typeout{\detokenize{Neznám procesor} \qtype}}%
%#4
%\egroup%
}
\endinput
\ProvidesPackage{rdfref-user}
\RequirePackage{sty/rdfref-core,nameref}
\newwrite\exportfile
\def\RootObject{_:doc}
% blank nodes support
% useful for adding unnamed objects
\newcount\rdf@blank@cnt
% shouldn't this be document dependent?
\def\rdf@blk{blank}
\def\BlankNode{%
\global\advance\rdf@blank@cnt by 1\relax%
\expandafter\def\expandafter\CurrentObject\expandafter{_:\rdf@blk\the\rdf@blank@cnt}%
}
\def\CurrentObject{\RootObject}
% shouldn't this be in rdfref-core?
% Save property definitions, they are saved with \rdflabel
\newcommand\AddRdfType[2]{%
\def\do##1{\csgdef{rdf:type@##1}{\noexpand\unexpanded{#2}}}
%\csgdef{rdf:type@#1}{\unexpanded{#2}}
\docsvlist{#1}
}
\newcommand\AddProperty[2]{%
\AddTriple{\CurrentObject}{#1}{#2}%
}
% add expanded property
% usefull for adding page numbers etc
\newcommand\AddPropertyEx[2]{%
\AddTripleEx{\CurrentObject}{#1}{#2}%
}
\newcommand\WithObject[2]{%
\begingroup%
\def\CurrentObject{#1}%
\def\run{#2}
\run%
\endgroup%
}
\newcommand\UseRdfType[1]{%
\ifcsdef{rdf:type@\GuessRdfType{#1}}%
{\csuse{rdf:type@\GuessRdfType{#1}}}%
{\typeout{Package rdfref error: unknown type of reference #1 :\GuessRdfType{#1}:}}%
}
% we save these commands in order to enable letting \label etc. to \rdf..
% equivalents
% this also means, that rdfref should be loaded after all packages that modify
% ref mechanism (like all others such packages)
% if something goes wrong, redefine these macros to new definitions again
\let\rdfref@oldlabel\label
\let\rdfref@oldref\ref
\let\rdfref@oldpageref\pageref
% replacement for \label
\newcommand\rdflabel[1]{%
\rdfref@oldlabel{#1}
\AddTriple{#1}{doc:hasParent}{\CurrentObject}%
\AddTriple{#1}{doc:envir}{\@currenvir}%
\def\CurrentObject{#1}%
\UseRdfType{#1}
}
% replacement for \ref
\newcommand\rdfref@core[2]{%
\bgroup%
% save \CurrentObject
\edef\ParentObject{\CurrentObject}%
\BlankNode% \CurrentObject is blank node
\AddPropertyEx{doc:hasParent}{\ParentObject}%
\AddPropertyEx{doc:pageNo}{\thepage}%
\AddPropertyEx{doc:refersTo}{#1}%
\AddTripleEx{#1}{doc:referedBy}{\CurrentObject}%
\AddPropertyEx{rdfs:label}{Blank node: \rdf@blk\the\rdf@blank@cnt}%
#2%
\egroup%
}
\newcommand\rdfref[1]{%
\rdfref@core{#1}{%
\AddPropertyEx{rdf:type}{doc:reference}%
}%
\rdfref@oldref{#1}%
}
\newcommand\rdfpageref[1]{%
\rdfref@core{#1}{%
\AddPropertyEx{rdf:type}{doc:pagereference}%
}%
\rdfref@oldpageref{#1}%
}
\newcommand\GuessRdfType[1]{%
% We first try if current environment is defined as type, if not, then guess type from the parameter
\ifcsdef{rdf:type@\@currenvir}{\@currenvir}{%
\ifx\RdfPrefix{#1}\Nil\Nil\else%
\RdfPrefix{#1}%
\fi%
}%
}
% import ontology
\newcount\undercat
\newcommand\inputontology[1]{%
\makeatletter
\undercat=\the\catcode`\_
\catcode`\_=12
\input{#1}
\catcode`\_=\the\undercat
\makeatother
}
% This is horrible
\newcommand\ExportGraphviz[2]{%
digraph G\{
\forcsvlist{\listadd\typelist}{#1}
%\forcsvlist{\listadd\propertylist}{#2}
\def\worker##1##2{%
%"\ObjectLabel" -> \GetProperty{\First##1}
\edef\ppp{\GetProperty{##1}{##2}}
\typeout{Worker: ##1: ##1 : \ppp}
\IfSubStr{\ppp}{???}{}{%
"\ObjectLabel" -> %
\IfSubStr{\ppp}{:}{"\GetProperty{\GetProperty{\ppp}{rdf:type}}{rdfs:label}: \GetProperty{\ppp}{rdfs:label}"}{"\ppp"} %
%\GetProperty{##1}{##2}
[label="##2"];\\%
}
}
\MapPropertyList{rdf:type}{%
\xifinlist{\Second##1}{\typelist}{%
\edef\ObjectLabel{\GetProperty{\Second##1}{rdfs:label}: \GetProperty{\First##1}{rdfs:label}}%
%\ObjectLabel \& \Second##1\\}
\bgroup%
%\MapObjectList{\First##1}{}
\forcsvlist{\worker{\First##1}}{#2}%
\egroup
}%
{}%
}
\}
}
\endinput
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment