Skip to content
This repository was archived by the owner on Aug 3, 2024. It is now read-only.

Commit ae23b4f

Browse files
committed
Many LaTeX backend fixes
After this commit, we can run with `--latex` on all boot libraries without crashing (although the generated LaTeX still fails to compile in a handful of larger packages like `ghc` and `base`). * Add newlines after all block elements in LaTeX. This is important to prevent the final output from being more an more indented. See the `latext-test/src/Example` test case for a sample of this. * Support associated types in class declarations (but not yet defaults) * Several small issues for producing compiling LaTeX; - avoid empy `\haddockbeginargs` lists (ex: `type family Any`) - properly escape identifiers depending on context (ex: `Int#`) - add `vbox` around `itemize`/`enumerate` (so they can be in tables) * Several spacing fixes: - limit the width of `Pretty`-arranged monospaced code - cut out extra space characters in export lists - only escape spaces if there are _multiple_ spaces - allow type signatures to be multiline (even without docs) * Remove uninteresting and repetitive `main.tex`/`haddock.sty` files from `latex-test` test reference output. Fixes #935, #929 (LaTeX docs for `text` build & compile) Fixes #727, #930 (I think both are really about type families...)
1 parent 747dfc7 commit ae23b4f

File tree

29 files changed

+253
-732
lines changed

29 files changed

+253
-732
lines changed

CHANGES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
* Render associated type defaults and also improve rendering of
2727
default method signatures
2828

29+
* Many fixes to the LaTeX backend, mostly focused on not crashing
30+
as well as generating LaTeX source that compiles
31+
2932
## Changes in version 2.22.0
3033

3134
* Make `--package-version` optional for `--hoogle` (#899)

haddock-api/src/Haddock/Backends/LaTeX.hs

Lines changed: 118 additions & 98 deletions
Large diffs are not rendered by default.

latex-test/Main.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ checkConfig = CheckConfig
1919

2020

2121
dirConfig :: DirConfig
22-
dirConfig = defaultDirConfig $ takeDirectory __FILE__
22+
dirConfig = (defaultDirConfig $ takeDirectory __FILE__)
23+
{ dcfgCheckIgnore = (`elem` ["haddock.sty", "main.tex"]) . takeFileName
24+
}
2325

2426

2527
main :: IO ()

latex-test/ref/ConstructorArgs/ConstructorArgs.tex

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@
33
\haddockbeginheader
44
{\haddockverb\begin{verbatim}
55
module ConstructorArgs (
6-
Foo((:|), Rec, Baz, Boa, (:*), x, y), Boo(Foo, Foa, Fo, Fo'), pattern Bo,
7-
pattern Bo'
6+
Foo((:|), Rec, Baz, Boa, (:*), x, y), Boo(Foo, Foa, Fo, Fo'),
7+
pattern Bo, pattern Bo'
88
) where\end{verbatim}}
99
\haddockendheader
1010

1111
\begin{haddockdesc}
1212
\item[\begin{tabular}{@{}l}
13-
data\ Foo
14-
\end{tabular}]\haddockbegindoc
13+
data Foo
14+
\end{tabular}]
15+
{\haddockbegindoc
1516
\enspace \emph{Constructors}\par
1617
\haddockbeginconstrs
1718
\haddockdecltt{=} & \haddockdecltt{Rec} & doc on a record \\
@@ -25,12 +26,13 @@
2526
\haddockdecltt{|} & \haddockdecltt{(:*)} & doc on the \haddockid{:*} constructor \\
2627
& \qquad \haddockdecltt{Int} & doc on the \haddockid{Int} field of the \haddockid{:*} constructor \\
2728
& \qquad \haddockdecltt{String} & doc on the \haddockid{String} field of the \haddockid{:*} constructor \\
28-
\end{tabulary}\par
29+
\end{tabulary}\par}
2930
\end{haddockdesc}
3031
\begin{haddockdesc}
3132
\item[\begin{tabular}{@{}l}
32-
data\ Boo\ where
33-
\end{tabular}]\haddockbegindoc
33+
data Boo where
34+
\end{tabular}]
35+
{\haddockbegindoc
3436
\enspace \emph{Constructors}\par
3537
\haddockbeginconstrs
3638
& \haddockdecltt{Foo} & Info about a \haddockid{Foo} \\
@@ -46,24 +48,24 @@
4648
& \qquad \haddockdecltt{->} \enspace \haddockdecltt{String} & a \haddockid{String} \\
4749
& \qquad \haddockdecltt{->} \enspace \haddockdecltt{Boo} & a \haddockid{Boo} \\
4850
& \haddockdecltt{pattern Fo' :: Boo} & Bundled and no argument docs \\
49-
\end{tabulary}\par
51+
\end{tabulary}\par}
5052
\end{haddockdesc}
5153
\begin{haddockdesc}
5254
\item[\begin{tabular}{@{}l}
53-
pattern\ Bo
54-
\end{tabular}]\haddockbegindoc
55+
pattern Bo
56+
\end{tabular}]
57+
{\haddockbegindoc
5558
\haddockbeginargs
5659
\haddockdecltt{::} & \haddockdecltt{Int} & an \haddockid{Int} \\
5760
\haddockdecltt{->} & \haddockdecltt{String} & a \haddockid{String} \\
5861
\haddockdecltt{->} & \haddockdecltt{Boo} & a \haddockid{Boo} pattern \\
5962
\end{tabulary}\par
60-
Info about not-bundled \haddockid{Bo}\par
61-
63+
Info about not-bundled \haddockid{Bo}\par}
6264
\end{haddockdesc}
6365
\begin{haddockdesc}
6466
\item[\begin{tabular}{@{}l}
65-
pattern\ Bo'\ ::\ Int\ ->\ String\ ->\ Boo
66-
\end{tabular}]\haddockbegindoc
67-
Not bunded and no argument docs\par
68-
67+
pattern Bo' :: Int -> String -> Boo
68+
\end{tabular}]
69+
{\haddockbegindoc
70+
Not bunded and no argument docs\par}
6971
\end{haddockdesc}

latex-test/ref/ConstructorArgs/haddock.sty

Lines changed: 0 additions & 57 deletions
This file was deleted.

latex-test/ref/ConstructorArgs/main.tex

Lines changed: 0 additions & 11 deletions
This file was deleted.

latex-test/ref/DefaultSignatures/DefaultSignatures.tex

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,33 @@
99

1010
\begin{haddockdesc}
1111
\item[\begin{tabular}{@{}l}
12-
class\ Foo\ a\ where
13-
\end{tabular}]\haddockbegindoc
12+
class Foo a where
13+
\end{tabular}]
14+
{\haddockbegindoc
1415
Documentation for Foo.\par
15-
1616
\haddockpremethods{}\emph{Methods}
1717
\begin{haddockdesc}
1818
\item[\begin{tabular}{@{}l}
19-
bar,\ baz\ ::\ a\ ->\ String
20-
\end{tabular}]\haddockbegindoc
21-
Documentation for bar and baz.\par
22-
19+
bar, baz :: a -> String
20+
\end{tabular}]
21+
{\haddockbegindoc
22+
Documentation for bar and baz.\par}
2323
\end{haddockdesc}
2424
\begin{haddockdesc}
2525
\item[\begin{tabular}{@{}l}
26-
default\ bar\ ::\ Show\ a\ =>\ a\ ->\ String
26+
default bar :: Show a => a -> String
2727
\end{tabular}]
2828
\end{haddockdesc}
2929
\begin{haddockdesc}
3030
\item[\begin{tabular}{@{}l}
31-
baz'\ ::\ String\ ->\ a
32-
\end{tabular}]\haddockbegindoc
33-
Documentation for baz'.\par
34-
31+
baz' :: String -> a
32+
\end{tabular}]
33+
{\haddockbegindoc
34+
Documentation for baz'.\par}
3535
\end{haddockdesc}
3636
\begin{haddockdesc}
3737
\item[\begin{tabular}{@{}l}
38-
default\ baz'\ ::\ Read\ a\ =>\ String\ ->\ a
38+
default baz' :: Read a => String -> a
3939
\end{tabular}]
40-
\end{haddockdesc}
40+
\end{haddockdesc}}
4141
\end{haddockdesc}

latex-test/ref/DefaultSignatures/haddock.sty

Lines changed: 0 additions & 57 deletions
This file was deleted.

latex-test/ref/DefaultSignatures/main.tex

Lines changed: 0 additions & 11 deletions
This file was deleted.

latex-test/ref/Deprecated/Deprecated.tex

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99

1010
\begin{haddockdesc}
1111
\item[\begin{tabular}{@{}l}
12-
deprecated\ ::\ Int
13-
\end{tabular}]\haddockbegindoc
12+
deprecated :: Int
13+
\end{tabular}]
14+
{\haddockbegindoc
1415
Deprecated: Don't use this\par
15-
Docs for something deprecated\par
16-
16+
Docs for something deprecated\par}
1717
\end{haddockdesc}

0 commit comments

Comments
 (0)