summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/docshots/docshots.dtx
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2022-10-18 20:50:19 +0000
committerKarl Berry <karl@freefriends.org>2022-10-18 20:50:19 +0000
commit9a041b7d9e060400f05af5cec995772c8939f9ba (patch)
treeb73eab76e9bfb6e0e8316797395c8a71e3c6f18d /Master/texmf-dist/source/latex/docshots/docshots.dtx
parentee8f0db3107cad52d5004f3f36c48cf66d82570d (diff)
docshots (17oct22)
git-svn-id: svn://tug.org/texlive/trunk@64739 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/docshots/docshots.dtx')
-rw-r--r--Master/texmf-dist/source/latex/docshots/docshots.dtx93
1 files changed, 76 insertions, 17 deletions
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 @@
%<package>\NeedsTeXFormat{LaTeX2e}
%<package>\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]
%</package>
%<*driver>
\documentclass{ltxdoc}
@@ -306,6 +306,52 @@ Hello, world!
%</verb>
%\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
+%</verb>
+%\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
+%</verb>
+%\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
+%</verb>
+%\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}