4

I am building a project with l3build. There are some examples I want to present in the documentation, showing their source code, annotated with DocStrip, as well as including the output they produce using \includegraphics to pull in the PDF generated from the extracted example source code. It all looks roughly like this:

  • examples.dtx:

    %    \begin{macrocode}
    \documentclass[a8paper]{scrartcl}
    \begin{document}
    %<*italic>
    %    \end{macrocode}
    % Here is some italic text.
    %    \begin{macrocode}
    \textit{Lorem ipsum}
    %    \end{macrocode}
    %    \begin{macrocode}
    %</italic>
    %<*bold>
    %    \end{macrocode}
    % And here is some bold text.
    %    \begin{macrocode}
    \textbf{Lorem ipsum}
    %</bold>
    %    \end{macrocode}
    % That is all.
    %    \begin{macrocode}
    \end{document}
    %    \end{macrocode}
    
  • examples.ins:

    \input docstrip.tex
    \generate{\file{italic.tex}{\from{examples.dtx}{italic}}}
    \generate{\file{bold.tex}{\from{examples.dtx}{bold}}}
    \endbatchfile
    
  • documentation.drv:

    \documentclass{ltxdoc}
    \usepackage{graphicx}
    \begin{document}
    Let me present some examples.
    \DocInput{examples.dtx}
    This is how the examples look when compiled. \\
    \includegraphics{italic.pdf} \\
    \includegraphics{bold.pdf}
    \end{document}
    
  • build.lua:

    #!/usr/bin/env texlua
    -- build.lua - not working
    module = "example"
    typesetfiles = {"documentation.drv"}
    kpse.set_program_name("kpsewhich")
    dofile(kpse.lookup("l3build.lua"))
    
  • shell commands to do what build.lua is intended to do (typeset.sh):

    tex *.ins
    for doc in *.tex
    do
      pdflatex "$doc"
    done
    pdflatex *.drv
    

I placed these files on GitHub for you to quickly download and test them.

I even thought of rather drastic measures like redefining the typeset function in terms of arara. But I cannot seem to configure l3build to compile the documentation correctly. The examples do not need to be distributed in any TDS or *.zip, but they have to be unpacked and compiled before typesetting the documentation. Can this be done with l3build?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.