Skip to content

Commit

Permalink
tune latex escaping rule for labels
Browse files Browse the repository at this point in the history
  • Loading branch information
Octachron authored and jonludlam committed Jan 10, 2023
1 parent b6223d8 commit ffdfac8
Show file tree
Hide file tree
Showing 39 changed files with 361 additions and 362 deletions.
1 change: 0 additions & 1 deletion src/latex/raw.ml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ module Escape = struct
for i = 0 to String.length s - 1 do
match s.[i] with
| '~' -> Fmt.pf ppf "+t+"
| '_' -> Fmt.pf ppf "+u+"
| '+' -> Fmt.pf ppf "+++"
| c -> Fmt.pf ppf "%c" c
done
Expand Down
2 changes: 1 addition & 1 deletion test/generators/latex/Bugs_post_406.let_open'.tex
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
\section{Class \ocamlinlinecode{Bugs\_\allowbreak{}post\_\allowbreak{}406.\allowbreak{}let\_\allowbreak{}open'}}\label{module-Bugs+u+post+u+406-class-let+u+open'}%
\section{Class \ocamlinlinecode{Bugs\_\allowbreak{}post\_\allowbreak{}406.\allowbreak{}let\_\allowbreak{}open'}}\label{module-Bugs_post_406-class-let_open'}%


6 changes: 3 additions & 3 deletions test/generators/latex/Bugs_post_406.tex
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
\section{Module \ocamlinlinecode{Bugs\_\allowbreak{}post\_\allowbreak{}406}}\label{module-Bugs+u+post+u+406}%
\section{Module \ocamlinlinecode{Bugs\_\allowbreak{}post\_\allowbreak{}406}}\label{module-Bugs_post_406}%
Let-open in class types, https://github.com/ocaml/odoc/issues/543 This was added to the language in 4.06

\label{module-Bugs+u+post+u+406-class-type-let+u+open}\ocamlcodefragment{\ocamltag{keyword}{class} \ocamltag{keyword}{type} \hyperref[module-Bugs+u+post+u+406-class-type-let+u+open]{\ocamlinlinecode{let\_\allowbreak{}open}}}\ocamlcodefragment{ = \ocamltag{keyword}{object}}\begin{ocamlindent}\end{ocamlindent}%
\label{module-Bugs_post_406-class-type-let_open}\ocamlcodefragment{\ocamltag{keyword}{class} \ocamltag{keyword}{type} \hyperref[module-Bugs_post_406-class-type-let_open]{\ocamlinlinecode{let\_\allowbreak{}open}}}\ocamlcodefragment{ = \ocamltag{keyword}{object}}\begin{ocamlindent}\end{ocamlindent}%
\ocamlcodefragment{\ocamltag{keyword}{end}}\\
\label{module-Bugs+u+post+u+406-class-let+u+open'}\ocamlcodefragment{\ocamltag{keyword}{class} \hyperref[module-Bugs+u+post+u+406-class-let+u+open']{\ocamlinlinecode{let\_\allowbreak{}open'}}}\ocamlcodefragment{ : \ocamltag{keyword}{object} .\allowbreak{}.\allowbreak{}.\allowbreak{} \ocamltag{keyword}{end}}\\
\label{module-Bugs_post_406-class-let_open'}\ocamlcodefragment{\ocamltag{keyword}{class} \hyperref[module-Bugs_post_406-class-let_open']{\ocamlinlinecode{let\_\allowbreak{}open'}}}\ocamlcodefragment{ : \ocamltag{keyword}{object} .\allowbreak{}.\allowbreak{}.\allowbreak{} \ocamltag{keyword}{end}}\\

\input{Bugs_post_406.let_open'.tex}
6 changes: 3 additions & 3 deletions test/generators/latex/Bugs_pre_410.tex
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
\section{Module \ocamlinlinecode{Bugs\_\allowbreak{}pre\_\allowbreak{}410}}\label{module-Bugs+u+pre+u+410}%
\label{module-Bugs+u+pre+u+410-type-opt'}\ocamlcodefragment{\ocamltag{keyword}{type} 'a opt' = int option}\\
\label{module-Bugs+u+pre+u+410-val-foo'}\ocamlcodefragment{\ocamltag{keyword}{val} foo' : ?bar:\ocamltag{type-var}{'a} \ocamltag{arrow}{$\rightarrow$} unit \ocamltag{arrow}{$\rightarrow$} unit}\begin{ocamlindent}Similar to \ocamlinlinecode{Bugs}, but the printed type of \ocamlinlinecode{\textasciitilde{}bar} should be \ocamlinlinecode{int}, not \ocamlinlinecode{'a}. This probably requires fixing in the compiler. See \href{https://github.com/ocaml/odoc/pull/230\#issuecomment-433226807}{https://github.com/ocaml/odoc/pull/230\#issuecomment-433226807}\footnote{\url{https://github.com/ocaml/odoc/pull/230\#issuecomment-433226807}}.\end{ocamlindent}%
\section{Module \ocamlinlinecode{Bugs\_\allowbreak{}pre\_\allowbreak{}410}}\label{module-Bugs_pre_410}%
\label{module-Bugs_pre_410-type-opt'}\ocamlcodefragment{\ocamltag{keyword}{type} 'a opt' = int option}\\
\label{module-Bugs_pre_410-val-foo'}\ocamlcodefragment{\ocamltag{keyword}{val} foo' : ?bar:\ocamltag{type-var}{'a} \ocamltag{arrow}{$\rightarrow$} unit \ocamltag{arrow}{$\rightarrow$} unit}\begin{ocamlindent}Similar to \ocamlinlinecode{Bugs}, but the printed type of \ocamlinlinecode{\textasciitilde{}bar} should be \ocamlinlinecode{int}, not \ocamlinlinecode{'a}. This probably requires fixing in the compiler. See \href{https://github.com/ocaml/odoc/pull/230\#issuecomment-433226807}{https://github.com/ocaml/odoc/pull/230\#issuecomment-433226807}\footnote{\url{https://github.com/ocaml/odoc/pull/230\#issuecomment-433226807}}.\end{ocamlindent}%
\medbreak


2 changes: 1 addition & 1 deletion test/generators/latex/Class.empty_virtual'.tex
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
\section{Class \ocamlinlinecode{Class.\allowbreak{}empty\_\allowbreak{}virtual'}}\label{module-Class-class-empty+u+virtual'}%
\section{Class \ocamlinlinecode{Class.\allowbreak{}empty\_\allowbreak{}virtual'}}\label{module-Class-class-empty_virtual'}%


4 changes: 2 additions & 2 deletions test/generators/latex/Class.tex
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ \section{Module \ocamlinlinecode{Class}}\label{module-Class}%
\ocamlcodefragment{\ocamltag{keyword}{end}}\\
\label{module-Class-class-mutually'}\ocamlcodefragment{\ocamltag{keyword}{class} \hyperref[module-Class-class-mutually']{\ocamlinlinecode{mutually'}}}\ocamlcodefragment{ : \hyperref[module-Class-class-type-mutually]{\ocamlinlinecode{mutually}}}\\
\label{module-Class-class-recursive'}\ocamlcodefragment{\ocamltag{keyword}{class} \hyperref[module-Class-class-recursive']{\ocamlinlinecode{recursive'}}}\ocamlcodefragment{ : \hyperref[module-Class-class-type-recursive]{\ocamlinlinecode{recursive}}}\\
\label{module-Class-class-type-empty+u+virtual}\ocamlcodefragment{\ocamltag{keyword}{class} \ocamltag{keyword}{type} \ocamltag{keyword}{virtual} \hyperref[module-Class-class-type-empty+u+virtual]{\ocamlinlinecode{empty\_\allowbreak{}virtual}}}\ocamlcodefragment{ = \ocamltag{keyword}{object}}\begin{ocamlindent}\end{ocamlindent}%
\label{module-Class-class-type-empty_virtual}\ocamlcodefragment{\ocamltag{keyword}{class} \ocamltag{keyword}{type} \ocamltag{keyword}{virtual} \hyperref[module-Class-class-type-empty_virtual]{\ocamlinlinecode{empty\_\allowbreak{}virtual}}}\ocamlcodefragment{ = \ocamltag{keyword}{object}}\begin{ocamlindent}\end{ocamlindent}%
\ocamlcodefragment{\ocamltag{keyword}{end}}\\
\label{module-Class-class-empty+u+virtual'}\ocamlcodefragment{\ocamltag{keyword}{class} \ocamltag{keyword}{virtual} \hyperref[module-Class-class-empty+u+virtual']{\ocamlinlinecode{empty\_\allowbreak{}virtual'}}}\ocamlcodefragment{ : \hyperref[module-Class-class-type-empty]{\ocamlinlinecode{empty}}}\\
\label{module-Class-class-empty_virtual'}\ocamlcodefragment{\ocamltag{keyword}{class} \ocamltag{keyword}{virtual} \hyperref[module-Class-class-empty_virtual']{\ocamlinlinecode{empty\_\allowbreak{}virtual'}}}\ocamlcodefragment{ : \hyperref[module-Class-class-type-empty]{\ocamlinlinecode{empty}}}\\
\label{module-Class-class-type-polymorphic}\ocamlcodefragment{\ocamltag{keyword}{class} \ocamltag{keyword}{type} 'a \hyperref[module-Class-class-type-polymorphic]{\ocamlinlinecode{polymorphic}}}\ocamlcodefragment{ = \ocamltag{keyword}{object}}\begin{ocamlindent}\end{ocamlindent}%
\ocamlcodefragment{\ocamltag{keyword}{end}}\\
\label{module-Class-class-polymorphic'}\ocamlcodefragment{\ocamltag{keyword}{class} 'a \hyperref[module-Class-class-polymorphic']{\ocamlinlinecode{polymorphic'}}}\ocamlcodefragment{ : \ocamltag{type-var}{'a} \hyperref[module-Class-class-type-polymorphic]{\ocamlinlinecode{polymorphic}}}\\
Expand Down
6 changes: 3 additions & 3 deletions test/generators/latex/Class_comments.c.tex
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
\section{Class \ocamlinlinecode{Class\_\allowbreak{}comments.\allowbreak{}c}}\label{module-Class+u+comments-class-c}%
\ocamlcodefragment{\ocamltag{keyword}{inherit} \hyperref[module-Class+u+comments-class-x]{\ocamlinlinecode{x}}}\begin{ocamlindent}Inherit.\end{ocamlindent}%
\section{Class \ocamlinlinecode{Class\_\allowbreak{}comments.\allowbreak{}c}}\label{module-Class_comments-class-c}%
\ocamlcodefragment{\ocamltag{keyword}{inherit} \hyperref[module-Class_comments-class-x]{\ocamlinlinecode{x}}}\begin{ocamlindent}Inherit.\end{ocamlindent}%
\medbreak
\ocamlcodefragment{ \ocamltag{keyword}{constraint} \ocamltag{type-var}{'a} = int}\begin{ocamlindent}Constraint.\end{ocamlindent}%
\medbreak
Floating comment.

\label{module-Class+u+comments-class-c-method-bar}\ocamlcodefragment{\ocamltag{keyword}{method} bar : int}\\
\label{module-Class_comments-class-c-method-bar}\ocamlcodefragment{\ocamltag{keyword}{method} bar : int}\\


6 changes: 3 additions & 3 deletions test/generators/latex/Class_comments.tex
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
\section{Module \ocamlinlinecode{Class\_\allowbreak{}comments}}\label{module-Class+u+comments}%
\label{module-Class+u+comments-class-x}\ocamlcodefragment{\ocamltag{keyword}{class} \hyperref[module-Class+u+comments-class-x]{\ocamlinlinecode{x}}}\ocamlcodefragment{ : \ocamltag{keyword}{object} .\allowbreak{}.\allowbreak{}.\allowbreak{} \ocamltag{keyword}{end}}\\
\label{module-Class+u+comments-class-c}\ocamlcodefragment{\ocamltag{keyword}{class} 'a \hyperref[module-Class+u+comments-class-c]{\ocamlinlinecode{c}}}\ocamlcodefragment{ : \ocamltag{keyword}{object} .\allowbreak{}.\allowbreak{}.\allowbreak{} \ocamltag{keyword}{end}}\\
\section{Module \ocamlinlinecode{Class\_\allowbreak{}comments}}\label{module-Class_comments}%
\label{module-Class_comments-class-x}\ocamlcodefragment{\ocamltag{keyword}{class} \hyperref[module-Class_comments-class-x]{\ocamlinlinecode{x}}}\ocamlcodefragment{ : \ocamltag{keyword}{object} .\allowbreak{}.\allowbreak{}.\allowbreak{} \ocamltag{keyword}{end}}\\
\label{module-Class_comments-class-c}\ocamlcodefragment{\ocamltag{keyword}{class} 'a \hyperref[module-Class_comments-class-c]{\ocamlinlinecode{c}}}\ocamlcodefragment{ : \ocamltag{keyword}{object} .\allowbreak{}.\allowbreak{}.\allowbreak{} \ocamltag{keyword}{end}}\\

\input{Class_comments.x.tex}
\input{Class_comments.c.tex}
2 changes: 1 addition & 1 deletion test/generators/latex/Class_comments.x.tex
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
\section{Class \ocamlinlinecode{Class\_\allowbreak{}comments.\allowbreak{}x}}\label{module-Class+u+comments-class-x}%
\section{Class \ocamlinlinecode{Class\_\allowbreak{}comments.\allowbreak{}x}}\label{module-Class_comments-class-x}%


2 changes: 1 addition & 1 deletion test/generators/latex/Functor.tex
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ \section{Module \ocamlinlinecode{Functor}}\label{module-Functor}%
\end{ocamlindent}%
\ocamlcodefragment{\ocamltag{keyword}{end}}\\
\label{module-Functor-module-type-S1}\ocamlcodefragment{\ocamltag{keyword}{module} \ocamltag{keyword}{type} \hyperref[module-Functor-module-type-S1]{\ocamlinlinecode{S1}}}\ocamlcodefragment{ = \ocamltag{keyword}{sig}}\begin{ocamlindent}\subsubsection{Parameters\label{parameters}}%
\label{module-Functor-module-type-S1-argument-1-+u+}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[module-Functor-module-type-S1-argument-1-+u+]{\ocamlinlinecode{\_\allowbreak{}}}}\ocamlcodefragment{ : \ocamltag{keyword}{sig}}\begin{ocamlindent}\label{module-Functor-module-type-S1-argument-1-+u+-type-t}\ocamlcodefragment{\ocamltag{keyword}{type} t}\\
\label{module-Functor-module-type-S1-argument-1-_}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[module-Functor-module-type-S1-argument-1-_]{\ocamlinlinecode{\_\allowbreak{}}}}\ocamlcodefragment{ : \ocamltag{keyword}{sig}}\begin{ocamlindent}\label{module-Functor-module-type-S1-argument-1-_-type-t}\ocamlcodefragment{\ocamltag{keyword}{type} t}\\
\end{ocamlindent}%
\ocamlcodefragment{\ocamltag{keyword}{end}}\\
\subsubsection{Signature\label{signature}}%
Expand Down
6 changes: 3 additions & 3 deletions test/generators/latex/Functor2.X.tex
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ \subsection{Parameters\label{parameters}}%
\end{ocamlindent}%
\ocamlcodefragment{\ocamltag{keyword}{end}}\\
\subsection{Signature\label{signature}}%
\label{module-Functor2-module-X-type-y+u+t}\ocamlcodefragment{\ocamltag{keyword}{type} y\_\allowbreak{}t = \hyperref[module-Functor2-module-X-argument-1-Y-type-t]{\ocamlinlinecode{Y.\allowbreak{}t}}}\\
\label{module-Functor2-module-X-type-z+u+t}\ocamlcodefragment{\ocamltag{keyword}{type} z\_\allowbreak{}t = \hyperref[module-Functor2-module-X-argument-2-Z-type-t]{\ocamlinlinecode{Z.\allowbreak{}t}}}\\
\label{module-Functor2-module-X-type-x+u+t}\ocamlcodefragment{\ocamltag{keyword}{type} x\_\allowbreak{}t = \hyperref[module-Functor2-module-X-type-y+u+t]{\ocamlinlinecode{y\_\allowbreak{}t}}}\\
\label{module-Functor2-module-X-type-y_t}\ocamlcodefragment{\ocamltag{keyword}{type} y\_\allowbreak{}t = \hyperref[module-Functor2-module-X-argument-1-Y-type-t]{\ocamlinlinecode{Y.\allowbreak{}t}}}\\
\label{module-Functor2-module-X-type-z_t}\ocamlcodefragment{\ocamltag{keyword}{type} z\_\allowbreak{}t = \hyperref[module-Functor2-module-X-argument-2-Z-type-t]{\ocamlinlinecode{Z.\allowbreak{}t}}}\\
\label{module-Functor2-module-X-type-x_t}\ocamlcodefragment{\ocamltag{keyword}{type} x\_\allowbreak{}t = \hyperref[module-Functor2-module-X-type-y_t]{\ocamlinlinecode{y\_\allowbreak{}t}}}\\


10 changes: 5 additions & 5 deletions test/generators/latex/Functor2.tex
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ \section{Module \ocamlinlinecode{Functor2}}\label{module-Functor2}%
\end{ocamlindent}%
\ocamlcodefragment{\ocamltag{keyword}{end}}\\
\label{module-Functor2-module-X}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[module-Functor2-module-X]{\ocamlinlinecode{X}}}\ocamlcodefragment{ (\hyperref[module-Functor2-module-X-argument-1-Y]{\ocamlinlinecode{Y}} : \hyperref[module-Functor2-module-type-S]{\ocamlinlinecode{S}}) (\hyperref[module-Functor2-module-X-argument-2-Z]{\ocamlinlinecode{Z}} : \hyperref[module-Functor2-module-type-S]{\ocamlinlinecode{S}}) : \ocamltag{keyword}{sig} .\allowbreak{}.\allowbreak{}.\allowbreak{} \ocamltag{keyword}{end}}\\
\label{module-Functor2-module-type-XF}\ocamlcodefragment{\ocamltag{keyword}{module} \ocamltag{keyword}{type} \hyperref[module-Functor2-module-type-XF]{\ocamlinlinecode{XF}}}\ocamlcodefragment{ = \ocamltag{keyword}{sig}}\begin{ocamlindent}\subsubsection{Parameters\label{parameters+u+2}}%
\label{module-Functor2-module-type-XF}\ocamlcodefragment{\ocamltag{keyword}{module} \ocamltag{keyword}{type} \hyperref[module-Functor2-module-type-XF]{\ocamlinlinecode{XF}}}\ocamlcodefragment{ = \ocamltag{keyword}{sig}}\begin{ocamlindent}\subsubsection{Parameters\label{parameters_2}}%
\label{module-Functor2-module-type-XF-argument-1-Y}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[module-Functor2-module-type-XF-argument-1-Y]{\ocamlinlinecode{Y}}}\ocamlcodefragment{ : \ocamltag{keyword}{sig}}\begin{ocamlindent}\label{module-Functor2-module-type-XF-argument-1-Y-type-t}\ocamlcodefragment{\ocamltag{keyword}{type} t}\\
\end{ocamlindent}%
\ocamlcodefragment{\ocamltag{keyword}{end}}\\
\label{module-Functor2-module-type-XF-argument-2-Z}\ocamlcodefragment{\ocamltag{keyword}{module} \hyperref[module-Functor2-module-type-XF-argument-2-Z]{\ocamlinlinecode{Z}}}\ocamlcodefragment{ : \ocamltag{keyword}{sig}}\begin{ocamlindent}\label{module-Functor2-module-type-XF-argument-2-Z-type-t}\ocamlcodefragment{\ocamltag{keyword}{type} t}\\
\end{ocamlindent}%
\ocamlcodefragment{\ocamltag{keyword}{end}}\\
\subsubsection{Signature\label{signature+u+2}}%
\label{module-Functor2-module-type-XF-type-y+u+t}\ocamlcodefragment{\ocamltag{keyword}{type} y\_\allowbreak{}t = \hyperref[module-Functor2-module-type-XF-argument-1-Y-type-t]{\ocamlinlinecode{Y.\allowbreak{}t}}}\\
\label{module-Functor2-module-type-XF-type-z+u+t}\ocamlcodefragment{\ocamltag{keyword}{type} z\_\allowbreak{}t = \hyperref[module-Functor2-module-type-XF-argument-2-Z-type-t]{\ocamlinlinecode{Z.\allowbreak{}t}}}\\
\label{module-Functor2-module-type-XF-type-x+u+t}\ocamlcodefragment{\ocamltag{keyword}{type} x\_\allowbreak{}t = \hyperref[module-Functor2-module-type-XF-type-y+u+t]{\ocamlinlinecode{y\_\allowbreak{}t}}}\\
\subsubsection{Signature\label{signature_2}}%
\label{module-Functor2-module-type-XF-type-y_t}\ocamlcodefragment{\ocamltag{keyword}{type} y\_\allowbreak{}t = \hyperref[module-Functor2-module-type-XF-argument-1-Y-type-t]{\ocamlinlinecode{Y.\allowbreak{}t}}}\\
\label{module-Functor2-module-type-XF-type-z_t}\ocamlcodefragment{\ocamltag{keyword}{type} z\_\allowbreak{}t = \hyperref[module-Functor2-module-type-XF-argument-2-Z-type-t]{\ocamlinlinecode{Z.\allowbreak{}t}}}\\
\label{module-Functor2-module-type-XF-type-x_t}\ocamlcodefragment{\ocamltag{keyword}{type} x\_\allowbreak{}t = \hyperref[module-Functor2-module-type-XF-type-y_t]{\ocamlinlinecode{y\_\allowbreak{}t}}}\\
\end{ocamlindent}%
\ocamlcodefragment{\ocamltag{keyword}{end}}\\

Expand Down
Loading

0 comments on commit ffdfac8

Please sign in to comment.