\documentclass{book}

\usepackage[colorlinks=true,breaklinks=true]{hyperref}
\usepackage{color}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage[strings,nohyphen]{underscore}
\input{ifocamldoc}
\ifocamldoc
\usepackage{ocamldoc}
\usepackage{textcomp}
\else
\usepackage{changepage}
\usepackage{longtable}
\usepackage{listings}
\newcommand{\ocamlcodefragment}[1]{{\ttfamily\setlength{\parindent}{0cm}%
\raggedright#1}}
\newcommand{\ocamlinlinecode}[1]{{\ttfamily#1}}
\newcommand{\bold}[1]{{\bfseries#1}}
\newenvironment{ocamlexception}{\bfseries}{}
\newenvironment{ocamlextension}{\bfseries}{}
\newenvironment{ocamlarrow}{}

\newcommand{\ocamltag}[2]{\begin{ocaml#1}#2\end{ocaml#1}}
\newenvironment{ocamlkeyword}{\bfseries}{}
\newenvironment{ocamlconstructor}{\bfseries}{}
\newenvironment{ocamltype-var}{\itshape\ttfamily}{}

\newcommand{\ocamlhighlight}{\bfseries\uline}
\newcommand{\ocamlerror}{\bfseries}
\newcommand{\ocamlwarning}{\bfseries}

\definecolor{lightgray}{gray}{0.97}
\definecolor{gray}{gray}{0.5}
\newcommand{\ocamlcomment}{\color{gray}\normalfont\small}
\newcommand{\ocamlstring}{\color{gray}\bfseries}
\newenvironment{ocamlindent}{\begin{adjustwidth}{2em}{0pt}}{\end{adjustwidth}}
\newenvironment{ocamltabular}[2][l]{\begin{tabular}{#2}}%
{\end{tabular}}

\lstnewenvironment{ocamlcodeblock}{
  \lstset{
    backgroundcolor = \color{lightgray},
    basicstyle=\ttfamily,
    showstringspaces=false,
    language=caml,
    escapeinside={$}{$},
    columns=fullflexible,
    stringstyle=\ocamlstring,
    commentstyle=\ocamlcomment,
    keepspaces=true,
    keywordstyle=\ocamlkeyword,
    moredelim=[is][\ocamlhighlight]{<<}{>>},
    moredelim=[s][\ocamlstring]{\{|}{|\}},
    moredelim=[s][\ocamlstring]{\{delimiter|}{|delimiter\}},
    keywords={[2]{val,initializer,nonrec}}, keywordstyle={[2]\ocamlkeyword},
    belowskip=0\baselineskip,
    upquote=true,
    literate={'"'}{\textquotesingle "\textquotesingle}3
    {'\\"'}{\textquotesingle \textbackslash"\textquotesingle}4,
  }
}{}
\fi

\ifocamldoc
\newcommand{\docitem}[2]{\input{#2}}
\else
\newcommand{\docitem}[2]{\input{#1/#2}}
\fi

\begin{document}
\chapter{Stdlib}
\docitem{libref}{Stdlib.tex}
\input{stdlib_input}
\docitem{libref}{Ocaml_operators.tex}
\chapter{Dynlink}
\docitem{libref}{Dynlink.tex}
\chapter{Str}
\docitem{libref}{Str.tex}
\chapter{Thread}
\docitem{libref}{Condition.tex}
\docitem{libref}{Event.tex}
\docitem{libref}{Mutex.tex}
\docitem{libref}{Thread.tex}
\docitem{libref}{ThreadUnix.tex}
\docitem{libref}{Semaphore.tex}
\chapter{Unix}
\docitem{libref}{UnixLabels.tex}
\docitem{libref}{Unix.tex}
\chapter{Compilerlibs}
\docitem{compilerlibref}{Compiler_libs.tex}
\input{compilerlibs_input.tex}
\end{document}
