%% Code Listing Template
%% Auto-generated by ggen from RDF ontology
%% Uses listings package

{% raw %}{% if is_inline %}
\lstinline[language={{ language }}]|{{ code }}|
{% else %}
\begin{lstlisting}[
  language={{ language }},
  caption={{ caption }},
  label=lst:{{ listing_id }},
  {% if line_numbers %}numbers=left,{% endif %}
  {% if start_line %}firstnumber={{ start_line }},{% endif %}
  {% if highlight_lines %}escapeinside={(*@}{@*)},{% endif %}
  style={{ style | default(value="default") }},
  frame={{ frame | default(value="single") }},
  breaklines=true,
  basicstyle=\ttfamily\footnotesize,
  commentstyle=\color{gray}\itshape,
  keywordstyle=\color{blue}\bfseries,
  stringstyle=\color{red},
  showstringspaces=false,
  tabsize={{ tab_size | default(value="4") }}
]
{% if highlight_lines %}
{% for line in code_lines %}
{% if line.number in highlight_lines %}(*@\hl{@*){{ line.content }}(*@}@*){% else %}{{ line.content }}{% endif %}
{% endfor %}
{% else %}
{{ code }}
{% endif %}
\end{lstlisting}
{% endif %}{% endraw %}

{% raw %}{% if description %}
\noindent {{ description }}
{% endif %}{% endraw %}

{% raw %}{% if file_path %}
\noindent \textbf{File:} \texttt{{{ file_path }}}
{% endif %}{% endraw %}

{% raw %}{% if github_url %}
\noindent \textbf{Source:} \url{{{ github_url }}}
{% endif %}{% endraw %}

{% raw %}{% if related_listings %}
\noindent \textbf{See also:}
{% for related in related_listings %}
\cref{lst:{{ related.id }}}{% if not loop.last %}, {% endif %}
{% endfor %}
{% endif %}{% endraw %}

{% raw %}{% if annotations %}
\noindent \textbf{Notes:}
\begin{itemize}
{% for annotation in annotations %}
\item Line {{ annotation.line_number }}: {{ annotation.text }}
{% endfor %}
\end{itemize}
{% endif %}{% endraw %}
