From 458ae81ef20dbea77877876c44a0de359afd55de Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sat, 5 Sep 2015 22:16:03 +0000 Subject: checklistings (3sep15) git-svn-id: svn://tug.org/texlive/trunk@38300 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/latex/checklistings/Makefile | 42 +++++ .../texmf-dist/doc/latex/checklistings/README.md | 56 ++++++ .../doc/latex/checklistings/checklistings.hva | 188 +++++++++++++++++++++ .../doc/latex/checklistings/checklistings.pdf | Bin 0 -> 286631 bytes .../doc/latex/checklistings/example.html | 74 ++++++++ .../texmf-dist/doc/latex/checklistings/example.pdf | Bin 0 -> 73949 bytes .../texmf-dist/doc/latex/checklistings/example.tex | 56 ++++++ 7 files changed, 416 insertions(+) create mode 100644 Master/texmf-dist/doc/latex/checklistings/Makefile create mode 100644 Master/texmf-dist/doc/latex/checklistings/README.md create mode 100644 Master/texmf-dist/doc/latex/checklistings/checklistings.hva create mode 100644 Master/texmf-dist/doc/latex/checklistings/checklistings.pdf create mode 100644 Master/texmf-dist/doc/latex/checklistings/example.html create mode 100644 Master/texmf-dist/doc/latex/checklistings/example.pdf create mode 100644 Master/texmf-dist/doc/latex/checklistings/example.tex (limited to 'Master/texmf-dist/doc/latex/checklistings') diff --git a/Master/texmf-dist/doc/latex/checklistings/Makefile b/Master/texmf-dist/doc/latex/checklistings/Makefile new file mode 100644 index 00000000000..15126e2aba6 --- /dev/null +++ b/Master/texmf-dist/doc/latex/checklistings/Makefile @@ -0,0 +1,42 @@ + +all: checklistings.sty checklistings.pdf + +checklistings.pdf: checklistings.dtx checklistings.ind checklistings.sty \ + checklistings.chkl + ./checklistings.sh checklistings.chkl + pdflatex $< + pdflatex $< + +checklistings.ind: checklistings.idx + makeindex -s gind.ist -o $@ $< + +checklistings.idx checklistings.chkl: checklistings.dtx + pdflatex $< + +checklistings.sty: checklistings.dtx + latex checklistings.ins + +example.pdf: example.tex example.chkl checklistings.sty + ./checklistings.sh example.chkl + pdflatex $< + pdflatex $< + +example.html: example.tex example.chkl checklistings.hva + ./checklistings.sh example.chkl + hevea -fix example + +example.chkl: example.tex + pdflatex $< + +clean: + -@rm -rf chklisting0*.tex chklisting0*.ml Withopen* + -@rm -rf chklisting0*.msg chklisting0*.err + -@rm -rf checklistings.aux checklistings.glo checklistings.idx + -@rm -rf checklistings.ilg checklistings.ind checklistings.log + -@rm -rf checklistings.chkl checklistings.tmp + -@rm -rf checklistings.hd checklistings.out + -@rm -rf example0*.tex example0*.ml + -@rm -rf example0*.msg example0*.err example0*.html + -@rm -rf example.aux example.log + -@rm -rf example.chkl example.tmp + diff --git a/Master/texmf-dist/doc/latex/checklistings/README.md b/Master/texmf-dist/doc/latex/checklistings/README.md new file mode 100644 index 00000000000..70f6c7fcabe --- /dev/null +++ b/Master/texmf-dist/doc/latex/checklistings/README.md @@ -0,0 +1,56 @@ +checklistings +============= + +By [Timothy Bourke](http://www.tbrk.org) +and [Marc Pouzet](http://www.di.ens.fr/~pouzet). + +User manuals and papers about programming languages usually contain many +code samples, often with accompanying compiler messages giving the types +of declarations or error messages explaining why certain declarations are +invalid. + +The `checklistings` package augments the +[fancyvrb](http://www.ctan.org/pkg/fancyvrb) and +[listings](http://www.ctan.org/pkg/listings) packages for including source +code in LaTeX documents with a way to pass the source code through a +compiler and also include the resulting messages in the document. + +The motivation is to check the code samples in a document for syntax and +typing errors and to facilitate the inclusion of inferred types and compiler +warnings or errors in a text. This package is intentionally very lightweight +and unlike packages like [python](http://www.ctan.org/pkg/python) it is not +intended for interacting with an interpretor or including the execution +traces of code. While `checklistings` does not focus on a specific +programming language, it is designed to work well with ML-like languages. + +Using the package involves three elements: + +1. The declaration `\usepackage{checklistings}`. +2. The verbatim environment `\begin{chklisting}...\end{chklisting}`. +3. The shell script `checklistings.sh`. + +In a first pass, `latex`/`pdflatex` outputs code samples into files. +The second pass is performed by `checklistings.sh` which passes each file +through a compiler to generate corresponding output files. +In a third pass, `latex`/`pdflatex` reads from the generated files to +incorporate the results into the document. + +A `checklistings.hva` file is provided for interoperability with +[HeVeA](http://hevea.inria.fr). + +The `checklistings` package may be distributed and/or modified under the +conditions of the +[LaTeX Project Public License](http://www.latex-project.org/lppl.txt), +either version 1.2 of this license or (at your option) any later version. + +Please send comments, suggestions, and bug reports (with version number and +the keyword "checklistings" in the subject of the message) to +. Please keep in mind that we prefer to keep `checklistings` +simple and lightweight rather than to incorporate many different +configuration and customization options. The source code is hosted on +[GitHub](https://github.com/tbrk/checklistings). + +This package was developed within the +[PARKAS](http://www.di.ens.fr/ParkasTeam.html) at +[Inria](http://www.inria.fr) and the [ENS](http://www.di.ens.fr). + diff --git a/Master/texmf-dist/doc/latex/checklistings/checklistings.hva b/Master/texmf-dist/doc/latex/checklistings/checklistings.hva new file mode 100644 index 00000000000..8e3a95563bb --- /dev/null +++ b/Master/texmf-dist/doc/latex/checklistings/checklistings.hva @@ -0,0 +1,188 @@ +%% HeVeA support for checklistings. +%% +%% Limitations / caveats +%% +%% * checklistings.hva requires all the intermediate generated by latex and +%% checklistings.sh (*., *.tex, *.msg, *.err). +%% +%% * The options 'codestyle', 'msgstyle', 'errstyle', 'codelst', 'msglst', +%% and 'errlst' cannot be set as in LaTeX, e.g., +%% \checklistings{codelst={language=caml}} +%% Since HeVeA eliminates the grouping braces and passes 'language' to +%% the handler for 'codelst' (rather than 'language=caml'). +%% +%% One workaround is to \usepackage{hevea} and use \ifhevea to select +%% the most appropriate of the two forms. +%% +%% * fancyvrb and the package options codestyle, msgstyle, and errstyle are +%% not supported. +%% Alternative 1: use the codelst, msglst, and errlst options. +%% Alternative 2: use css for formatting code, messages, and errors. +%% +%% * Non-empty labels in the arguments of \chklistingmsg and +%% \chklistingerr are not supported. +%% +\ProvidesPackage{checklistings} +\RequirePackage{keyval} +\RequirePackage{listings} + +\newcounter{chklisting} +\setcounter{chklisting}{-1} + +\newif\ifCHKL@fileexists +\newif\ifCHKL@showcode\CHKL@showcodetrue +\newif\ifCHKL@shouldfail\CHKL@shouldfailfalse +\newif\ifCHKL@withresult\CHKL@withresultfalse +\newif\ifCHKL@showerrors\CHKL@showerrorstrue +\newif\ifCHKL@loadhtml\CHKL@loadhtmlfalse +\def\CHKL@pkg@skipopts{} + +% % % Declare Options % % % + +\DeclareOption{withresult}{\CHKL@withresulttrue} +\DeclareOption{withoutresult}{\CHKL@withresultfalse} +\DeclareOption{skipone}{\def\CHKL@pkg@skipopts{firstline=2}} +\DeclareOption{skiptwo}{\def\CHKL@pkg@skipopts{firstline=3}} +\DeclareOption{showproblems}{\CHKL@showproblemstrue} +\DeclareOption{hideproblems}{\CHKL@showproblemsfalse} + +\def\CHKL@codestyle{} +\def\CHKL@msgstyle{} +\def\CHKL@errstyle{} +\define@key{CHKL@pkgkeys}{codestyle}[]{\def\CHKL@codestyle{#1}} +\define@key{CHKL@pkgkeys}{msgstyle}[]{\def\CHKL@msgstyle{#1}} +\define@key{CHKL@pkgkeys}{errstyle}[]{\def\CHKL@errstyle{#1}} + +\def\CHKL@codelst{} +\def\CHKL@msglst{} +\def\CHKL@errlst{} +\define@key{CHKL@pkgkeys}{codelst}[]{\def\CHKL@codelst{#1}} +\define@key{CHKL@pkgkeys}{msglst}[]{\def\CHKL@msglst{#1}} +\define@key{CHKL@pkgkeys}{errlst}[]{\def\CHKL@errlst{#1}} + +\def\CHKL@subdir{.} +\def\CHKL@prefix{chklisting} +\def\CHKL@prompt{\#} +\def\CHKL@ext{.ml} +\define@key{CHKL@pkgkeys}{prompt}[]{\def\CHKL@prompt{#1}} +\define@key{CHKL@pkgkeys}{subdir}[]{\def\CHKL@subdir{#1}} +\define@key{CHKL@pkgkeys}{prefix}[]{\def\CHKL@prefix{#1}} +\define@key{CHKL@pkgkeys}{ext}[]{\def\CHKL@ext{#1}} +\define@key{CHKL@pkgkeys}{html}[]{\CHKL@loadhtmltrue} + +% Unused options +\define@key{CHKL@pkgkeys}{compiler}[]{} +\define@key{CHKL@pkgkeys}{compilerflags}[]{} +\define@key{CHKL@pkgkeys}{lastflags}[]{} +\define@key{CHKL@pkgkeys}{includecmd}[]{} + +% % % Process Options % % % + +% Work around the lack of \DeclareOption* in package.hva +\renewcommand{\@process@option}[1]% + {\def\pkg@opt{{\@nostyle\@callprim{\@eatspaces}{#1,}}}% + \ifu\csname\@pkg@opt@name{\pkg@opt}\endcsname + \setkeys{CHKL@pkgkeys}{#1} + \else + \csname\@pkg@opt@name{\pkg@opt}\endcsname\fi}% + +\ProcessOptions* +\newcommand{\checklistings}[1]{\ExecuteOptions{#1}} + +% % % Macros used in files generated by checklistings.sh % % % + +\newif\ifchklisting +\newcommand{\setchklistingcmd}[1]{% + \global\def\chklistingcmd{\emph{\CHKL@prompt{#1}}}} + +\newenvironment{ChkListingMsg}{\verblatex}{\endverblatex} +\newenvironment{ChkListingErr}{\verblatex}{\endverblatex} + +\newcommand{\chklistingfile}{\CHKL@prefix\CHKL@ext} + +% % % Checklistings user macros % % % + +\define@key{CHKL@envkeys}{continue}[]{} +\define@key{CHKL@envkeys}{include}[]{} +\define@key{CHKL@envkeys}{label}[]{} +\define@key{CHKL@envkeys}{showproblems}[]{\CHKL@showproblemstrue} +\define@key{CHKL@envkeys}{hideproblems}[]{\CHKL@showproblemsfalse} +\define@key{CHKL@envkeys}{skipnone}[]{\def\CHKL@pkg@skipopts{firstline=1}} +\define@key{CHKL@envkeys}{skipone}[]{\def\CHKL@pkg@skipopts{firstline=2}} +\define@key{CHKL@envkeys}{skiptwo}[]{\def\CHKL@pkg@skipopts{firstline=3}} +\define@key{CHKL@envkeys}{hide}[]{\CHKL@showcodefalse} +\define@key{CHKL@envkeys}{withresult}[]{\CHKL@withresulttrue} +\define@key{CHKL@envkeys}{withoutresult}[]{\CHKL@withresultfalse} +\define@key{CHKL@envkeys}{fail}[]{\CHKL@shouldfailtrue} + +% Work around the lack of \edef and \expandafter +\def\CHKL@lstset#1{\lstset{#1}} +\def\elstset#1{\@callprim{\CHKL@lstset}{\{#1\}}} + +\newcommand{\chklistingmsg}{\bgroup% + \setenvclass{lstlisting}{lstlisting chklistingmsg}% + \elstset{\CHKL@msgstyle}% + \elstset{\CHKL@msglst}% + \lstinputlisting{\CHKL@subdir/\CHKL@prefix\CHKL@num.msg}% + \egroup}% + +\newcommand{\chklistingerr}{\bgroup% + \setenvclass{lstlisting}{lstlisting chklistingerr}% + \elstset{\CHKL@errstyle}% + \elstset{\CHKL@errlst}% + \lstinputlisting{\CHKL@subdir/\CHKL@prefix\CHKL@num.err}% + \egroup}% + +\newenvironment{chklisting}[1][] + {% + \setenvclass{lstlisting}{lstlisting chklisting}% + \stepcounter{chklisting}% + \def\@currentlabel{\thechklisting}% + \@setkeys{CHKL@envkeys}{#1}% + \global\def\CHKL@num{% + \ifthenelse{\value{chklisting}<1000}{0}{}% + \ifthenelse{\value{chklisting}<100}{0}{}% + \ifthenelse{\value{chklisting}<10}{0}{}% + \arabic{chklisting}}% + \global\def\CHKL@file{\CHKL@subdir/\CHKL@prefix\CHKL@num}% + \global\let\chklistingcmd\relax% + \ifCHKL@showcode% + \bgroup% + \ifCHKL@loadhtml% + \@open{div}{class="chklisting"}% + \rawinput{\CHKL@file{}.html}% + \@close{div}% + \else% + \elstset{\CHKL@pkg@skipopts}% + \elstset{\CHKL@codestyle}% + \elstset{\CHKL@codelst}% + \lstinputlisting{\CHKL@file\CHKL@ext}% + \fi% + \egroup% + \input{\CHKL@file.tex}% + \ifCHKL@shouldfail% + \ifchklisting% + \ifCHKL@showproblems% + \begin{divstyle}{checklistingserror}% + Unexpected success: \chklistingmsg{} + \end{divstyle}% + \fi% + \else% + \ifCHKL@withresult{\chklistingerr{}}\fi% + \fi% + \else + \ifchklisting% + \ifCHKL@withresult{\chklistingmsg{}}\fi% + \else% + \ifCHKL@showproblems% + \begin{divstyle}{checklistingserror}% + Unexpected failure: \chklistingerr{} + \end{divstyle}% + \fi% + \fi% + \fi + \fi% + \verblatex% + } + {\endverblatex}% +\endinput diff --git a/Master/texmf-dist/doc/latex/checklistings/checklistings.pdf b/Master/texmf-dist/doc/latex/checklistings/checklistings.pdf new file mode 100644 index 00000000000..49f1aa917c9 Binary files /dev/null and b/Master/texmf-dist/doc/latex/checklistings/checklistings.pdf differ diff --git a/Master/texmf-dist/doc/latex/checklistings/example.html b/Master/texmf-dist/doc/latex/checklistings/example.html new file mode 100644 index 00000000000..5a78714da5a --- /dev/null +++ b/Master/texmf-dist/doc/latex/checklistings/example.html @@ -0,0 +1,74 @@ + + + + + + +example + + + +

Two simple declarations: +

let x = 3 +let f x = x + 1

and, after compilation with ocamlc -i example.ml, their types: +

val x : int +val f : int -> int

Then, building on these definitions: +

let y = f 3
val y : int

What about compiler error messages?: +

let z = 3 + "four"

They are also detected: +

File "example.ml", line 1, characters 12-18: +Error: This expression has type string but an expression was expected of type + int

We can continue on from earlier examples:

let z = f y
val z : int
+ + + +
This document was translated from LATEX by +HEVEA.
+ diff --git a/Master/texmf-dist/doc/latex/checklistings/example.pdf b/Master/texmf-dist/doc/latex/checklistings/example.pdf new file mode 100644 index 00000000000..37def76c622 Binary files /dev/null and b/Master/texmf-dist/doc/latex/checklistings/example.pdf differ diff --git a/Master/texmf-dist/doc/latex/checklistings/example.tex b/Master/texmf-dist/doc/latex/checklistings/example.tex new file mode 100644 index 00000000000..88980097a9f --- /dev/null +++ b/Master/texmf-dist/doc/latex/checklistings/example.tex @@ -0,0 +1,56 @@ +\documentclass[a4paper]{article} + +\usepackage[T1]{fontenc} +\usepackage[prompt=,prefix=example]{checklistings} +\usepackage{listings} + +\lstdefinestyle{camlstyle}{% + language=caml, + basicstyle=\sffamily, + keywordstyle=\bf, + literate={"}{\textquotedbl}1, +} +%BEGIN LATEX +\checklistings{codelst={style=camlstyle}} +%END LATEX +%HEVEA \newstyle{.chklistingerr}{font-style: italic; color: red;} +%HEVEA \newstyle{.chklistingmsg}{font-style: italic;} +%HEVEA \checklistings{codelst=\{style=camlstyle\}} + +\begin{document} + +\noindent +Two simple declarations: +\begin{chklisting} +let x = 3 +let f x = x + 1 +\end{chklisting} + +\noindent +and, after compilation with \chklistingcmd, their types: +\chklistingmsg{} + +\noindent +Then, building on these definitions: +\begin{chklisting}[continue,withresult,label=early] +let y = f 3 +\end{chklisting} + +\noindent +What about compiler error messages?: +\begin{chklisting}[fail] +let z = 3 + "four" +\end{chklisting} + +\noindent +They are also detected: +\chklistingerr{} + +\noindent +We can continue on from earlier examples: + +\begin{chklisting}[withresult,include=early] +let z = f y +\end{chklisting} + +\end{document} -- cgit v1.2.3