% \iffalse meta-comment
% A LaTeX Class and Package for the SMGloM Glossary
% Copyright (c) 2009 Michael Kohlhase, all rights reserved
%               this file is released under the
%               LaTeX Project Public License (LPPL)
%
% The original of this file is in the public repository at 
% http://github.com/KWARC/sTeX/
% \fi
%   
% \iffalse
%<package|cls>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<cls>\ProvidesClass{smglom}[2016/04/07 v0.1 Semantic Multilingual Glossary for Math]
%<sty>\ProvidesPackage{smglom}[2016/04/07 v0.1 Semantic Multilingual Glossary for Math]
%
%<*driver>
\documentclass{ltxdoc}
\usepackage{url,array,omdoc,omtext,float}
\usepackage[show]{ed}
\usepackage[hyperref=auto,style=alphabetic]{biblatex}
\addbibresource{kwarcpubs.bib}
\addbibresource{extpubs.bib}
\addbibresource{kwarccrossrefs.bib}
\addbibresource{extcrossrefs.bib}
\usepackage{stex-logo}
\usepackage{ctangit}
\usepackage{hyperref}
\makeindex
\floatstyle{boxed}
\newfloat{exfig}{thp}{lop}
\floatname{exfig}{Example}
\def\tracissue#1{\cite{sTeX:online}, \hyperlink{hstp://trac.kwarc.info/sTeX/ticket/#1}{issue #1}}
\begin{document}\DocInput{smglom.dtx}\end{document}
%</driver>
% \fi
% 
%\CheckSum{152}
% 
% \changes{v0.1}{2013/12/17}{First Version}
% \changes{v0.1}{2014/2/17}{Renamed ad split into \texttt{smglom.sty} and \texttt{smglom.cls}}
%
% 
% \MakeShortVerb{\|}
%
% \def\omdoc{OMDoc}
% \def\latexml{{\LaTeX}ML}
% \title{{\texttt{smglom.cls/sty}}: Semantic Multilingual Glossary for Math}
%    \author{Michael Kohlhase\\
%            Jacobs University, Bremen\\
%            \url{http://kwarc.info/kohlhase}}
% \maketitle
%
% \begin{abstract}
%   The |smglom| 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 an infrastructure for writing {\omdoc} glossary entries. 
% \end{abstract}
%
%\tableofcontents\newpage
% 
%\begin{omgroup}[id=sec:STR]{Introduction}
%
% \end{omgroup}
% 
% \begin{omgroup}[id=sec:user]{The User Interface}\
% 
%
% \begin{omgroup}[id=sec:user:options]{Package and Class Options}
%   |smglom.cls| accepts all options of the |omdoc.cls| and |article.cls| and just passes
%   them on to these. 
% \end{omgroup}
% 
% \end{omgroup}
% 
% \StopEventually{\newpage\PrintIndex\newpage\PrintChanges\printbibliography}\newpage
%
% \begin{omgroup}[id=sec:impl:cls]{Implementation: The SMGloM Class}
%
% \begin{omgroup}[id=sec:impl:cls:options]{Class Options}
%
% To initialize the |smglom| class, we pass on all options to |omdoc.cls| as well as the
% |stex| and |smglom| packages. 
% 
%    \begin{macrocode}
%<*cls>
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{omdoc}
                           \PassOptionsToPackage{\CurrentOption}{stex}
                           \PassOptionsToPackage{\CurrentOption}{smglom}}
\ProcessOptions
%    \end{macrocode}
% 
% We load |omdoc.cls|, the |smglom| package that provides the SMGloM-specific
% functionality\ednote{MK:describe that above}, and the |stex| package to allow OMDoc
% compatibility. 
%
%    \begin{macrocode}
\LoadClass{omdoc}
\RequirePackage{smglom}
\RequirePackage{stex}
\RequirePackage{amstext}
\RequirePackage{amsfonts}
%</cls>
%    \end{macrocode}
%
% Now we do the same thing for the package; first the options, which we just pass on to
% the |stex| package.  
%
%    \begin{macrocode}
%<*sty>
\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{statements}
                          \PassOptionsToPackage{\CurrentOption}{structview}
                          \PassOptionsToPackage{\CurrentOption}{smultiling}}
\ProcessOptions
%    \end{macrocode}
%
% We load |omdoc.cls|, and the desired packages. For the {\latexml} bindings, we make sure
% the right packages are loaded.
%
%    \begin{macrocode}
\RequirePackage{statements}
\RequirePackage[langfiles]{smultiling}
\RequirePackage{structview}
%    \end{macrocode}
% \end{omgroup}
% 
% \begin{omgroup}[id=sec:module-defs]{For Module Definitions} %
% \begin{macro}{\gimport}
% Just a shortcut, we have a starred and unstarred version, the first one is conservative.
% For example, if we execute:\newline
% \begin{center}
% |\gimport[smglom/numberfields]{naturalnumbers}|\newline
% \end{center}
% First we are redirected to |\@gimport@nostar|, we store the
% |smglom/numberfields|\meta{the repo's path} in |\@test|, then store
% |\mh@currentrepos|\meta{current directory} in |\mh@repos|. If no repo's path is offered,
% that means the module to import is under the same directory, so we let |repos=\mh@repos|
% and pass bunch of parameters to |\importmhmodule|, which is defined in |module.sty|. If
% there's a repo's path, then we let repos=\meta{the repo's path}. Finally we use
% |\mhcurrentrepos|(defined in |module.sty|) to change the |\mh@currentrepos|.
%    \begin{macrocode}
\def\gimport{\@ifstar\@gimport@star\@gimport@nostar}%
\newrobustcmd\@gimport@star[2][]{%
  \def\@test{#1}%
  \edef\mh@@repos{\mh@currentrepos}%
  \ifx\@test\@empty%
    \importmhmodule[conservative,repos=\mh@@repos,ext=tex,path=#2]{#2}%
  \else%
    \importmhmodule[conservative,repos=#1,ext=tex,path=#2]{#2}%
  \fi%
  \mhcurrentrepos{\mh@@repos}%
  \ignorespacesandpars%
}%
\newrobustcmd\@gimport@nostar[2][]{%
  \def\@test{#1}%
  \edef\mh@@repos{\mh@currentrepos}%
  \ifx\@test\@empty%
    \importmhmodule[repos=\mh@@repos,ext=tex,path=#2]{#2}%
  \else%
    \importmhmodule[repos=#1,ext=tex,path=#2]{#2}%
  \fi%
  \mhcurrentrepos{\mh@@repos}%
  \ignorespacesandpars%
}%
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{guse}
%   just a shortcut
%    \begin{macrocode}
\newrobustcmd\guse[2][]{%
  \def\@test{#1}%
  \edef\mh@@repos{\mh@currentrepos}%
  \ifx\@test\@empty%
    \usemhmodule[repos=\mh@@repos,ext=tex,path=#2]{#2}%
  \else%
    \usemhmodule[repos=#1,ext=tex,path=#2]{#2}%
  \fi%
  \mhcurrentrepos{\mh@@repos}%
  \ignorespacesandpars%
}%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{*nym}
%    \begin{macrocode}
\newrobustcmd\hypernym[3][]{\if@importing\else\par\noindent #2 is a hypernym of #3\fi}%
\newrobustcmd\hyponym[3][]{\if@importing\else\par\noindent #2 is a hyponym of  #3\fi}%
\newrobustcmd\meronym[3][]{\if@importing\else\par\noindent #2 is a meronym of #3\fi}%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\MSC}
%   to define the Math Subject Classification, \ednote{MK: what to do for the LaTeXML side?}
%    \begin{macrocode}
\newrobustcmd\MSC[1]{\if@importing\else MSC: #1\fi\ignorespacesandpars}%
%    \end{macrocode}
% \end{macro}
% \end{omgroup}
% 
% \begin{omgroup}[id=sec:langbindings]{For Language Bindings}
%
% Here we adapt the |smultiling| functionality to the special situation, where the module
% and file names are identical by design. 
%
% \begin{environment}{gviewsig}
%   The |gviewsig| environment is just a layer over the |mhviewsig| environment with the keys
%   suitably adapted.
%    \begin{macrocode}
\newenvironment{gviewsig}[4][]{%
  \def\test{#1}%
  \ifx\@test\@empty%
    \begin{mhviewsig}[frompath=#3,topath=#4]{#2}{#3}{#4}%
  \else%
    \begin{mhviewsig}[frompath=#3,topath=#4,#1]{#2}{#3}{#4}%
  \fi%
  \ignorespacesandpars%
}{%
  \end{mhviewsig}%
  \ignorespacesandparsafterend%
}%
%    \end{macrocode}
% \end{environment}
%
% \begin{environment}{gviewnl}
%   The |gviewnl| environment is just a layer over the |mhviewnl| environment with the
%   keys suitably adapted.
%    \begin{macrocode}
\newenvironment{gviewnl}[5][]{%
  \def\@test{#1}\ifx\@test\@empty%
    \begin{mhviewnl}[frompath=#4,topath=#5]{#2}{#3}{#4}{#5}%
  \else%
    \begin{mhviewnl}[frompath=#4,topath=#5,#1]{#2}{#3}{#4}{#5}%
  \fi%
\ignorespacesandpars%
}{%
  \end{mhviewnl}%
  \ignorespacesandparsafterend%
}%
%    \end{macrocode}
% \end{environment}
%
% \begin{macro}{\gincludeview}
%   \ednote{This is fake for now, needs to be implemented and documented}
%    \begin{macrocode}
\newcommand\gincludeview[2][]{\ignorespacesandpars}%
%    \end{macrocode}
% \end{macro}
% \end{omgroup}
% 
% \begin{omgroup}{Authoring States}
% We add a key to the module environment.
%    \begin{macrocode}
\addmetakey{module}{state}%
%    \end{macrocode}
% \end{omgroup}
%
% \begin{omgroup}{Shadowing of repositories}
% \begin{macro}{\repos@macro} 
%   |\repos@macro| parses a GitLab repository name \meta{group}|/|\meta{name} and creates
%   an internal macro name from that, which will be used 
%    \begin{macrocode}
\def\repos@macro#1/#2;{#1@shadows@#2}%
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{\shadow} 
%   |\shadow{|\meta{orig}|}{|\meta{fork}|}| declares a that the private repository
%   \meta{fork} shadows the MathHub repository \meta{orig}. Internally, it simply defines
%   an internal macro with the shadowing information.
%    \begin{macrocode}
\def\shadow#1#2{\@namedef{\repos@macro#1;}{#2}}%
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{\MathHubPath} 
%   |\MathHubPath{|\meta{repos}|}| computes the path of the fork that shadows the MathHub
%   repository \meta{repos} according to the current |\shadow| specification. The computed
%   path can be used for loading modules from the private version of \meta{repos}. 
%    \begin{macrocode}
\def\MathHubPath#1{\@ifundefined{\repos@macro#1;}{#1}{\@nameuse{\repos@macro#1;}}}%
%</sty>
%    \end{macrocode}
% \end{macro}
% \end{omgroup}
% \end{omgroup} 
% \Finale
\endinput
% \iffalse
%%% Local Variables: 
%%% mode: doctex
%%% TeX-master: t
%%% End: 
% \fi

% LocalWords:  iffalse cls smglo smglo.dtx omdoc latexml texttt smlog.cls sref SMGloM
% LocalWords:  maketitle newpage tableofcontents newpage omgroup ednote ltxml smglom.dtx
% LocalWords:  printbibliography showmeta metakeys amstext ginput newrobustcmd sproof cmath
% LocalWords:  module-defs gimport renewrobustcmd langbindings gle newenvironment amsfonts
% LocalWords:  doctex NeedsTeXFormat langfiles ngerman smultiling
