Skip to content

Commit

Permalink
added examples/test cases for new functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasWeise committed Aug 1, 2024
1 parent c797e17 commit 286905b
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 2 deletions.
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,20 @@ build_examples: extract python_dependencies
rm example_4.aux &&\
rm example_4.latexgit.dummy &&\
rm example_4.out &&\
pdflatex example_5.tex &&\
python3 -m latexgit.aux example_5 &&\
pdflatex example_5.tex &&\
rm example_5.log &&\
rm example_5.aux &&\
rm example_5.latexgit.dummy &&\
rm example_5.out &&\
pdflatex example_6.tex &&\
python3 -m latexgit.aux example_6 &&\
pdflatex example_6.tex &&\
rm example_6.log &&\
rm example_6.aux &&\
rm example_6.latexgit.dummy &&\
rm example_6.out &&\
rm latexgit.sty &&\
cd .. &&\
echo "$(NOW): Finished building the examples."
Expand Down
18 changes: 18 additions & 0 deletions examples/example_5.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
\documentclass{article}%
\usepackage{latexgit}% use our package
\usepackage{xcolor}% to be able to use colors
\usepackage[colorlinks]{hyperref}% for printing the URL
\usepackage{listings}% importing external code
\lstset{language={},basicstyle=\small\ttfamily,%
numbers=left,numberstyle=\tiny,frame=shadowbox,frameround=tttt,%
backgroundcolor=\color{black!10!yellow!5!white}}%
%
\begin{document}%
%
Check the output of a simple command in \autoref{lst:out}:
%
\gitExec{}{}{python3 --version}%
\lstinputlisting[float,label={lst:out},caption={%
The result of \texttt{python3 {-}{-} version}.}]{\gitFile}
%
\end{document}%
19 changes: 19 additions & 0 deletions examples/example_6.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
\documentclass{article}%
\usepackage{latexgit}% use our package
\usepackage{xcolor}% to be able to use colors
\usepackage[colorlinks]{hyperref}% for printing the URL
\usepackage{listings}% importing external code
\lstset{language={},basicstyle=\tiny,%
numbers=left,numberstyle=\tiny,frame=shadowbox,frameround=tttt,%
backgroundcolor=\color{black!10!yellow!5!white}}%
%
\begin{document}%
%
Check the output of a command executed inside a git
repository in \autoref{lst:out}:
%
\gitExec{https://github.com/thomasWeise/pycommons}{examples}{python3 temp.py}%
\lstinputlisting[float,label={lst:out},caption={%
The result of command executed inside a git repository.}]{\gitFile}
%
\end{document}%
63 changes: 61 additions & 2 deletions latexgit.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -842,8 +842,6 @@ backgroundcolor=\color{black!10!yellow!5!white}%
% (if the example code from \autoref{ex:example_4} was stored in a file called
% |example_4.tex|, that is.)
%
% \FloatBarrier%
%
% \begin{figure}%
% \centering%
% \strut\hfill\strut%
Expand All @@ -861,6 +859,65 @@ backgroundcolor=\color{black!10!yellow!5!white}%
% \label{ex:example_4:res}%
% \end{figure}%
%
% \FloatBarrier%
% \subsection{The Fifth Example: Capturing the Output of a Program}%
% \label{sec:example_5}%
% \FloatBarrier%
%
% \lstinputlisting[float,label=ex:example_5,caption={An example of capturing the output of a program, rendered as \autoref{ex:example_5:res}.}]{examples/example_5.tex}%
%
% The goal of the fifth example is to show that we can capture the output of
% a program.
% In \autoref{ex:example_5}, we just invoke |python3 --version| and capture
% the output in a file.
% We then load this file as listing.
% The results are shown in \autoref{ex:example_5:res}% and can be obtained via
% \begin{quote}
% |pdflatex example_5|\\
% |python3 -m latexgit.aux example_5|\\
% |pdflatex example_5|
% \end{quote}
% (if the example code from \autoref{ex:example_5} was stored in a file called
% |example_5.tex|, that is.)
%
% \begin{figure}%
% \centering%
% \fbox{\includegraphics[page=1,width=0.9\linewidth,trim=1.65in 7.9in 1.5in 1.8in,clip]{examples/example_5.pdf}}%
% \caption{The rendered result of \autoref{ex:example_5} (with trimmed page margins and bottoms).}%
% \label{ex:example_5:res}%
% \end{figure}%
%
%
% \FloatBarrier%
% \subsection{The Sixth Example: Capturing the Output of a Program Executed Inside a git Repository}%
% \label{sec:example_6}%
% \FloatBarrier%
%
% \lstinputlisting[float,label=ex:example_6,caption={An example of capturing the output of a program executed inside a git repository, rendered as \autoref{ex:example_6:res}.}]{examples/example_5.tex}%
%
% The goal of the fifth example is to show that we can capture the output of
% a program -- but this time we execute it inside a git repository.
% In \autoref{ex:example_6}, we invoke a program which is part of the examples
% suite of the \href{https://github.com/thomasWeise/pycommons}{pycommons}
% utility package.
% We capture its standard output in a file.
% We then load this file as listing.
% The results are shown in \autoref{ex:example_6:res}% and can be obtained via
% \begin{quote}
% |pdflatex example_6|\\
% |python3 -m latexgit.aux example_6|\\
% |pdflatex example_6|
% \end{quote}
% (if the example code from \autoref{ex:example_6} was stored in a file called
% |example_6.tex|, that is.)
%
% \begin{figure}%
% \centering%
% \fbox{\includegraphics[page=1,width=0.9\linewidth,trim=1.65in 7.5in 1.5in 1.8in,clip]{examples/example_6.pdf}}%
% \caption{The rendered result of \autoref{ex:example_6} (with trimmed page margins and bottoms).}%
% \label{ex:example_6:res}%
% \end{figure}%
%
% \afterpage{\clearpage}%
%
% \clearpage%
Expand Down Expand Up @@ -917,6 +974,8 @@ backgroundcolor=\color{black!10!yellow!5!white}%
%
% This command does nothing and is just a placeholder in the |aux| files.
\protected\gdef\@latexgit@gitFile#1#2#3{}%
% This command as well.
\protected\gdef\@latexgit@process#1#2#3{}%
% \end{macrocode}
%
% \begin{macro}{\gitLoad}
Expand Down

0 comments on commit 286905b

Please sign in to comment.