summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/stex/modules/modules.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/source/latex/stex/modules/modules.dtx')
-rw-r--r--Master/texmf-dist/source/latex/stex/modules/modules.dtx102
1 files changed, 74 insertions, 28 deletions
diff --git a/Master/texmf-dist/source/latex/stex/modules/modules.dtx b/Master/texmf-dist/source/latex/stex/modules/modules.dtx
index d68258bcdf6..11f392bfaa7 100644
--- a/Master/texmf-dist/source/latex/stex/modules/modules.dtx
+++ b/Master/texmf-dist/source/latex/stex/modules/modules.dtx
@@ -22,7 +22,7 @@
\usepackage{amsfonts}
\bibliography{kwarc}
\usepackage[eso-foot,today]{svninfo}
-\svnInfo $Id: modules.dtx 1502 2010-07-20 08:17:00Z kohlhase $
+\svnInfo $Id: modules.dtx 1676 2010-11-08 09:53:09Z kohlhase $
\svnKeyword $HeadURL: https://svn.kwarc.info/repos/stex/trunk/sty/modules/modules.dtx $
\usepackage{../ctansvn}
\usepackage{hyperref}
@@ -30,11 +30,12 @@
\floatstyle{boxed}
\newfloat{exfig}{thp}{lop}
\floatname{exfig}{Example}
+\def\tracissue#1{\cite{sTeX:online}, \hyperlink{http://trac.kwarc.info/sTeX/ticket/#1}{issue #1}}
\begin{document}\DocInput{modules.dtx}\end{document}
%</driver>
% \fi
%
-% \CheckSum{779}
+% \iffalse\CheckSum{787}\fi
%
% \changes{v0.9}{2005/06/14}{First Version with Documentation}
% \changes{v0.9a}{2005/07/01}{Completed Documentation}
@@ -148,6 +149,9 @@
% internal memory. As qualified imports are not fully implemented at the moment, they are
% turned off by default see Limitation~\ref{sec:limitations:qualified-imports}.
%
+% If the \DescribeMacro{showmeta}|showmeta| is set, then the metadata keys are shown
+% (see~\cite{Kohlhase:metakeys:ctan} for details and customization options).
+%
% \subsection{Modules and Inheritance}\label{sec:modules}
%
% \DescribeEnv{module} The |module| environment takes an optional |KeyVal|
@@ -493,26 +497,55 @@
% the current module from the \sTeX module signature (see Section~\ref{sec:modules}) via
% the |\importmodule| declaration.
%
-% \section{Tips and Tricks}\label{sec:tipstricks}
+% \subsection{No Forward Imports}\label{sec:limitations:forward-imports}
+%
+% {\sTeX} allows imports in the same file via |\importmodule{|\meta{mod}|}|, but due to
+% the single-pass linear processing model of {\TeX}, \meta{mod} must be the name of a
+% module declared {\emph{before}} the current point. So we cannot have forward imports as
+% in
+% \begin{verbatim}
+% \begin{module}[id=foo]
+% \importmodule{mod}
+% ...
+% \end{module}
+% ...
+% \begin{module}[id=mod]
+% ...
+% \end{module}
+% \end{verbatim}
+% a workaround, we can extract the module \meta{mod} into a file {{{mod.tex}}} and replace
+% it with |\sinput{mod}|, as in
+% \begin{verbatim}
+% \begin{module}[id=foo]
+% \importmodule[mod]{mod}
+% ...
+% \end{module}
+% ...
+% \sinput{mod}
+% \end{verbatim}
+% then the |\importmodule| command can read |mod.sms| (created via the |sms| utility)
+% without having to wait for the module \meta{mod} to be defined.
+%
%
-% \subsection{Forward References}\label{sec:limitations:forward-references}
+% \section{Limitations}\label{sec:limitations}
%
-% It is a inherent limitation of {\sTeX} that we cannot have simple forward references in
-% the same file (|\importmodules{|\meta{thy}|}|, where \meta{thy} is in the same file
-% after the occurrence of |\importmodule|). In this case, we need to use
-% |\importmodule[|\meta{jobname}|]{|\meta{thy}|}|, where \meta{jobname} is the name of the
-% file or (if it is the top-level file {\LaTeX} is called with) even |\jobname|.
+% In this section we document known limitations. If you want to help alleviate them,
+% please feel free to contact the package author. Some of them are currently discussed in
+% the \sTeX TRAC~\cite{sTeX:online}.
+% \begin{compactenum}
+% \item none reported yet
+% \end{compactenum}
%
% \StopEventually{\newpage\PrintIndex\newpage\PrintChanges\newpage\printbibliography}\newpage
%
% \section{The Implementation}
%
-% The |modules| package generates to files: the {\LaTeX} package (all the code between
-% {\textlangle\textsf{*package}\textrangle} and {\textsf{\textlangle/package\textrangle}}) and the
-% {\latexml} bindings (between {\textsf{\textlangle*ltxml\textrangle}} and
-% {\textsf{\textlangle/ltxml\textrangle}}). We keep the corresponding code fragments together,
-% since the documentation applies to both of them and to prevent them from getting out of
-% sync.
+% The |modules| package generates two files: the {\LaTeX} package (all the code between
+% {\textlangle\textsf{*package}\textrangle} and {\textsf{\textlangle/package\textrangle}})
+% and the {\latexml} bindings (between {\textsf{\textlangle*ltxml\textrangle}} and
+% {\textsf{\textlangle/ltxml\textrangle}}). We keep the corresponding code fragments
+% together, since the documentation applies to both of them and to prevent them from
+% getting out of sync.
%
% \subsection{Package Options}\label{sec:impl:options}
%
@@ -521,6 +554,7 @@
% (otherwise they stay false).
% \begin{macrocode}
%<*package>
+\DeclareOption{showmeta}{\PassOptionsToPackage{\CurrentOption}{metakeys}}
\newif\ifmod@show\mod@showfalse
\DeclareOption{show}{\mod@showtrue}
\newif\ifmod@qualified\mod@qualifiedfalse
@@ -907,6 +941,12 @@ DefConstructor('\metalanguage OptionalSemiverbatim {}',
% generates the {\omdoc} |symbol| and |presentation| elements (see
% Section~\ref{sec:impl:presentation}).
% \begin{macrocode}
+%<*package>
+\define@key{DefMathOp}{name}{\def\defmathop@name{#1}}
+\newcommand\DefMathOp[2][]{%
+\setkeys{DefMathOp}{#1}%
+\symdef[#1]{\defmathop@name}{#2}}
+%</package>
%<*ltxml>
DefMacro('\DefMathOp OptionalKeyVals:symdef {}',
sub {
@@ -914,9 +954,13 @@ DefMacro('\DefMathOp OptionalKeyVals:symdef {}',
my $name = KeyVal($keyval,'name') if $keyval;
#Rewrite this token
my $scopes = $STATE->getActiveScopes;
- DefMathRewrite(active=>$scopes,xpath=>'descendant-or-self::ltx:XMath',match=>ToString($pres),replace=>"\\".ToString($name));
+ DefMathRewrite(xpath=>'descendant-or-self::ltx:XMath',match=>ToString($pres),
+ replace=>sub{
+ map {$STATE->activateScope($_);} @$scopes;
+ $_[0]->absorb(Digest("\\".ToString($name)));
+ });
#Invoke symdef
- (Invocation(T_CS('\symdef'),$keyval,$name,undef,undef,$pres)->unlist);
+ (Invocation(T_CS('\symdef'),$keyval,$name,undef,undef,$pres)->unlist);
});
DefMacro('\symdef OptionalKeyVals:symdef {}[][]{}',
sub {
@@ -1092,7 +1136,7 @@ DefPrimitive('\@symdef OptionalKeyVals:symdef {}[][]{}', sub {
properties => {name=>$cs->toString, meaning=>$name,omcd=>$cd,role => $role},
scope=>$scope);
return; });
-%</ltxml>
+%</ltxml>%$
% \end{macrocode}
% \end{macro}
%
@@ -1146,9 +1190,9 @@ DefPrimitive('\abbrdef OptionalKeyVals:symdef {}[][]{}', sub {
% \begin{macrocode}
%<*package>
\def\mod@true{true}
-\omdaddkey[false]{termdef}{local}
-\omdaddkey{termdef}{name}
-\newcommand{\termdef}[3][]{\omdsetkeys{termdef}{#1}%
+\addmetakey[false]{termdef}{local}
+\addmetakey{termdef}{name}
+\newcommand{\termdef}[3][]{\metasetkeys{termdef}{#1}%
\expandafter\mod@newcommand\csname#2\endcsname[0]{#3\xspace}
\ifx\termdef@local\mod@true\else%
\@ifundefined{mod@id}{}{\expandafter\g@addto@macro\this@module%
@@ -1268,7 +1312,7 @@ DefMacro('\defpath{}{}', sub {
my $paths = LookupValue('defpath')||{};
$$paths{"$arg1"}=$arg2;
AssignValue('defpath'=>$paths,'global');
- DefMacro('\\'.$arg1.' {}',$arg2."/#1");
+ DefMacro('\\'.$arg1.' Semiverbatim',$arg2."/#1");
});#$
%</ltxml>
% \end{macrocode}
@@ -1498,9 +1542,11 @@ DefPrimitive('\sinput Semiverbatim', sub {
% \begin{macrocode}
%<*package>
\let\sinputref=\sinput
+\let\inputref=\input
%</package>
%<*ltxml>
-DefConstructor('\sinputref{}',"<omdoc:ref xref='#1.omdoc' type='include'/>");
+DefConstructor('\sinputref{}',"<omdoc:ref xref='#1.omdoc' type='cite' class='expandable'/>");
+DefConstructor('\inputref{}',"<omdoc:ref xref='#1.omdoc' type='cite' class='expandable'/>");
%</ltxml>
% \end{macrocode}
%
@@ -1699,16 +1745,16 @@ DefConstructor('\requirepackage{} Semiverbatim',"<omdoc:imports from='#2'/>",
% \begin{macrocode}
%<*package>
\srefaddidkey{view}
-\omdaddkey{view}{from}
-\omdaddkey{view}{to}
-\omdaddkey{view}{title}
+\addmetakey{view}{from}
+\addmetakey{view}{to}
+\addmetakey*{view}{title}
\ifmod@show
\newsavebox{\viewbox}
\newcounter{view}[section]
\def\view@heading{{\textbf{View} \thesection.\theview}
\sref@label@id{View \thesection.\theproblem}
\@ifundefined{view@title}{:\quad}{\quad(\view@title)\hfill\\}}
-\newenvironment{view}[1][]{\omdsetkeys{view}{#1}\sref@target\stepcounter{view}
+\newenvironment{view}[1][]{\metasetkeys{view}{#1}\sref@target\stepcounter{view}
\begin{lrbox}{\viewbox}\begin{minipage}{.9\textwidth}\importmodule{\view@to}}
{\end{minipage}\end{lrbox}
\setbox0=\hbox{\begin{minipage}{.9\textwidth}%
@@ -1843,7 +1889,7 @@ Tag('omdoc:theory',afterOpen=>\&numberIt,afterClose=>\&locateIt);
% LocalWords: coolurioff cwd ouri ifdefinable testopt ifnextchar xargdef bvars
% LocalWords: argdef yargdef somefunction symdeflocaltrue bvar xpath assoc qr
% LocalWords: symdeflocalfalse localpres isbound symdefs COMPLEXTOKEN localp
-% LocalWords: findnodes localname carg renewcommand omdaddkey omdsetkeys bbb
+% LocalWords: findnodes localname carg renewcommand bbb
% LocalWords: refundefinedtrue subsubsection blaaa makeatletter makeatother rm
% LocalWords: ifmodules gdef xdef xdef modulestrue modulesfalse pathpostfix
% LocalWords: updatedsms newreg xref texorpdfstring srefaddidkey newsavebox