From 9a041b7d9e060400f05af5cec995772c8939f9ba Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Tue, 18 Oct 2022 20:50:19 +0000 Subject: docshots (17oct22) git-svn-id: svn://tug.org/texlive/trunk@64739 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/latex/docshots/DEPENDS.txt | 2 + Master/texmf-dist/doc/latex/docshots/docshots.pdf | Bin 334497 -> 336674 bytes .../texmf-dist/source/latex/docshots/docshots.dtx | 93 +++++++++++++++++---- Master/texmf-dist/tex/latex/docshots/docshots.sty | 50 +++++++---- 4 files changed, 111 insertions(+), 34 deletions(-) (limited to 'Master/texmf-dist') diff --git a/Master/texmf-dist/doc/latex/docshots/DEPENDS.txt b/Master/texmf-dist/doc/latex/docshots/DEPENDS.txt index 194336badc4..da7d0486850 100644 --- a/Master/texmf-dist/doc/latex/docshots/DEPENDS.txt +++ b/Master/texmf-dist/doc/latex/docshots/DEPENDS.txt @@ -4,3 +4,5 @@ hard pdfcrop hard pgf hard pgf-blur hard pgfopts +hard listings +hard minted \ No newline at end of file diff --git a/Master/texmf-dist/doc/latex/docshots/docshots.pdf b/Master/texmf-dist/doc/latex/docshots/docshots.pdf index b4a800febda..fbec067a70e 100644 Binary files a/Master/texmf-dist/doc/latex/docshots/docshots.pdf and b/Master/texmf-dist/doc/latex/docshots/docshots.pdf differ diff --git a/Master/texmf-dist/source/latex/docshots/docshots.dtx b/Master/texmf-dist/source/latex/docshots/docshots.dtx index 18f9b6356ad..8dfd11cf522 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> -[2022-10-17 0.0.3 TeX Samples Next to Their PDF Snapshots in DTX] +[2022-10-18 0.0.4 TeX Samples Next to Their PDF Snapshots in DTX] % %<*driver> \documentclass{ltxdoc} @@ -306,6 +306,52 @@ Hello, world! % %\fi +% \DescribeMacro{log} +% With |log| option you can make us print all possible logs to the main \TeX{} log. +% By default, we don't do this and you won't see the output of |pdflatex| compilation, for example. +% Just use it like this: +%\iffalse +%<*verb> +%\fi +\begin{verbatim} +\usepackage[log]{docshot} +\end{verbatim} +%\iffalse +% +%\fi + +% \DescribeMacro{inputminted} +% By default, we render the verbatim text using |\VerbatimInput| command. You +% can change that and make us use |\inputminted| +% from \href{https://ctan.org/pkg/minted}{minted} package instead, for example: +%\iffalse +%<*verb> +%\fi +\begin{verbatim} +\usepackage{minted} +\setminted[java]{frame=lines,framesep=2mm} +\usepackage[inputminted=java]{docshot} +\end{verbatim} +%\iffalse +% +%\fi + +% \DescribeMacro{lstinputlisting} +% By default, we render the verbatim text using |\VerbatimInput| command. You +% can change that and make us use |\lstinputlisting| from +% \href{https://ctan.org/pkg/listings}{listings} package instead, for example: +%\iffalse +%<*verb> +%\fi +\begin{verbatim} +\usepackage{listings} +\lstset{basicstyle=\small} +\usepackage[lstinputlisting]{docshot} +\end{verbatim} +%\iffalse +% +%\fi + % \section{Prerequisites} % \DescribeMacro{\docshotPrerequisite} @@ -402,6 +448,10 @@ Hello, world! \pgfkeys{ /docshots/.cd, dtx/.store in=\docshots@dtx, + log/.store in=\docshots@log, + log/.default=, + lstinputlisting/.store in=\docshots@lstinputlisting, + inputminted/.store in=\docshots@inputminted, tmpdir/.store in=\docshots@tmpdir, tmpdir/.default=_docshots, small/.store in=\docshots@small, @@ -422,24 +472,24 @@ Hello, world! left/.default=.3\linewidth, right/.store in=\docshots@right, right/.default=.55\linewidth, - tmpdir,pdflatex,gs,pdfcrop,margin,hspace,left,right,runs + tmpdir,pdflatex,gs,pdfcrop,margin,hspace,left,right,runs,log } \ProcessPgfOptions{/docshots} % \end{macrocode} % Then, we print the version of |pdflatex| to \TeX{} log: % \begin{macrocode} -\iexec[log,quiet]{\docshots@pdflatex\space --version}% +\iexec[\docshots@log,quiet]{\docshots@pdflatex\space --version}% % \end{macrocode} % Then, we print the version of \href{https://ctan.org/pkg/pdfcrop}{pdfcrop} to \TeX{} log: % \begin{macrocode} -\iexec[log,quiet]{\docshots@pdfcrop\space --version}% +\iexec[\docshots@log,quiet]{\docshots@pdfcrop\space --version}% % \end{macrocode} % Then, we print the version of |ghostscript| to \TeX{} log: % \begin{macrocode} -\iexec[log,quiet]{\docshots@gs\space --version}% +\iexec[\docshots@log,quiet]{\docshots@gs\space --version}% % \end{macrocode} % Then, we make a directory where all temporary files will be kept: @@ -464,7 +514,8 @@ Hello, world! % \end{macrocode} % We calculate MD5 hashsum of the file content: % \begin{macrocode} - \def\hash{\pdfmdfivesum file {\docshots@tmpdir/\jobname/verbatim.tex}}% + \def\hash{\pdfmdfivesum file + {\docshots@tmpdir/\jobname/verbatim.tex}}% % \end{macrocode} % If the PDF with the required name already exists, we ignore this step. % Otherwise, we copy |verbatim.tex| into new file and run |pdflatex|: @@ -472,10 +523,10 @@ Hello, world! \IfFileExists{\docshots@tmpdir/\jobname/\hash.pdf} {\message{docshots: won't render, the PDF already exists (\docshots@tmpdir/\jobname/\hash.pdf)^^J}} - {\iexec[log,quiet]{cp \docshots@tmpdir/\jobname/verbatim.tex + {\iexec[\docshots@log,quiet]{cp \docshots@tmpdir/\jobname/verbatim.tex \docshots@tmpdir/\jobname/\hash.tex}% \foreach \n in {1,...,\docshots@runs}{ - \iexec[log,quiet]{cd \docshots@tmpdir/\jobname; + \iexec[\docshots@log,quiet]{cd \docshots@tmpdir/\jobname; \docshots@pdflatex\space -interaction=errorstopmode -halt-on-error @@ -483,16 +534,16 @@ Hello, world! \hash.tex} \message{docshots: pdflatex run no.\n^^J} \IfFileExists{\docshots@tmpdir/\jobname/after.sh} - {\iexec[log,quiet]{chmod a+x + {\iexec[\docshots@log,quiet]{chmod a+x \docshots@tmpdir/\jobname/after.sh} - \iexec[log,quiet]{cd \docshots@tmpdir/\jobname; + \iexec[\docshots@log,quiet]{cd \docshots@tmpdir/\jobname; ./after.sh \n\space \hash\space \hash.tex}} {}}}% % \end{macrocode} % Here we delete |after.sh| which may exist here after the last % compilation of |pdflatex|: % \begin{macrocode} - \iexec[log,quiet]{rm -f \docshots@tmpdir/\jobname/after.sh} + \iexec[\docshots@log,quiet]{rm -f \docshots@tmpdir/\jobname/after.sh} % \end{macrocode} % If a cropped version of the PDF with the required name already exists, we ignore this step. % Otherwise, we ask |pdfcrop| to crop the PDF: @@ -500,7 +551,7 @@ Hello, world! \IfFileExists{\docshots@tmpdir/\jobname/\hash.crop.pdf} {\message{docshots: on't pdfcrop, the PDF already exists (\docshots@tmpdir/\jobname/\hash.crop.pdf)^^J}} - {\iexec[log,quiet]{\docshots@pdfcrop\space + {\iexec[\docshots@log,quiet]{\docshots@pdfcrop\space --margins \docshots@margin\space \docshots@tmpdir/\jobname/\hash.pdf \docshots@tmpdir/\jobname/\hash.crop.pdf}}% @@ -509,7 +560,7 @@ Hello, world! % \begin{macrocode} \fvset{numbers=left,numbersep=3pt}% \fvset{frame=leftline,framerule=.4pt,rulecolor=\color{gray}}% - \fvset{samepage=true,baselinestretch=1}% + \fvset{samepage=true}% \fvset{baselinestretch=1}% \ifdefined\docshots@small% \fvset{fontsize=\small}% @@ -529,7 +580,14 @@ Hello, world! \hspace{\docshots@hspace}% \begin{minipage}[t]{\docshots@right}% \vspace{0pt}% - \VerbatimInput{\docshots@tmpdir/\jobname/\hash.tex}% + \ifdefined\docshots@lstinputlisting% + \lstinputlisting{\docshots@tmpdir/\jobname/\hash.tex}% + \else\ifdefined\docshots@inputminted% + \inputminted{\docshots@inputminted} + {\docshots@tmpdir/\jobname/\hash.tex}% + \else% + \VerbatimInput{\docshots@tmpdir/\jobname/\hash.tex}% + \fi\fi% \vspace{0pt}% \end{minipage}% \par% @@ -542,7 +600,7 @@ Hello, world! % Then, we define |\docshotPrerequisite| command: % \begin{macrocode} \newcommand\docshotPrerequisite[1]{ - \iexec[log,quiet]{cp #1 \docshots@tmpdir/\jobname}% + \iexec[\docshots@log,quiet]{cp #1 \docshots@tmpdir/\jobname}% \message{docshots: file #1 copied to \docshots@tmpdir/\jobname/#1^^J}% } @@ -553,9 +611,10 @@ Hello, world! % Finally, we define |\docshotAfter| command: % \begin{macrocode} \newcommand\docshotAfter[1]{ - \iexec[log,quiet]{/bin/echo -n '\detokenize{#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}% + \message{docshots: file + \docshots@tmpdir/\jobname/after.sh created^^J}% } % \end{macrocode} % \end{macro} diff --git a/Master/texmf-dist/tex/latex/docshots/docshots.sty b/Master/texmf-dist/tex/latex/docshots/docshots.sty index 4725e69c2db..f9f9c6225e5 100644 --- a/Master/texmf-dist/tex/latex/docshots/docshots.sty +++ b/Master/texmf-dist/tex/latex/docshots/docshots.sty @@ -31,7 +31,10 @@ \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{docshots} -[2022-10-17 0.0.3 TeX Samples Next to Their PDF Snapshots in DTX] +[2022-10-18 0.0.4 TeX Samples Next to Their PDF Snapshots in DTX] + + + @@ -67,6 +70,10 @@ \pgfkeys{ /docshots/.cd, dtx/.store in=\docshots@dtx, + log/.store in=\docshots@log, + log/.default=, + lstinputlisting/.store in=\docshots@lstinputlisting, + inputminted/.store in=\docshots@inputminted, tmpdir/.store in=\docshots@tmpdir, tmpdir/.default=_docshots, small/.store in=\docshots@small, @@ -87,15 +94,15 @@ left/.default=.3\linewidth, right/.store in=\docshots@right, right/.default=.55\linewidth, - tmpdir,pdflatex,gs,pdfcrop,margin,hspace,left,right,runs + tmpdir,pdflatex,gs,pdfcrop,margin,hspace,left,right,runs,log } \ProcessPgfOptions{/docshots} -\iexec[log,quiet]{\docshots@pdflatex\space --version}% +\iexec[\docshots@log,quiet]{\docshots@pdflatex\space --version}% -\iexec[log,quiet]{\docshots@pdfcrop\space --version}% +\iexec[\docshots@log,quiet]{\docshots@pdfcrop\space --version}% -\iexec[log,quiet]{\docshots@gs\space --version}% +\iexec[\docshots@log,quiet]{\docshots@gs\space --version}% \iexec[null]{mkdir -p \docshots@tmpdir/\jobname}% @@ -107,14 +114,15 @@ \iexec[null]{perl -i -0777pe "s/(\\n|^)\\x{25} /\\1/g" \docshots@tmpdir/\jobname/verbatim.tex}% \fi% - \def\hash{\pdfmdfivesum file {\docshots@tmpdir/\jobname/verbatim.tex}}% + \def\hash{\pdfmdfivesum file + {\docshots@tmpdir/\jobname/verbatim.tex}}% \IfFileExists{\docshots@tmpdir/\jobname/\hash.pdf} {\message{docshots: won't render, the PDF already exists (\docshots@tmpdir/\jobname/\hash.pdf)^^J}} - {\iexec[log,quiet]{cp \docshots@tmpdir/\jobname/verbatim.tex + {\iexec[\docshots@log,quiet]{cp \docshots@tmpdir/\jobname/verbatim.tex \docshots@tmpdir/\jobname/\hash.tex}% \foreach \n in {1,...,\docshots@runs}{ - \iexec[log,quiet]{cd \docshots@tmpdir/\jobname; + \iexec[\docshots@log,quiet]{cd \docshots@tmpdir/\jobname; \docshots@pdflatex\space -interaction=errorstopmode -halt-on-error @@ -122,22 +130,22 @@ \hash.tex} \message{docshots: pdflatex run no.\n^^J} \IfFileExists{\docshots@tmpdir/\jobname/after.sh} - {\iexec[log,quiet]{chmod a+x + {\iexec[\docshots@log,quiet]{chmod a+x \docshots@tmpdir/\jobname/after.sh} - \iexec[log,quiet]{cd \docshots@tmpdir/\jobname; + \iexec[\docshots@log,quiet]{cd \docshots@tmpdir/\jobname; ./after.sh \n\space \hash\space \hash.tex}} {}}}% - \iexec[log,quiet]{rm -f \docshots@tmpdir/\jobname/after.sh} + \iexec[\docshots@log,quiet]{rm -f \docshots@tmpdir/\jobname/after.sh} \IfFileExists{\docshots@tmpdir/\jobname/\hash.crop.pdf} {\message{docshots: on't pdfcrop, the PDF already exists (\docshots@tmpdir/\jobname/\hash.crop.pdf)^^J}} - {\iexec[log,quiet]{\docshots@pdfcrop\space + {\iexec[\docshots@log,quiet]{\docshots@pdfcrop\space --margins \docshots@margin\space \docshots@tmpdir/\jobname/\hash.pdf \docshots@tmpdir/\jobname/\hash.crop.pdf}}% \fvset{numbers=left,numbersep=3pt}% \fvset{frame=leftline,framerule=.4pt,rulecolor=\color{gray}}% - \fvset{samepage=true,baselinestretch=1}% + \fvset{samepage=true}% \fvset{baselinestretch=1}% \ifdefined\docshots@small% \fvset{fontsize=\small}% @@ -154,7 +162,14 @@ \hspace{\docshots@hspace}% \begin{minipage}[t]{\docshots@right}% \vspace{0pt}% - \VerbatimInput{\docshots@tmpdir/\jobname/\hash.tex}% + \ifdefined\docshots@lstinputlisting% + \lstinputlisting{\docshots@tmpdir/\jobname/\hash.tex}% + \else\ifdefined\docshots@inputminted% + \inputminted{\docshots@inputminted} + {\docshots@tmpdir/\jobname/\hash.tex}% + \else% + \VerbatimInput{\docshots@tmpdir/\jobname/\hash.tex}% + \fi\fi% \vspace{0pt}% \end{minipage}% \par% @@ -162,15 +177,16 @@ } \newcommand\docshotPrerequisite[1]{ - \iexec[log,quiet]{cp #1 \docshots@tmpdir/\jobname}% + \iexec[\docshots@log,quiet]{cp #1 \docshots@tmpdir/\jobname}% \message{docshots: file #1 copied to \docshots@tmpdir/\jobname/#1^^J}% } \newcommand\docshotAfter[1]{ - \iexec[log,quiet]{/bin/echo -n '\detokenize{#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}% + \message{docshots: file + \docshots@tmpdir/\jobname/after.sh created^^J}% } -- cgit v1.2.3