summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/docshots/docshots.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/docshots/docshots.dtx')
-rw-r--r--macros/latex/contrib/docshots/docshots.dtx92
1 files changed, 59 insertions, 33 deletions
diff --git a/macros/latex/contrib/docshots/docshots.dtx b/macros/latex/contrib/docshots/docshots.dtx
index 393f867408..04a7402a2b 100644
--- a/macros/latex/contrib/docshots/docshots.dtx
+++ b/macros/latex/contrib/docshots/docshots.dtx
@@ -50,7 +50,7 @@
%<package>\NeedsTeXFormat{LaTeX2e}
%<package>\ProvidesPackage{docshots}
%<*package>
-[2024-01-09 0.4.1 TeX Samples Next to Their PDF Snapshots in DTX]
+[2024-01-13 0.4.2 TeX Samples Next to Their PDF Snapshots in DTX]
%</package>
%<*driver>
\documentclass{ltxdoc}
@@ -466,16 +466,37 @@ Hello, world!
% \section{Implementation}
% \changes{0.0.1}{2022/10/09}{Initial version}
-% First, we include a few packages:
+% First, we include \href{https://ctan.org/pkg/iexec}{iexec}
+% in order to execute shell commands, such as |pdflatex| and |pdfcrop|:
% \begin{macrocode}
\RequirePackage{iexec}
+% \end{macrocode}
+
+% Then, we include \href{https://ctan.org/pkg/fancyvrb}{fancyvrb}
+% in order to render verbatim texts:
+% \begin{macrocode}
\RequirePackage{fancyvrb}
+% \end{macrocode}
+
+% Then, we include \href{https://ctan.org/pkg/xcolor}{xcolor}
+% in order to make borders gray:
+% \begin{macrocode}
\RequirePackage{xcolor}
+% \end{macrocode}
+
+% Then, we include \href{https://ctan.org/pkg/graphicx}{graphicx}
+% in order to be able to use |\includegraphics| command:
+% \begin{macrocode}
\RequirePackage{graphicx}
+% \end{macrocode}
+
+% Then, we include \href{https://ctan.org/pkg/tikz}{tikz}
+% in order to be able to position elements:
+% \begin{macrocode}
\RequirePackage{tikz}
% \end{macrocode}
-% Then, we process package options:
+% Then, we process package options with the help of \href{https://ctan.org/pkg/pgfopts}{pgfopts}:
% \changes{0.0.4}{2022/10/18}{Package options "lstinputlisting" and "inputminted" introduced to enable printing of verbatim text either via listings or minted packages.}
% \changes{0.0.5}{2022/10/24}{Package option "log" added, which enables detailed logging via exec. By default, there is no logging at all.}
% \changes{0.2.0}{2022/10/26}{New package option "nocrop" added to allow disabling of "pdfcrop" execution.}
@@ -540,17 +561,21 @@ Hello, world!
% \begin{macro}{\docshots@mdfive}
% \changes{0.1.1}{2022/10/26}{New supplementary command added to calculate MD5 sum of a file.}
-% Then, we define a command for MD5 hash calculating of a file:
+% Then, we define a command for MD5 hash calculating of a file, with
+% the help of \href{https://ctan.org/pkg/pdftexcmds}{pdftexcmds}:
% \begin{macrocode}
\RequirePackage{pdftexcmds}
-\makeatletter\newcommand\docshots@mdfive[1]{\pdf@filemdfivesum{#1}}\makeatother
+\makeatletter
+\newcommand\docshots@mdfive[1]{\pdf@filemdfivesum{#1}}
+\makeatother
% \end{macrocode}
% \end{macro}
% \begin{macro}{docshot}
% Then, we define |docshot| environment:
% \begin{macrocode}
-\makeatletter\newenvironment{docshot}
+\makeatletter
+\newenvironment{docshot}
{\VerbatimEnvironment\begin{VerbatimOut}
{\docshots@tmpdir/\jobname/verbatim.tex}}
{\end{VerbatimOut}%
@@ -620,25 +645,7 @@ Hello, world!
"\docshots@tmpdir/\jobname/\hash.pdf"
"\docshots@tmpdir/\jobname/\hash.crop.pdf"}%
\fi}%
-% \end{macrocode}
-% We configure |fancyvrb|:
-% \begin{macrocode}
- \def\docshots@xopts{
- numbers=left,numbersep=3pt,
- frame=leftline,framerule=.2pt,rulecolor=\color{gray},
- samepage=true,
- commandchars=none,
- baselinestretch=1
- }%
- \ifdefined\docshots@small%
- \edef\docshots@xopts{\unexpanded\expandafter{\docshots@xopts},fontsize=\small}%
- \fi%
- \ifdefined\docshots@tiny%
- \edef\docshots@xopts{\unexpanded\expandafter{\docshots@xopts},fontsize=\scriptsize}%
- \fi%
- \ifdefined\docshots@opts
- \edef\docshots@xopts{\unexpanded\expandafter{\docshots@xopts},\docshots@opts}
- \fi
+ \message{docshots: the PDF is ready from line no. \the\inputlineno^^J}%
% \end{macrocode}
% Finally, we render the two-column content:
% \begin{macrocode}
@@ -660,38 +667,56 @@ Hello, world!
{\docshots@inputminted}
{\docshots@tmpdir/\jobname/\hash.tex}%
\else%
- \expandafter\VerbatimInput\expandafter[\docshots@xopts]
- {\docshots@tmpdir/\jobname/\hash.tex}%
+ \fvset{numbers=left,numbersep=3pt}%
+ \fvset{frame=leftline,framerule=.2pt,rulecolor=\color{gray}}%
+ \fvset{samepage=true}%
+ \fvset{commandchars=none}%
+ \fvset{baselinestretch=1}%
+ \ifdefined\docshots@small%
+ \fvset{fontsize=\small}%
+ \fi%
+ \ifdefined\docshots@tiny%
+ \fvset{fontsize=\scriptsize}%
+ \fi%
+ \ifdefined\docshots@opts%
+ \fvset{\docshots@opts}%
+ \fi%
+ \VerbatimInput{\docshots@tmpdir/\jobname/\hash.tex}%
\fi\fi%
\vspace{0pt}%
\end{minipage}%
\par%
\endgroup%
\docshotOptions{}%
-}\makeatother
+}
+\makeatother
% \end{macrocode}
% \end{macro}
% \begin{macro}{\docshotPrerequisite}
% Then, we define |\docshotPrerequisite| command:
% \begin{macrocode}
-\makeatletter\newcommand\docshotPrerequisite[1]{
+\makeatletter
+\newcommand\docshotPrerequisite[1]{
\iexec[\docshots@log,quiet]{cp #1 "\docshots@tmpdir/\jobname"}%
\message{docshots: File '#1' copied to
'\docshots@tmpdir/\jobname/#1'^^J}%
-}\makeatother
+}
+\makeatother
% \end{macrocode}
% \end{macro}
% \begin{macro}{\docshotAfter}
% Then, we define |\docshotAfter| command:
% \begin{macrocode}
-\makeatletter\newcommand\docshotAfter[1]{
+\makeatletter
+\newcommand\docshotAfter[1]{
\iexec[\docshots@log,quiet]{/bin/echo -n '\detokenize{#1}'
> "\docshots@tmpdir/\jobname/after.sh"}%
\message{docshots: File
'\docshots@tmpdir/\jobname/after.sh' created^^J}%
-}\makeatother
+}
+\makeatother
% \end{macrocode}
% \end{macro}
@@ -703,7 +728,8 @@ Hello, world!
\gdef\docshots@opts{}
\newcommand\docshotOptions[1]{%
\gdef\docshots@opts{#1}%
-}\makeatother
+}
+\makeatother
% \end{macrocode}
% \end{macro}