| 1 |
%%%============================================================================== |
| 2 |
% WinEdt pragmas |
| 3 |
% !Mode:: "TeX:EN" |
| 4 |
% Default Compile engines: |
| 5 |
% !TEX program = pdflatex |
| 6 |
% !PDFTeXify ext = --enable-etex --restrict-write18 |
| 7 |
% !PDFLaTeX ext = --enable-etex --restrict-write18 |
| 8 |
% !BIB program = none |
| 9 |
%%%============================================================================== |
| 10 |
%% Copyright 2025-present by Alceu Frigeri |
| 11 |
%% |
| 12 |
%% This work may be distributed and/or modified under the conditions of |
| 13 |
%% |
| 14 |
%% * The [LaTeX Project Public License](http://www.latex-project.org/lppl.txt), |
| 15 |
%% version 1.3c (or later), and/or |
| 16 |
%% * The [GNU Affero General Public License](https://www.gnu.org/licenses/agpl-3.0.html), |
| 17 |
%% version 3 (or later) |
| 18 |
%% |
| 19 |
%% This work has the LPPL maintenance status *maintained*. |
| 20 |
%% |
| 21 |
%% The Current Maintainer of this work is Alceu Frigeri |
| 22 |
%% |
| 23 |
%% This is version {1.2a} {2026/01/03} |
| 24 |
%% |
| 25 |
%% The list of files that compose this work can be found in the README.md file at |
| 26 |
%% https://ctan.org/pkg/pkginfograb |
| 27 |
%% |
| 28 |
%%%============================================================================== |
| 29 |
\documentclass[10pt]{article} |
| 30 |
\RequirePackage[verbose,a4paper,marginparwidth=27.5mm,top=2.5cm,bottom=1.5cm,hmargin={40mm,20mm},marginparsep=2.5mm,columnsep=10mm,asymmetric]{geometry} |
| 31 |
\usepackage[T1]{fontenc} |
| 32 |
\usepackage[utf8]{inputenc} |
| 33 |
\usepackage{lmodern} |
| 34 |
\usepackage[infograb,silence]{codedescribe} |
| 35 |
\RequirePackage[inline]{enumitem} |
| 36 |
\SetEnumitemKey{miditemsep}{parsep=0ex,itemsep=0.4ex} |
| 37 |
|
| 38 |
|
| 39 |
\RequirePackage{pkginfograb} |
| 40 |
|
| 41 |
%% if needed |
| 42 |
%\RequirePackage[backend=biber]{biblatex} |
| 43 |
%\addbibresource{pkginfograb.bib} |
| 44 |
|
| 45 |
\RequirePackage[hidelinks,hypertexnames=false]{hyperref} |
| 46 |
|
| 47 |
\begin{document} |
| 48 |
\tstitle{ |
| 49 |
author={Alceu Frigeri\footnote{\tsverb{https://github.com/alceu-frigeri/pkginfograb}}}, |
| 50 |
date={\tsdate}, |
| 51 |
title={The pkginfograb Package\break Version \PkgInfo{pkginfograb}{version}} |
| 52 |
} |
| 53 |
|
| 54 |
|
| 55 |
\begin{typesetabstract} |
| 56 |
|
| 57 |
This package is aimed at package writers and offers a way to collect/document \LaTeX\ package's info (name, version, description, etc.) in a systematic way, including a mechanism to check package's version. Just a few functions are defined, to document/set package's info, retrieve them and to verify package's version (if it is newer than a given reference). |
| 58 |
|
| 59 |
\end{typesetabstract} |
| 60 |
|
| 61 |
%\tableofcontents |
| 62 |
|
| 63 |
\newcodekey{pkginfograb}{codeprefix={},resultprefix={},letter={@,_}, |
| 64 |
keywd=[2]{ |
| 65 |
pkginfograb_set,pkginfograb_get,pkginfograb_req_version,pkginfograb_req_date, |
| 66 |
pkginfograb_description, pkginfograbProvidesExplPackage, |
| 67 |
PkgInfoSet,PkgInfo,PkgInfoDescription,PkgInfoReqVersion,PkgInfoReqDate |
| 68 |
}, |
| 69 |
emph=[2]{name,prefix,version,date,description}, |
| 70 |
keywd={ExplSyntaxOn} |
| 71 |
} |
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
\section{Expl3 Commands}\label{expl3-cmds} |
| 76 |
|
| 77 |
|
| 78 |
\begin{codedescribe}{\pkginfograb_set:nn} |
| 79 |
\begin{codesyntax}% |
| 80 |
\tsmacro{\pkginfograb_set:nn}{pack-name,keyval-list} |
| 81 |
\end{codesyntax} |
| 82 |
This will create a property list associated with \tsobj[marg]{pack-name}. \tsobj[marg]{keyval-list} might contain any set of keys, though, the functions below expect at least \tsobj[meta,sep=or]{version,date} (for version checking) and \tsobj[meta]{name,date,version,description} (for \tsobj{\pkginfograb_description:n}). |
| 83 |
\end{codedescribe} |
| 84 |
\begin{tsremark} |
| 85 |
An error will be raised if calling it twice for the same \tsobj[marg]{pack-name}. |
| 86 |
\end{tsremark} |
| 87 |
|
| 88 |
For Example: |
| 89 |
\begin{codestore}[demoA] |
| 90 |
\pkginfograb_set:nn {pkginfograb} |
| 91 |
{ |
| 92 |
name = {pkginfograb} , |
| 93 |
prefix = {pkginfograb} , |
| 94 |
date = {2026/01/03}, |
| 95 |
version = {1.2a} , |
| 96 |
description = {Collecting~ package's~ info~ in~ a~ regular~ way} |
| 97 |
} |
| 98 |
\end{codestore} |
| 99 |
|
| 100 |
\tscode*[pkginfograb]{demoA} |
| 101 |
|
| 102 |
|
| 103 |
\begin{codedescribe}[code,update=2026/01/03]{\pkginfograbProvidesExplPackage,\pkginfograbProvidesExplClass,\pkginfograbProvidesExplFile} |
| 104 |
\begin{codesyntax}% |
| 105 |
\tsmacro{\pkginfograbProvidesExplPackage}{pack-name,keyval-list} |
| 106 |
\tsmacro{\pkginfograbProvidesExplClass}{pack-name,keyval-list} |
| 107 |
\tsmacro{\pkginfograbProvidesExplFile}{pack-name,keyval-list} |
| 108 |
\end{codesyntax} |
| 109 |
Same as \tsobj{\pkginfograb_set:nn}, but calling the commands \tsobj[code,sep=or]{\ProvidesExplPackage,\ProvidesExplClass,\ProvidesExplFile} |
| 110 |
right after, with the information just set. It assumes the following properties to be present: \tsobj[key]{name,date,version,description}. This doesn't follow \tsobj[pkg]{expl3} convention, since \tsobj[pkg]{expl3} code régime will starts only after the commands \tsobj[code,sep=or]{\ProvidesExpl...} are called. For Example: |
| 111 |
\end{codedescribe} |
| 112 |
|
| 113 |
|
| 114 |
\begin{codestore}[demoA] |
| 115 |
\pkginfograbProvidesExplPackage {newpackage} |
| 116 |
{ |
| 117 |
name = {newpackage} , |
| 118 |
prefix = {newpack} , |
| 119 |
date = {2026/01/03}, |
| 120 |
version = {1.0a} , |
| 121 |
description = {some~ lazy~ pack} |
| 122 |
} |
| 123 |
\end{codestore} |
| 124 |
|
| 125 |
\tscode*[pkginfograb]{demoA}[2] |
| 126 |
This will be equivalent to call \tsverb[code]{\ProvidesExplPackage {newpackage} {2026/01/03} {1.0a} {some~ lazy~ pack} } after \tsobj{\pkginfograb_set:nn}. |
| 127 |
\begin{tsremark} |
| 128 |
\tsobj[pkg]{expl3} code régime will be en force after them. |
| 129 |
\end{tsremark} |
| 130 |
\begin{codedescribe}{\pkginfograb_req_version:nnn} |
| 131 |
\begin{codesyntax}% |
| 132 |
\tsmacro{\pkginfograb_req_version:nnn}{your-pack,pack-name,min-version} |
| 133 |
\end{codesyntax} |
| 134 |
This will verify if \tsobj[marg]{pack-name}'s \tsobj[marg]{version} (as stored with \tsobj{\pkginfograb_set:nn}) is at least \tsobj[marg]{min-version}. It expects \tsobj[marg]{version} in one of three formats \tsobj[keys,sep=or]{[v]digits[letters],[v]digits.digits[letters],[v]digits.digits.digits[letters]} (the \tsobj[key]{[v]}, if present, is ignored). |
| 135 |
\end{codedescribe} |
| 136 |
\begin{tsremark} |
| 137 |
An error will be raised if \tsobj[marg]{pack-name}'s info isn't defined, incorrect version format or \tsobj[marg]{min-version} isn't satisfied, in which case the error will note that \tsobj{your-pack} needs version \tsobj[marg]{min-version} of \tsobj[marg]{pack-name}. |
| 138 |
\end{tsremark} |
| 139 |
|
| 140 |
\begin{codedescribe}{\pkginfograb_req_date:nnn} |
| 141 |
\begin{codesyntax}% |
| 142 |
\tsmacro{\pkginfograb_req_date:nnn}{your-pack,pack-name,min-date} |
| 143 |
\end{codesyntax} |
| 144 |
This will verify if \tsobj[marg]{pack-name}'s \tsobj[marg]{date} (as stored with \tsobj{\pkginfograb_set:nn}) is at least \tsobj[marg]{min-date}. It expects \tsobj[marg]{date} in one of three formats \tsobj[keys,sep=or]{YYYY/MM/DD,YYYY-MM-DD,YYYY.MM.DD} . |
| 145 |
\end{codedescribe} |
| 146 |
\begin{tsremark} |
| 147 |
An error will be raised if \tsobj[marg]{pack-name}'s info isn't defined, incorrect version format or \tsobj[marg]{min-version} isn't satisfied, in which case the error will note that \tsobj{your-pack} needs version \tsobj[marg]{min-date} of \tsobj[marg]{pack-name}. |
| 148 |
\end{tsremark} |
| 149 |
|
| 150 |
|
| 151 |
\begin{codedescribe}{\pkginfograb_set_aliases:} |
| 152 |
\begin{codesyntax}% |
| 153 |
\tsmacro{\pkginfograb_set_aliases:}{} |
| 154 |
\end{codesyntax} |
| 155 |
This will set \LaTeXe\ aliases for the \tsobj[pkg]{expl3} commands in this package. Note that none of the commands in \ref{2e-cmds} are defined by default, except \tsobj{\PkgInfoSetAliases} which is an alias for this command. |
| 156 |
\end{codedescribe} |
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
\begin{codedescribe}[code,EXP]{\pkginfograb_get:nn} |
| 161 |
\begin{codesyntax}% |
| 162 |
\tsmacro{\pkginfograb_get:nn}{pack-name,key} |
| 163 |
\end{codesyntax} |
| 164 |
This will retrieve \tsobj[marg]{key}'s value. If \tsobj[marg,sep=or]{pack-name,key} doesn't exist, this will expands to nothing. |
| 165 |
\end{codedescribe} |
| 166 |
|
| 167 |
\begin{codedescribe}{\pkginfograb_get:nnN} |
| 168 |
\begin{codesyntax}% |
| 169 |
\tsmacro{\pkginfograb_get:nnN}{pack-name,key,tl-var} |
| 170 |
\end{codesyntax} |
| 171 |
This will store \tsobj[marg]{key}'s value at \tsobj[marg]{tl-var}. If \tsobj[marg,sep=or]{pack-name,key} doesn't exist, \tsobj[marg]{tl-var} will be cleared. |
| 172 |
\end{codedescribe} |
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
\begin{codedescribe}{\pkginfograb_description:n} |
| 178 |
\begin{codesyntax}% |
| 179 |
\tsmacro{\pkginfograb_description:n}{pack-name} |
| 180 |
\end{codesyntax} |
| 181 |
This will typeset a small paragraph (for data validation) with following \tsobj[marg]{pack-name}'s info: \tsobj[meta]{name,version,date,description} |
| 182 |
\end{codedescribe} |
| 183 |
For example: |
| 184 |
\begin{codestore}[demoD] |
| 185 |
\ExplSyntaxOn |
| 186 |
\pkginfograb_description:n{pkginfograb} |
| 187 |
\ExplSyntaxOff |
| 188 |
\end{codestore} |
| 189 |
|
| 190 |
\tsdemo[pkginfograb]{demoD} |
| 191 |
|
| 192 |
|
| 193 |
\begin{codedescribe}[code,EXP,new=2025/11/01]{\pkginfograb_if_set_p:n,\pkginfograb_if_set:nTF} |
| 194 |
\begin{codesyntax}% |
| 195 |
\tsmacro{\pkginfograb_if_set_p:n}{pack-name} |
| 196 |
\tsmacro{\pkginfograb_if_set:nTF}{pack-name,if-true,if-false} |
| 197 |
\end{codesyntax} |
| 198 |
This will test if the given \tsobj[marg]{pack-name} was set with \tsobj{\pkginfograb_set:nn} and \tsobj[marg,sep=or]{if-true,if-false} will be properly executed. |
| 199 |
\end{codedescribe} |
| 200 |
|
| 201 |
|
| 202 |
\begin{codedescribe}[code,new=2025/11/01]{\pkginfograb_map_inline:n} |
| 203 |
\begin{codesyntax}% |
| 204 |
\tsmacro{\pkginfograb_map_inline:n}{inline-code} |
| 205 |
\end{codesyntax} |
| 206 |
\tsobj[marg]{inline-code} will receive (as \tsobj[arg]{\#1}) the name of each package set with \tsobj{\pkginfograb_set:nn} in the order they were set. |
| 207 |
\end{codedescribe} |
| 208 |
|
| 209 |
|
| 210 |
\begin{codestore}[demoD] |
| 211 |
\ExplSyntaxOn |
| 212 |
\pkginfograb_map_inline:n |
| 213 |
{ |
| 214 |
\pkginfograb_description:n{#1} |
| 215 |
} |
| 216 |
\ExplSyntaxOff |
| 217 |
\end{codestore} |
| 218 |
|
| 219 |
\tsdemo[pkginfograb]{demoD}[2] |
| 220 |
|
| 221 |
|
| 222 |
\section{LaTeX2e Commands' Aliases}\label{2e-cmds} |
| 223 |
All commands below are aliases to their \tsobj[pkg]{expl3} counterparts. Aside from \tsobj{\PkgInfoSetAliases} all other \LaTeX2e\ aliases aren't defined by default. Call either \tsobj[code,sep=or]{\pkginfograb_set_aliases:,\PkgInfoSetAliases} before using them. |
| 224 |
|
| 225 |
\begin{codedescribe}{\PkgInfoSet} |
| 226 |
\begin{codesyntax}% |
| 227 |
\tsmacro{PkgInfoSet}{pack-name,keyval-list} |
| 228 |
\end{codesyntax} |
| 229 |
This will create a property list associated with \tsobj[marg]{pack-name}. \tsobj[marg]{keyval-list} might contain any set of keys, though, the functions below expect at least \tsobj[meta]{version} (for version checking) and \tsobj[meta]{name,version,date,description} (for \tsobj{\PkgInfoDescription}). |
| 230 |
\end{codedescribe} |
| 231 |
\begin{tsremark} |
| 232 |
An error will be raised if calling it twice for the same \tsobj[marg]{pack-name}. |
| 233 |
\end{tsremark} |
| 234 |
For Example: |
| 235 |
\begin{codestore}[demoB] |
| 236 |
\PkgInfoSet {pkginfograb} |
| 237 |
{ |
| 238 |
name = {pkginfograb} , |
| 239 |
prefix = {pkginfograb} , |
| 240 |
date = {2026/01/03}, |
| 241 |
version = {1.2a} , |
| 242 |
description = {Collecting~ package's~ info~ in~ a~ regular~ way} |
| 243 |
} |
| 244 |
\end{codestore} |
| 245 |
|
| 246 |
\tscode*[pkginfograb]{demoB} |
| 247 |
|
| 248 |
\begin{codedescribe}{\PkgInfoReqVersion} |
| 249 |
\begin{codesyntax}% |
| 250 |
\tsmacro{\PkgInfoReqVersion}{your-pack,pack-name,min-version} |
| 251 |
\end{codesyntax} |
| 252 |
This will verify if \tsobj[marg]{pack-name}'s \tsobj[marg]{version} (as stored with \tsobj{\PkgInfoSet}) is at least \tsobj[marg]{min-version}. It expects \tsobj[marg]{version} in one of three formats \tsobj[keys,sep=or]{[v]digits[letters],[v]digits.digits[letters],[v]digits.digits.digits[letters]} (the \tsobj[key]{[v]}, if present, is ignored). |
| 253 |
\end{codedescribe} |
| 254 |
\begin{tsremark} |
| 255 |
An error will be raised if \tsobj[marg]{pack-name}'s info isn't defined, incorrect version format or \tsobj[marg]{min-version} isn't satisfied, in which case the error will note that \tsobj{your-pack} needs version \tsobj[marg]{min-version} of \tsobj[marg]{pack-name}. |
| 256 |
\end{tsremark} |
| 257 |
|
| 258 |
|
| 259 |
\begin{codedescribe}{\PkgInfoReqDate} |
| 260 |
\begin{codesyntax}% |
| 261 |
\tsmacro{\PkgInfoReqDate}{your-pack,pack-name,min-date} |
| 262 |
\end{codesyntax} |
| 263 |
This will verify if \tsobj[marg]{pack-name}'s \tsobj[marg]{date} (as stored with \tsobj{\PkgInfoSet}) is at least \tsobj[marg]{min-date}. It expects \tsobj[marg]{date} in one of three formats \tsobj[keys,sep=or]{YYYY/MM/DD,YYYY-MM-DD,YYYY.MM.DD} . |
| 264 |
\end{codedescribe} |
| 265 |
\begin{tsremark} |
| 266 |
An error will be raised if \tsobj[marg]{pack-name}'s info isn't defined, incorrect version format or \tsobj[marg]{min-version} isn't satisfied, in which case the error will note that \tsobj{your-pack} needs version \tsobj[marg]{min-date} of \tsobj[marg]{pack-name}. |
| 267 |
\end{tsremark} |
| 268 |
|
| 269 |
\begin{codedescribe}{\PkgInfoSetAliases} |
| 270 |
\begin{codesyntax}% |
| 271 |
\tsmacro{\PkgInfoSetAliases}{} |
| 272 |
\end{codesyntax} |
| 273 |
This will set \LaTeXe\ aliases for the \tsobj[pkg]{expl3} in this package. Note that none of the commands in \ref{2e-cmds} are defined by default, except this. |
| 274 |
\end{codedescribe} |
| 275 |
|
| 276 |
\begin{codedescribe}[code,EXP]{\PkgInfo} |
| 277 |
\begin{codesyntax}% |
| 278 |
\tsmacro{\PkgInfo}{pack-name,key} |
| 279 |
\end{codesyntax} |
| 280 |
This will retrieve \tsobj[marg]{key}'s value. If \tsobj[marg,sep=or]{pack-name,key} doesn't exist, this will expands to nothing. |
| 281 |
\end{codedescribe} |
| 282 |
|
| 283 |
\begin{codedescribe}{\PkgInfoGet} |
| 284 |
\begin{codesyntax}% |
| 285 |
\tsmacro{\PkgInfoGet}{pack-name,key,macro} |
| 286 |
\end{codesyntax} |
| 287 |
This will store \tsobj[marg]{key}'s value in \tsobj[marg]{macro}. If \tsobj[marg,sep=or]{pack-name,key} doesn't exist, \tsobj[marg]{macro} will be cleared. |
| 288 |
\end{codedescribe} |
| 289 |
|
| 290 |
|
| 291 |
\begin{codedescribe}{\PkgInfoDescription} |
| 292 |
\begin{codesyntax}% |
| 293 |
\tsmacro{\PkgInfoDescription}{pack-name} |
| 294 |
\end{codesyntax} |
| 295 |
This will typeset a small paragraph (for data validation) with following \tsobj[marg]{pack-name}'s info: \tsobj[meta]{name,version,date,description} |
| 296 |
\end{codedescribe} |
| 297 |
For example: |
| 298 |
\begin{codestore}[demoC] |
| 299 |
\PkgInfoDescription{pkginfograb} |
| 300 |
\end{codestore} |
| 301 |
|
| 302 |
\tsdemo[pkginfograb]{demoC} |
| 303 |
|
| 304 |
|
| 305 |
|
| 306 |
\begin{codedescribe}[code,new=2025/11/01]{\PkgInfoIfSet} |
| 307 |
\begin{codesyntax}% |
| 308 |
\tsmacro{\PkgInfoIfSet}{pack-name,if-true,if-false} |
| 309 |
\end{codesyntax} |
| 310 |
This will test if the given \tsobj[marg]{pack-name} was set with \tsobj{\PkgInfoSet} and \tsobj[marg,sep=or]{if-true,if-false} will be properly executed. |
| 311 |
\end{codedescribe} |
| 312 |
|
| 313 |
|
| 314 |
\begin{codedescribe}[code,new=2025/11/01]{\PkgInfoMapOver} |
| 315 |
\begin{codesyntax}% |
| 316 |
\tsmacro{\PkgInfoMapOver}{inline-code} |
| 317 |
\end{codesyntax} |
| 318 |
\tsobj[marg]{inline-code} will receive (as \tsobj[arg]{\#1}) the name of each package set with \tsobj{\PkgInfoSet} in the order they were set. |
| 319 |
\end{codedescribe} |
| 320 |
|
| 321 |
|
| 322 |
\begin{codestore}[demoE] |
| 323 |
\PkgInfoMapOver |
| 324 |
{ |
| 325 |
\PkgInfoDescription{#1} |
| 326 |
} |
| 327 |
\end{codestore} |
| 328 |
|
| 329 |
\tsdemo[pkginfograb]{demoE} |
| 330 |
|
| 331 |
|
| 332 |
%% if needed |
| 333 |
%\printbibliography |
| 334 |
|
| 335 |
\end{document} |