%%
%% This is file `ydoc-expl.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% ydoc.dtx  (with options: `ydoc-expl.sty')
%% 
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{ydoc-expl}[%
    2022/10/26
    v0.7alpha
    ydoc package to insert live examples of LaTeX code]
\RequirePackage{listings}
\lst@RequireAspects{writefile}
\def\ydoc@exafile{\jobname.exa}
\lstdefinestyle{examplecode}{%
    language=[latex]tex,
    basicstyle=\ttfamily,
    columns=fullflexible,
    numbers=left,
    firstnumber=1,
    numberstyle=\tiny\color{gray}\sffamily,
    numbersep=5pt,
    breaklines,prebreak={\mbox{\tiny$\swarrow$}},
    commentstyle=\color{black!60},
}%
\lstdefinestyle{exampleresult}{%
    firstnumber=1,
    gobble=0,
    basicstyle=\ttfamily,
    columns=fullflexible,
    commentstyle=\color{black!60},
}
\lstdefinestyle{exampleextract}{gobble=4}%
\newbox\examplecodebox
\newbox\exampleresultbox
\def\BoxExample{%
  \setbox\examplecodebox\hbox{\color@setgroup
    \lstinputlisting[style=examplecode,style=thisexampleprint]%
    {\ydoc@exafile}%
  \unskip\color@endgroup}%
  \setbox\exampleresultbox\hbox{\color@setgroup
    \lstset{style=exampleresult}%
    \@@input\ydoc@exafile\relax
  \unskip\color@endgroup}%
}
\def\PrintExample{%
  \begingroup
  \BoxExample
  \@tempdima=\textwidth
  \advance\@tempdima by -\wd\examplecodebox\relax
  \advance\@tempdima by -\wd\exampleresultbox\relax
  \advance\@tempdima by -15pt\relax
  \ifdim\@tempdima>\bigskipamount
    \hbox to \textwidth{%
     \null\hss
     \minipage[c]{\wd\exampleresultbox}\fbox{\usebox\exampleresultbox}\endminipage
     \hfill\hfill\hskip\bigskipamount\hskip15pt\hfill\hfill
     \minipage[c]{\wd\examplecodebox}\usebox\examplecodebox\endminipage
     \hss\null
     }%
  \else
    \vbox{%
        \centerline{\fbox{\usebox\exampleresultbox}}%
        \vspace{\bigskipamount}%
        \centerline{\usebox\examplecodebox}%
    }%
  \fi
  \endgroup
}
\lstnewenvironment{examplecode}[1][]{%
  \lstdefinestyle{thisexampleprint}{#1}%
  \setbox\@tempboxa\hbox\bgroup
  \lstset{style=exampleextract,#1}%
  \lst@BeginWriteFile{\ydoc@exafile}%
}
{%
  \lst@EndWriteFile
  \egroup
  \begingroup
  \MakePercentComment
  \catcode`\^^M=5\relax
  \PrintExample
  \endgroup
}
\RequirePackage{float}
\floatstyle{plain}
\newfloat{example}{tbhp}{loe}
\floatname{example}{\examplename}
\def\examplename{Example}
\newenvironment{exampletable}{%
  \floatstyle{plaintop}%
  \restylefloat{example}%
  \example
}{\endexample}
\endinput
%%
%% End of file `ydoc-expl.sty'.
