From 95f466967f2f2c50c3a0013a49df25892d06b263 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Wed, 26 Oct 2022 20:00:20 +0000 Subject: docshots (26oct22) git-svn-id: svn://tug.org/texlive/trunk@64820 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/latex/docshots/DEPENDS.txt | 5 +- Master/texmf-dist/doc/latex/docshots/README.md | 2 + Master/texmf-dist/doc/latex/docshots/docshots.pdf | Bin 335433 -> 338306 bytes .../texmf-dist/source/latex/docshots/docshots.dtx | 137 +++++++++++++-------- Master/texmf-dist/tex/latex/docshots/docshots.sty | 101 +++++++++------ 5 files changed, 154 insertions(+), 91 deletions(-) (limited to 'Master') diff --git a/Master/texmf-dist/doc/latex/docshots/DEPENDS.txt b/Master/texmf-dist/doc/latex/docshots/DEPENDS.txt index 93a73e061e6..42b2d30ead9 100644 --- a/Master/texmf-dist/doc/latex/docshots/DEPENDS.txt +++ b/Master/texmf-dist/doc/latex/docshots/DEPENDS.txt @@ -4,4 +4,7 @@ hard pdfcrop hard pgf hard pgfopts hard listings -hard minted \ No newline at end of file +hard minted +hard pdftexcmds +hard ifluatex +hard ifxetex diff --git a/Master/texmf-dist/doc/latex/docshots/README.md b/Master/texmf-dist/doc/latex/docshots/README.md index ff64e5ba6ed..17a6693a35f 100644 --- a/Master/texmf-dist/doc/latex/docshots/README.md +++ b/Master/texmf-dist/doc/latex/docshots/README.md @@ -28,6 +28,8 @@ For more informaiton, read \TeX{} Book by Donald Knuth. \end{document} ``` +Otherwise, you can download [`docshots.sty`](https://raw.githubusercontent.com/objectionary/eolang.sty/gh-pages/docshots/docshots.sty) and add to your project. + If you want to contribute yourself, make a fork, then create a branch, then run `l3build ctan` in the root directory. It should compile everything without errors. If not, submit an issue and wait. diff --git a/Master/texmf-dist/doc/latex/docshots/docshots.pdf b/Master/texmf-dist/doc/latex/docshots/docshots.pdf index 888639741de..9d94d44dee0 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 2e6d03614c2..0a559d7edf8 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-25 0.0.5 TeX Samples Next to Their PDF Snapshots in DTX] +[2022-10-26 0.2.0 TeX Samples Next to Their PDF Snapshots in DTX] % %<*driver> \documentclass{ltxdoc} @@ -128,13 +128,9 @@ % \begin{docshot} % \documentclass{article} % \usepackage{tikz} -% \usetikzlibrary{backgrounds} % \pagestyle{empty} % \begin{document} -% \begin{tikzpicture}[ -% show background rectangle, -% background rectangle/.style= -% {draw=none,fill=gray!20}] +% \begin{tikzpicture} % \node [circle,draw] (v0) {$v_0$}; % \node [circle,draw=orange,thick, % below right of=v0] (v1) {$v_1$}; @@ -155,17 +151,18 @@ % When you render a text instead of a single picture, it's recommended to use % \href{https://ctan.org/pkg/geometry}{geometry} package to change the size -% of the page and then |empty| page style to remove page numbering: +% of the page: % \begin{docshot} % \documentclass{article} -% \usepackage[paperwidth=2in]{geometry} -% \pagestyle{empty} +% \usepackage[paperwidth=2in, +% paperheight=2.2in]{geometry} % \begin{document} % ``There is no sadder thing than % a young pessimist, except an old % pessimist'' --- \emph{Mark Twain} % \end{document} % \end{docshot} +% You can also use |\pagestyle{empty}| as was done in previous docshots. % \section{Package Options} @@ -230,6 +227,18 @@ Hello, world! % %\fi +% \DescribeMacro{nocrop} +% You may disable cropping with the help of |nocrop| option: +%\iffalse +%<*verb> +%\fi +\begin{verbatim} +\usepackage[nocrop]{docshot} +\end{verbatim} +%\iffalse +% +%\fi + % \DescribeMacro{hspace} % The horizontal distance between the image and its verbatim \TeX{} source % may be configured via |hspace| package option: @@ -271,7 +280,7 @@ Hello, world! %\fi % \DescribeMacro{tmpdir} -% The default location of temp files is |\docshots@tmpdir|. You can change this using |tmpdir| option: +% The default location of temp files is |_docshots|. You can change this using |tmpdir| option: %\iffalse %<*verb> %\fi @@ -448,17 +457,21 @@ Hello, world! % Then, we process package options: % \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.} % \begin{macrocode} \RequirePackage{pgfopts} +\RequirePackage{ifluatex} +\RequirePackage{ifxetex} \def\docshots@log{} \pgfkeys{ /docshots/.cd, dtx/.store in=\docshots@dtx, log/.code=\def\docshots@log{log}, + nocrop/.code=\def\docshots@nocrop{}, lstinputlisting/.store in=\docshots@lstinputlisting, inputminted/.store in=\docshots@inputminted, tmpdir/.store in=\docshots@tmpdir, - tmpdir/.default=_docshots, + tmpdir/.default=_docshots\ifxetex-xe\else\ifluatex-lua\fi\fi, small/.store in=\docshots@small, tiny/.store in=\docshots@tiny, runs/.store in=\docshots@runs, @@ -484,28 +497,39 @@ Hello, world! % Then, we print the version of |pdflatex| to \TeX{} log: % \begin{macrocode} -\iexec[\docshots@log,quiet]{\docshots@pdflatex\space --version}% +\iexec[\docshots@log,quiet]{"\docshots@pdflatex" --version}% % \end{macrocode} % Then, we print the version of \href{https://ctan.org/pkg/pdfcrop}{pdfcrop} to \TeX{} log: % \begin{macrocode} -\iexec[\docshots@log,quiet]{\docshots@pdfcrop\space --version}% +\ifdefined\docshots@nocrop\else% + \iexec[\docshots@log,quiet]{"\docshots@pdfcrop" --version}% +\fi% % \end{macrocode} % Then, we print the version of |ghostscript| to \TeX{} log: % \begin{macrocode} -\iexec[\docshots@log,quiet]{\docshots@gs\space --version}% +\iexec[\docshots@log,quiet]{"\docshots@gs" --version}% % \end{macrocode} % Then, we make a directory where all temporary files will be kept: % \begin{macrocode} -\iexec[null]{mkdir -p \docshots@tmpdir/\jobname}% +\iexec[null]{mkdir -p "\docshots@tmpdir/\jobname"}% +% \end{macrocode} + +% \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: +% \begin{macrocode} +\RequirePackage{pdftexcmds} +\makeatletter\newcommand\docshots@mdfive[1]{\pdf@filemdfivesum{#1}}\makeatother % \end{macrocode} +% \end{macro} % \begin{macro}{docshot} % Then, we define |docshot| environment: % \begin{macrocode} -\newenvironment{docshot} +\makeatletter\newenvironment{docshot} {\VerbatimEnvironment\begin{VerbatimOut} {\docshots@tmpdir/\jobname/verbatim.tex}} {\end{VerbatimOut}% @@ -519,52 +543,64 @@ 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{\docshots@mdfive{\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|: +% \changes{0.1.0}{2022/10/26}{The output is saved to a hash-named file, for better uniqueness of temporary files.} % \begin{macrocode} \IfFileExists{\docshots@tmpdir/\jobname/\hash.pdf} - {\message{docshots: won't render, the PDF already exists - (\docshots@tmpdir/\jobname/\hash.pdf)^^J}} - {\iexec[\docshots@log,quiet]{cp \docshots@tmpdir/\jobname/verbatim.tex - \docshots@tmpdir/\jobname/\hash.tex}% - \foreach \n in {1,...,\docshots@runs}{ - \iexec[\docshots@log,quiet]{cd \docshots@tmpdir/\jobname; - \docshots@pdflatex\space + {\message{docshots: Won't render, + the PDF '\docshots@tmpdir/\jobname/\hash.pdf' already exists^^J}} + {\iexec[\docshots@log,quiet]{cp "\docshots@tmpdir/\jobname/verbatim.tex" + "\docshots@tmpdir/\jobname/\hash.tex"}% + \foreach \n in {1,...,\docshots@runs}{% + \iexec[\docshots@log, + stdout=\docshots@tmpdir/\jobname/\hash.stdout, + exit=\docshots@tmpdir/\jobname/\hash.ret, + quiet,trace]{cd "\docshots@tmpdir/\jobname" && + "\docshots@pdflatex" -interaction=errorstopmode -halt-on-error -shell-escape - \hash.tex} - \message{docshots: pdflatex run no.\n^^J} + \hash.tex}% + \ifnum\n=1\else% + \message{docshots: pdflatex run no.\n^^J}% + \fi% \IfFileExists{\docshots@tmpdir/\jobname/after.sh} {\iexec[\docshots@log,quiet]{chmod a+x - \docshots@tmpdir/\jobname/after.sh} - \iexec[\docshots@log,quiet]{cd \docshots@tmpdir/\jobname; + "\docshots@tmpdir/\jobname/after.sh"} + \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[\docshots@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: % \begin{macrocode} \IfFileExists{\docshots@tmpdir/\jobname/\hash.crop.pdf} - {\message{docshots: won't pdfcrop, the PDF already exists - (\docshots@tmpdir/\jobname/\hash.crop.pdf)^^J}} - {\iexec[\docshots@log,quiet]{\docshots@pdfcrop\space - --margins \docshots@margin\space - \docshots@tmpdir/\jobname/\hash.pdf - \docshots@tmpdir/\jobname/\hash.crop.pdf}}% + {\message{docshots: Won't pdfcrop, + the PDF '\docshots@tmpdir/\jobname/\hash.crop.pdf' + already exists^^J}} + {\ifdefined\docshots@nocrop + \iexec[\docshots@log,quiet]{cp + "\docshots@tmpdir/\jobname/\hash.pdf" + "\docshots@tmpdir/\jobname/\hash.crop.pdf"}% + \else% + \iexec[\docshots@log,quiet]{"\docshots@pdfcrop" + --margins 0 + "\docshots@tmpdir/\jobname/\hash.pdf" + "\docshots@tmpdir/\jobname/\hash.crop.pdf"}% + \fi}% % \end{macrocode} % We configure |fancyvrb|: % \begin{macrocode} \fvset{numbers=left,numbersep=3pt}% - \fvset{frame=leftline,framerule=.4pt,rulecolor=\color{gray}}% + \fvset{frame=leftline,framerule=.2pt,rulecolor=\color{gray}}% \fvset{samepage=true}% \fvset{baselinestretch=1}% \ifdefined\docshots@small% @@ -574,12 +610,13 @@ Hello, world! \fvset{fontsize=\scriptsize}% \fi% % \end{macrocode} -% We render the two column content: +% Finally, we render the two-column content: % \begin{macrocode} \begingroup% \par% \tikz[baseline=(a.north)] - \node (a) [draw=gray,inner sep=0] + \node (a) [draw=gray,inner sep=\docshots@margin, + line width=.2pt] {\includegraphics[width=\docshots@left] {\docshots@tmpdir/\jobname/\hash.crop.pdf}};% \hspace{\docshots@hspace}% @@ -597,30 +634,30 @@ Hello, world! \end{minipage}% \par% \endgroup% -} +}\makeatother % \end{macrocode} % \end{macro} % \begin{macro}{\docshotPrerequisite} % Then, we define |\docshotPrerequisite| command: % \begin{macrocode} -\newcommand\docshotPrerequisite[1]{ - \iexec[\docshots@log,quiet]{cp #1 \docshots@tmpdir/\jobname}% - \message{docshots: file #1 copied to - \docshots@tmpdir/\jobname/#1^^J}% -} +\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 % \end{macrocode} % \end{macro} % \begin{macro}{\docshotAfter} % Finally, we define |\docshotAfter| command: % \begin{macrocode} -\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}% -} + > "\docshots@tmpdir/\jobname/after.sh"}% + \message{docshots: File + '\docshots@tmpdir/\jobname/after.sh' created^^J}% +}\makeatother % \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 10016c493da..56f47c48ec3 100644 --- a/Master/texmf-dist/tex/latex/docshots/docshots.sty +++ b/Master/texmf-dist/tex/latex/docshots/docshots.sty @@ -31,7 +31,8 @@ \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{docshots} -[2022-10-25 0.0.5 TeX Samples Next to Their PDF Snapshots in DTX] +[2022-10-26 0.2.0 TeX Samples Next to Their PDF Snapshots in DTX] + @@ -65,15 +66,18 @@ \RequirePackage{tikz} \RequirePackage{pgfopts} +\RequirePackage{ifluatex} +\RequirePackage{ifxetex} \def\docshots@log{} \pgfkeys{ /docshots/.cd, dtx/.store in=\docshots@dtx, log/.code=\def\docshots@log{log}, + nocrop/.code=\def\docshots@nocrop{}, lstinputlisting/.store in=\docshots@lstinputlisting, inputminted/.store in=\docshots@inputminted, tmpdir/.store in=\docshots@tmpdir, - tmpdir/.default=_docshots, + tmpdir/.default=_docshots\ifxetex-xe\else\ifluatex-lua\fi\fi, small/.store in=\docshots@small, tiny/.store in=\docshots@tiny, runs/.store in=\docshots@runs, @@ -96,15 +100,20 @@ } \ProcessPgfOptions{/docshots} -\iexec[\docshots@log,quiet]{\docshots@pdflatex\space --version}% +\iexec[\docshots@log,quiet]{"\docshots@pdflatex" --version}% + +\ifdefined\docshots@nocrop\else% + \iexec[\docshots@log,quiet]{"\docshots@pdfcrop" --version}% +\fi% -\iexec[\docshots@log,quiet]{\docshots@pdfcrop\space --version}% +\iexec[\docshots@log,quiet]{"\docshots@gs" --version}% -\iexec[\docshots@log,quiet]{\docshots@gs\space --version}% +\iexec[null]{mkdir -p "\docshots@tmpdir/\jobname"}% -\iexec[null]{mkdir -p \docshots@tmpdir/\jobname}% +\RequirePackage{pdftexcmds} +\makeatletter\newcommand\docshots@mdfive[1]{\pdf@filemdfivesum{#1}}\makeatother -\newenvironment{docshot} +\makeatletter\newenvironment{docshot} {\VerbatimEnvironment\begin{VerbatimOut} {\docshots@tmpdir/\jobname/verbatim.tex}} {\end{VerbatimOut}% @@ -112,37 +121,48 @@ \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{\docshots@mdfive{\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[\docshots@log,quiet]{cp \docshots@tmpdir/\jobname/verbatim.tex - \docshots@tmpdir/\jobname/\hash.tex}% - \foreach \n in {1,...,\docshots@runs}{ - \iexec[\docshots@log,quiet]{cd \docshots@tmpdir/\jobname; - \docshots@pdflatex\space + {\message{docshots: Won't render, + the PDF '\docshots@tmpdir/\jobname/\hash.pdf' already exists^^J}} + {\iexec[\docshots@log,quiet]{cp "\docshots@tmpdir/\jobname/verbatim.tex" + "\docshots@tmpdir/\jobname/\hash.tex"}% + \foreach \n in {1,...,\docshots@runs}{% + \iexec[\docshots@log, + stdout=\docshots@tmpdir/\jobname/\hash.stdout, + exit=\docshots@tmpdir/\jobname/\hash.ret, + quiet,trace]{cd "\docshots@tmpdir/\jobname" && + "\docshots@pdflatex" -interaction=errorstopmode -halt-on-error -shell-escape - \hash.tex} - \message{docshots: pdflatex run no.\n^^J} + \hash.tex}% + \ifnum\n=1\else% + \message{docshots: pdflatex run no.\n^^J}% + \fi% \IfFileExists{\docshots@tmpdir/\jobname/after.sh} {\iexec[\docshots@log,quiet]{chmod a+x - \docshots@tmpdir/\jobname/after.sh} - \iexec[\docshots@log,quiet]{cd \docshots@tmpdir/\jobname; + "\docshots@tmpdir/\jobname/after.sh"} + \iexec[\docshots@log,quiet]{cd "\docshots@tmpdir/\jobname" && ./after.sh \n\space \hash\space \hash.tex}} {}}}% - \iexec[\docshots@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: won't pdfcrop, the PDF already exists - (\docshots@tmpdir/\jobname/\hash.crop.pdf)^^J}} - {\iexec[\docshots@log,quiet]{\docshots@pdfcrop\space - --margins \docshots@margin\space - \docshots@tmpdir/\jobname/\hash.pdf - \docshots@tmpdir/\jobname/\hash.crop.pdf}}% + {\message{docshots: Won't pdfcrop, + the PDF '\docshots@tmpdir/\jobname/\hash.crop.pdf' + already exists^^J}} + {\ifdefined\docshots@nocrop + \iexec[\docshots@log,quiet]{cp + "\docshots@tmpdir/\jobname/\hash.pdf" + "\docshots@tmpdir/\jobname/\hash.crop.pdf"}% + \else% + \iexec[\docshots@log,quiet]{"\docshots@pdfcrop" + --margins 0 + "\docshots@tmpdir/\jobname/\hash.pdf" + "\docshots@tmpdir/\jobname/\hash.crop.pdf"}% + \fi}% \fvset{numbers=left,numbersep=3pt}% - \fvset{frame=leftline,framerule=.4pt,rulecolor=\color{gray}}% + \fvset{frame=leftline,framerule=.2pt,rulecolor=\color{gray}}% \fvset{samepage=true}% \fvset{baselinestretch=1}% \ifdefined\docshots@small% @@ -154,7 +174,8 @@ \begingroup% \par% \tikz[baseline=(a.north)] - \node (a) [draw=gray,inner sep=0] + \node (a) [draw=gray,inner sep=\docshots@margin, + line width=.2pt] {\includegraphics[width=\docshots@left] {\docshots@tmpdir/\jobname/\hash.crop.pdf}};% \hspace{\docshots@hspace}% @@ -172,20 +193,20 @@ \end{minipage}% \par% \endgroup% -} +}\makeatother -\newcommand\docshotPrerequisite[1]{ - \iexec[\docshots@log,quiet]{cp #1 \docshots@tmpdir/\jobname}% - \message{docshots: file #1 copied to - \docshots@tmpdir/\jobname/#1^^J}% -} +\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 -\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}% -} + > "\docshots@tmpdir/\jobname/after.sh"}% + \message{docshots: File + '\docshots@tmpdir/\jobname/after.sh' created^^J}% +}\makeatother -- cgit v1.2.3