Convert sty to dtx and create an install file [WIP]

To have a proper LaTeX package convert the `dictionary.sty` to
`dictionary.dtx` and create the install file `dictionary.ins`.
This commit is contained in:
finga 2025-03-02 19:08:24 +01:00
parent cc886096f2
commit 75f198b464
5 changed files with 226 additions and 30 deletions

12
.gitignore vendored Normal file
View file

@ -0,0 +1,12 @@
*.aux
*.dvi
*.glo
*.gls
*.hd
*.idx
*.ilg
*.log
*.out
*.pdf
*.sty
*.toc

View file

@ -5,10 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
## v0.1.0 [Unreleased]
### Added
- Convert `dictionary.sty` to `dictionary.dtx` and create the install
file `dictionary.ins`.
- Set the languages of the dictionary by using the package options
`primary` and `secondary`.
- Create the `dictionary` environment where the

154
dictionary.dtx Normal file
View file

@ -0,0 +1,154 @@
% \iffalse meta-comment
%
% Copyright (C) 2024 by finga <finga@onders.org>
% ---------------------------------------------------------------------------
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
% http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This work has the LPPL maintenance status `maintained'.
%
% The Current Maintainer of this work is finga.
%
% This work consists of the files dictionary.dtx and dictionary.ins
% and the derived filebase dictionary.sty.
%
% \fi
%
% \iffalse
%<*driver>
\ProvidesFile{dictionary.dtx}
%</driver>
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<package>\ProvidesPackage{dictionary}
%<*package>
[2024/11/24 v0.1.0 dictionary]
%</package>
%
%<*driver>
\documentclass{ltxdoc}
\usepackage{dictionary}[2024/11/24]
\EnableCrossrefs
\CodelineIndex
\RecordChanges
\begin{document}
\DocInput{dictionary.dtx}
\PrintChanges
\PrintIndex
\end{document}
%</driver>
% \fi
%
% \CheckSum{34}
%
% \CharacterTable
% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
% Digits \0\1\2\3\4\5\6\7\8\9
% Exclamation \! Double quote \" Hash (number) \#
% Dollar \$ Percent \% Ampersand \&
% Acute accent \' Left paren \( Right paren \)
% Asterisk \* Plus \+ Comma \,
% Minus \- Point \. Solidus \/
% Colon \: Semicolon \; Less than \<
% Equals \= Greater than \> Question mark \?
% Commercial at \@ Left bracket \[ Backslash \\
% Right bracket \] Circumflex \^ Underscore \_
% Grave accent \` Left brace \{ Vertical bar \|
% Right brace \} Tilde \~}
%
%
% \changes{v0.1.0}{2024/11/24}{Initial version}
%
% \DoNotIndex{\newcommand,\newenvironment}
%
% \providecommand*{\url}{\texttt}
% \GetFileInfo{dictionary.dtx}
% \title{Create a \textsf{dictionary} in \LaTeX}
% \author{finga}
% \date{\fileversion~from \filedate}
%
% \maketitle
% \tableofcontents
%
% \begin{abstract}
% A \LaTeX\ style to print a dictionary.
% \end{abstract}
%
% \section{Introduction}
%
% This package uses datatool to build a database of entries
% andprovides macros to insert and ouput them.
%
% \section{Usage}
%
% Put text here.
%
%
% \DescribeMacro{\entry}
%
%
% \DescribeEnv{dictionary}
%
%
% \StopEventually{}
%
% \section{Implementation}
%
% \iffalse
%<*package>
% \fi
%
% \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{dictionary}[2024/11/24 Dictionary]
\RequirePackage{babel}
\RequirePackage{datatool}
\DeclareKeys[dictionary]{
primary.store = \@dictionary@primary,
secondary.store = \@dictionary@secondary
}
\ProcessKeyOptions[dictionary]
\PassOptionsToPackage{\@dictionary@primary,\@dictionary@secondary}
{babel}
% \end{macrocode}
%
% \begin{macro}{\entry}
% \begin{macrocode}
\newcommand{\entry}[2]{%
\DTLnewrow{dictionary}%
\DTLnewdbentry{dictionary}{word}{#1}%
\DTLnewdbentry{dictionary}{translation}{#2}%
}
% \end{macrocode}
% \end{macro}
%
%
% \begin{environment}{dictionary}
% \begin{macrocode}
\newenvironment{dictionary}{%
\DTLifdbexists{dictionary}
{\DTLcleardb{dictionary}}{\DTLnewdb{dictionary}}%
}{%
\DTLsort{word}{dictionary}%
\scriptsize%
\DTLforeach*{dictionary}{\word=word,\translation=translation}{%
\foreignlanguage{\@dictionary@primary}{\textbf{\word:}}
\foreignlanguage{\@dictionary@secondary}{\translation}\\}%
}
% \end{macrocode}
% \end{environment}
%
%
% \iffalse
%</package>
% \fi
%
% \Finale
\endinput

57
dictionary.ins Normal file
View file

@ -0,0 +1,57 @@
%% Copyright (C) 2024 by finga <finga@onders.org>
%% --------------------------------------------------------------------------
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%% http://www.latex-project.org/lppl.txt
%% and version 1.3 or later is part of all distributions of LaTeX
%% version 2005/12/01 or later.
%%
%% This work has the LPPL maintenance status `maintained'.
%%
%% The Current Maintainer of this work is finga.
%%
%% This work consists of the files dictionary.dtx and dictionary.ins
%% and the derived filebase dictionary.sty.
%%
\input docstrip.tex
\keepsilent
\usedir{tex/latex/dictionary}
\preamble
This is a generated file.
Copyright (C) 2024 by finga <finga@onders.org>
--------------------------------------------------------------------------
This work may be distributed and/or modified under the
conditions of the LaTeX Project Public License, either version 1.3
of this license or (at your option) any later version.
The latest version of this license is in
http://www.latex-project.org/lppl.txt
and version 1.3 or later is part of all distributions of LaTeX
version 2005/12/01 or later.
\endpreamble
\generate{\file{dictionary.sty}{\from{dictionary.dtx}{package}}}
\obeyspaces
\Msg{*************************************************************}
\Msg{* *}
\Msg{* To finish the installation you have to move the following *}
\Msg{* file into a directory searched by TeX: *}
\Msg{* *}
\Msg{* dictionary.sty *}
\Msg{* *}
\Msg{* To produce the documentation run the file dictionary.dtx *}
\Msg{* through LaTeX. *}
\Msg{* *}
\Msg{* Happy TeXing! *}
\Msg{* *}
\Msg{*************************************************************}
\endbatchfile

View file

@ -1,29 +0,0 @@
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{dictionary}[2024/11/24 Dictionary]
\RequirePackage{babel}
\RequirePackage{datatool}
\DeclareKeys[dictionary]{
primary.store = \@dictionary@primary,
secondary.store = \@dictionary@secondary
}
\ProcessKeyOptions[dictionary]
\PassOptionsToPackage{\@dictionary@primary,\@dictionary@secondary}{babel}
\newcommand{\entry}[2]{%
\DTLnewrow{dictionary}%
\DTLnewdbentry{dictionary}{word}{#1}%
\DTLnewdbentry{dictionary}{translation}{#2}%
}
\newenvironment{dictionary}{%
\DTLifdbexists{dictionary}{\DTLcleardb{dictionary}}{\DTLnewdb{dictionary}}%
}{%
\DTLsort{word}{dictionary}%
\scriptsize%
\DTLforeach*{dictionary}{\word=word,\translation=translation}{%
\foreignlanguage{\@dictionary@primary}{\textbf{\word:} }\foreignlanguage{\@dictionary@secondary}{\translation}\\}%
}