From 2e3dbcef4f1570cfd31ec7c541e01c6d455fd2c5 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sat, 13 Jan 2024 21:23:02 +0000 Subject: docshots (13jan24) git-svn-id: svn://tug.org/texlive/trunk@69410 c570f23f-e606-0410-a88d-b1316a301751 --- .../texmf-dist/source/latex/docshots/docshots.dtx | 92 ++++++++++++++-------- 1 file changed, 59 insertions(+), 33 deletions(-) (limited to 'Master/texmf-dist/source/latex') diff --git a/Master/texmf-dist/source/latex/docshots/docshots.dtx b/Master/texmf-dist/source/latex/docshots/docshots.dtx index 393f867408d..04a7402a2b9 100644 --- a/Master/texmf-dist/source/latex/docshots/docshots.dtx +++ b/Master/texmf-dist/source/latex/docshots/docshots.dtx @@ -50,7 +50,7 @@ %\NeedsTeXFormat{LaTeX2e} %\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] % %<*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} -- cgit v1.2.3