\documentclass{ltxdoc}
\usepackage{tikz,fancyvrb,geometry,minted,fontspec}
\usepackage[ngerman]{babel}
\usetikzlibrary{positioning}
\geometry{a4paper,margin=2cm}
\setmainfont[
	Renderer=HarfBuzz,
	ItalicFont=Recursive,
	BoldFont=Recursive,
	BoldItalicFont=Recursive,
	Scale=0.9,
	UprightFeatures={
		RawFeature={+ss01,+ss02,+ss08,+case},
		RawFeature={+axis={MONO=0.0,CASL=0.2,slnt=0,CRSV=0,wght=400}}
	},
	BoldFeatures={RawFeature={+axis={MONO=0.0,CASL=0.2,slnt=0,CRSV=0,wght=700}}},
	BoldItalicFeatures={RawFeature={+axis={MONO=0.0,CASL=0.2,slnt=-15,CRSV=1,wght=700}}},
	ItalicFeatures={RawFeature={+axis={MONO=0.0,CASL=0.2,slnt=-15,CRSV=1,wght=400}}}
	]{Recursive}
\setmonofont[
	Renderer=HarfBuzz,
	ItalicFont=Recursive,
	BoldFont=Recursive,
	BoldItalicFont=Recursive,
	Scale=0.9,
	UprightFeatures={
		RawFeature={+ss01,+ss02,+ss08,+case},
		RawFeature={+axis={MONO=1.0,CASL=0.2,slnt=0,CRSV=0,wght=400}}
	},
	BoldFeatures={RawFeature={+axis={MONO=1.0,CASL=0.2,slnt=0,CRSV=0,wght=700}}},
	BoldItalicFeatures={RawFeature={+axis={MONO=1.0,CASL=0.2,slnt=-15,CRSV=1,wght=700}}},
	ItalicFeatures={RawFeature={+axis={MONO=1.0,CASL=0.2,slnt=-15,CRSV=1,wght=400}}}
	]{Recursive}
\newfontfamily\titlefont[
	Renderer=HarfBuzz,
	ItalicFont=Recursive,
	BoldFont=Recursive,
	BoldItalicFont=Recursive,
	Scale=0.9,
	UprightFeatures={
		RawFeature={+ss01,+ss02,+ss08,+case},
		RawFeature={+axis={MONO=0.0,CASL=0.4,slnt=0,CRSV=1,wght=500}}
	},
	BoldFeatures={RawFeature={+axis={MONO=0.0,CASL=0.4,slnt=0,CRSV=1,wght=800}}},
	BoldItalicFeatures={RawFeature={+axis={MONO=0.0,CASL=0.4,slnt=-15,CRSV=1,wght=800}}},
	ItalicFeatures={RawFeature={+axis={MONO=0.0,CASL=0.4,slnt=-15,CRSV=1,wght=500}}}
	]{Recursive}

\directlua{ os.execute "mkdir -p cccbform-examples" }
\directlua{ os.execute "cp cccbform.cls cccbform-examples/" }
\directlua{ os.execute "cp logo.pdf cccbform-examples/" }

\NewDocumentCommand{\LineCount}{m}{\directlua{
	local n, f = 0, io.open("cccbform-examples/#1.tex")
	for l in f:lines() do  n = n + 1  end
	tex.print( n - 1 )
}}

\NewDocumentEnvironment{ShortExample}{m}{
	\VerbatimEnvironment
	\begin{VerbatimOut}{cccbform-examples/#1.tex}[]
	\documentclass[shortexample]{cccbform}
	\begin{document}}{
	\end{document}
	\end{VerbatimOut}
	\directlua{ os.execute "cd cccbform-examples ; latexmk -pdflua #1.tex" }
	\edef\lc{\LineCount{#1}}
	\begin{tikzpicture}
		\node[anchor=north west, inner sep=1ex, draw] (code) {
			\begin{minipage}[t]{0.45\textwidth}
				\inputminted[firstline=3,lastline=\lc]{tex}{cccbform-examples/#1.tex}
			\end{minipage}
		};
		\node[anchor=north west, right=2mm of code, draw] (output) {
			\begin{minipage}[t]{0.45\textwidth}
				\includegraphics[width=\linewidth]{cccbform-examples/#1.pdf}
			\end{minipage}
		};
	\end{tikzpicture}
}
\NewDocumentEnvironment{StandaloneExample}{m}{
	\VerbatimEnvironment%
	\begin{VerbatimOut}{cccbform-examples/#1.tex}}%
	{\end{VerbatimOut}%
	\directlua{ os.execute "cd cccbform-examples ; latexmk -pdflua #1.tex" }
	\edef\lc{\LineCount{#1}}
	\begin{tikzpicture}
		\node[anchor=north west, inner sep=1ex, draw] (code) {
			\begin{minipage}[t]{0.45\textwidth}
				\inputminted[firstline=3,lastline=\lc]{tex}{cccbform-examples/#1.tex}
			\end{minipage}
		};
		\node[anchor=north west, right=2mm of code, draw] (output) {
			\begin{minipage}[t]{0.45\textwidth}
				\includegraphics[width=\linewidth]{cccbform-examples/#1.pdf}
			\end{minipage}
		};
	\end{tikzpicture}
}

\title{\texttt{cccbform} -- Formulare für den CCCB}
\author{Frank Nord}
\begin{document}
\maketitle
\tableofcontents

\section{Übersicht}

\begin{ShortExample}{test}
\Text{Test}
\end{ShortExample}

\end{document}
