summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/stex/omd/omd.dtx
blob: ea175ed803ad6c1325eee718143fde61075071ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
% \iffalse meta-comment
% An Infrastructure for marking up Metadata in LaTeX documents
% $URL: https://svn.kwarc.info/repos/stex/trunk/sty/omd/omd.dtx $ 
% $Rev: 1502 $; last modified by $Author: kohlhase $ 
% $Date: 2010-07-20 10:17:00 +0200 (Tue, 20 Jul 2010) $
% Copyright (c) 2009 Michael Kohlhase, all rights reserved
%               this file is released under the
%               LaTeX Project Public License (LPPL)
% \fi
% 
% \iffalse
%<*package>
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{omd}[2010/06/25 v0.9 OMDoc Metadata Framework]
%</package>
%<*driver>
\documentclass{ltxdoc}
\usepackage{stex-logo,sref,url,array,float}
\usepackage[show]{ed}
\usepackage{../ctansvn}
\usepackage[eso-foot,today]{svninfo}
\usepackage[hyperref=auto,style=alphabetic]{biblatex}
\bibliography{kwarc}
\svnInfo $Id: omd.dtx 1502 2010-07-20 08:17:00Z kohlhase $
\svnKeyword $HeadURL: https://svn.kwarc.info/repos/stex/trunk/sty/omd/omd.dtx $
\usepackage{hyperref}
\makeindex
\floatstyle{boxed}
\newfloat{exfig}{thp}{lop}
\floatname{exfig}{Example}
\usepackage{omd}
\begin{document}\DocInput{omd.dtx}\end{document}
%</driver>
% \fi
%
%\CheckSum{58}
%
% \changes{v0.1}{2009/12/14}{First version}
% \changes{v0.9}{2010/06/18}{This is almost done}
% 
% \GetFileInfo{omd.sty}
% 
% \MakeShortVerb{\|}
% \def\scsys#1{{{\sc #1}}\index{#1@{\sc #1}}}
% \def\latexml{\scsys{LaTeXML}}
% \def\omdoc{OMDoc}
% \def\omdocv#1{\omdoc{#1}}
%
% \title{{\texttt{omd.sty}}: A generic framework for extensible Metadata in {\LaTeX}\thanks{Version {\fileversion} (last revised
%        {\filedate})}}
%    \author{Michael Kohlhase\\
%            Jacobs University, Bremen\\
%            \url{http://kwarc.info/kohlhase}}
% \maketitle
% \begin{abstract}
%   The |omd| package is part of the {\sTeX} collection, a version of {\TeX/\LaTeX} that
%   allows to markup {\TeX/\LaTeX} documents semantically without leaving the document
%   format, essentially turning {\TeX/\LaTeX} into a document format for mathematical
%   knowledge management (MKM).
%
%   This package supplies the infrastructure for extending {\sTeX} macros with {\omdoc}
%   metadata. This package is mainly intended for authors of {\sTeX} extension packages.
% \end{abstract}
%
% \setcounter{tocdepth}{2}\tableofcontents\newpage
%
%\section{Introduction}
% 
% The |omd| package supplies the infrastructure for extending {\sTeX} macros with
% ontology-based metadata. The |omd| infrastructure is intended to support the new
% metadata infrastructure for the {\omdoc} format~\cite{Kohlhase:omdoc1.2} introduced in
% {\omdocv{1.3}}~\cite{Kohlhase:OMDoc1.3}\ednote{continue}
%
% \section{The User Interface}\label{sec:user}
%
% The \DescribeMacro{\omdaddkey}|\omdaddkey| command takes two arguments, a metadata group
% \meta{group} and a metadata keyword name \meta{key}. It registers \meta{key} in the
% metadata group \meta{group}. The keys registered for a metadata group can be used for
% defining macros with a key/value arguments via the
% \DescribeMacro{\omdsetkeys}|\omdsetkeys| macro, see for instance the the definition in
% Figure~\ref{fig:foo}. With these definitions in a used package\footnote{The \texttt\@
%   character is only allowed in packages.}  |\foo[type=bar,id=f4711]| is formatted to
% \begin{quote}
% \omdaddkey{foo}{id}\omdaddkey{foo}{type}\makeatletter
% \newcommand\foo[1][]{\omdsetkeys{foo}{#1} I have seen a \emph{foo} of type \texttt{\foo@type}
% with identifier \texttt{\foo@id}!}\makeatother 
% \foo[type=bar,id=f4711]
% \end{quote}
% 
% \begin{exfig}[ht]
% \begin{verbatim}
% \omdaddkey{foo}{id}
% \omdaddkey{foo}{type}
% \newcommand\foo[1][]{\omdsetkeys{foo}{#1}
% I have seen a \emph{foo} of type \texttt{\foo@type} with identifier 
% \texttt\foo@id!}
% \end{verbatim}
% \vspace*{-2em}
% \caption{Defining a macro with metadata}
% \label{fig:foo}
% \end{exfig}
%
% \StopEventually{\newpage\PrintIndex\newpage\PrintChanges\printbibliography}
%
% \section{The Implementation}\label{sec:impl}
% 
% We build on the |keyval| package which we first need to load.
%    \begin{macrocode}
%<*package>
\RequirePackage{keyval}[1997/11/10]
%<*ltxml>
%</ltxml>
%    \end{macrocode}
%
% \begin{macro}{\omdaddkey}
%   An invocation of |\omdaddkey{|\meta{group}|}{|\meta{key}|}| macro first extends the
%   clearkeys macro and then defines the key \meta{key} with the |\define@key| macro from
%   the |keyval| package. This stores the key value given in the local macro
%   |\|\meta{group}|@|\meta{key}.
%    \begin{macrocode}
%<*package>
\newcommand\omdaddkey[3][]{\omd@ext@clear@keys{#2}{#3}{#1}%
\define@key{#2}{#3}[#1]{\expandafter\gdef\csname #2@#3\endcsname{##1}}}
%</package>
%<*ltxml>
%</ltxml>
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\omdsetkeys}
%    \begin{macrocode}
%<*package>
\newcommand\omdsetkeys[2]{\csname clear@#1@keys\endcsname\setkeys{#1}{#2}}
%</package>
%<*ltxml>
%</ltxml>
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\omd@ext@clear@keys}
%   |\omd@ext@clear@keys{|\meta{group}|}{|\meta{key}|}{|\meta{default}|}| extends (or sets
%   up if this is the first |\omdaddkey| for \meta{group}) the
%   |\clear@|\meta{group}|@keys| macro to set the default value \meta{default} for
%   \meta{key}. The |\clear@|\meta{group}|@keys| macro is used in the generic
%   |\omdsetkeys| macro below.
%    \begin{macrocode}
%<*package>
\newcommand\omd@ext@clear@keys[3]{\@omd@ext@clear@keys{#1}{#1@#2}{#3}}
\newcommand\@omd@ext@clear@keys[3]{\@ifundefined{clear@#1@keys}%
{\expandafter\def\csname clear@#1@keys\endcsname%
{\expandafter\gdef\csname #2\endcsname{#3}}}%
{\expandafter\g@addto@macro\csname clear@#1@keys\endcsname%
{\expandafter\gdef\csname #2\endcsname{#3}}}}
%</package>
%<*ltxml>
%</ltxml>
%    \end{macrocode}
% \end{macro}
%
% \subsection{Using better defaults than empty}
% 
% \begin{macro}{\omdaddkeynew}
%   |\omdaddkeynew| is an experimental version of |\omdaddkey| which gives
%   |\omd@unspecified| as an optional argument, so that it is used as the default value
%   here and then test for it in |\omfidus|. But unfortunately, this does not work yet.
%    \begin{macrocode}
%<*package>
\newcommand\omdaddkeynew[3][]{\omd@ext@clear@keys{#2}{#3}{#1}%
\define@key{#2}{#3}{\expandafter\gdef\csname #2@#3\endcsname{##1}}}
%</package>
%<*ltxml>
%</ltxml>
%    \end{macrocode}
% \end{macro}
%
% 
% \begin{macro}{\omd@unspecified}
%   Ain internal macro for unspecified values. It is used to initialize keys.\ednote{MK:
%   we could probably embed an package error or warning in here}
%    \begin{macrocode}
%<*package>
\newcommand\omd@unspecified{an omd-defined key left unspecified}
%</package>
%<*ltxml>
%</ltxml>
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\omdifus}
%   This just tests for equality of the first arg with |\omd@unspecified|
%    \begin{macrocode}
%<*package>
\newcommand\omdifus[4]{\message{testing #1@#2=\csname#1@#2\endcsname}\expandafter\ifx\csname #1@#2\endcsname\omd@unspecified{#3}\else{#4}\fi}
%</package>
%<*ltxml>
%</ltxml>
%    \end{macrocode}
% \end{macro}
%
% \subsection{Finale}
%
% Finally, we need to terminate the file with a success mark for perl.
%    \begin{macrocode}
%<ltxml>1;
%    \end{macrocode}
% \Finale
\endinput
% \iffalse
%%% Local Variables: 
%%% mode: doctex
%%% TeX-master: t
%%% End: 
% \fi


% LocalWords:  iffalse kohlhase Thu omd omd.dtx scsys sc sc latexml omdoc foo
% LocalWords:  omdocv texttt fileversion maketitle setcounter tocdepth newpage
% LocalWords:  tableofcontents ednote omdaddkey omdaddkey omdsetkeys omdsetkeys
% LocalWords:  makeatletter newcommand emph makeatother exfig vspace impl ltxml
% LocalWords:  printbibliography keyval clearkeys expandafter gdef csname ifx
% LocalWords:  endcsname setkeys ifundefined omdaddkeynew omfidus omdifus
% LocalWords:  doctex