Skip to content

Commit cb401b8

Browse files
Haddock: Fix very confusing formatting errors (#2622)
Because of mistakes escaping special characters, some documentation showed the operators `$` and `*` where the Functor and Applicative operators were intended. Since they are all very common operators, this can be very confusing to the reader. Additionally, it was discovered that later versions of Haddock start interpreting Markdown-style links in code blocks, breaking the rendering of the primitive blackboxes in `Clash.Tutorial`. This problem does not occur with GHC 9.0.2 (Haddock 2.25.1), which we use to build the documentation for Hackage. But it does occur with at least GHC 9.6. To make such things less problematic, we decided to use bird tracks (lines starting with '> ') for code blocks that are not Haskell code, and only use the '@...@' style of code block for Haskell code. Bird tracks don't use any formatting at all. All code blocks with something other than Haskell code have been converted to bird tracks. Additionally, some escaping issues in Haskell code blocks were fixed when they were noticed.
1 parent 778a79d commit cb401b8

File tree

33 files changed

+528
-644
lines changed

33 files changed

+528
-644
lines changed

clash-cosim/src/Clash/CoSim/DSLParser.hs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,9 @@ dslParser =
129129
-- The parser will detect a module name if it is mentioned as the first thing
130130
-- followed by at least three dashes on the following line. For example:
131131
--
132-
-- @
133-
-- MODULE: my_module_name
134-
-- ----------
135-
-- <!-- HDL code starts here -->
136-
-- @
132+
-- > MODULE: my_module_name
133+
-- > ----------
134+
-- > <!-- HDL code starts here -->
137135
parse
138136
:: String
139137
-> Either ParseError (Maybe String, CoSimDSL)

clash-ffi/src/Clash/FFI/VPI/Object/Value/Parse.hs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,7 @@ parseBinStr bitSize bin = do
8484
--
8585
-- Consider the following bit string:
8686
--
87-
-- @
88-
-- 9'b.0.1.1001
89-
-- @
87+
-- > 9'b.0.1.1001
9088
--
9189
-- Attempting to read this as octal or hexadecimal results in a loss of
9290
-- precision in the value, giving @XX1@ and @xX9@. When @\'X\'@ (or @\'Z\'@)

clash-lib/src/Clash/Netlist/Util.hs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,15 +1168,13 @@ declareUseOnce u i = usageMap %= Map.alter go (Id.toText i)
11681168
-- | Declare uses which occur as a result of a component being instantiated,
11691169
-- for example the following design (verilog)
11701170
--
1171-
-- @
1172-
-- module f ( input p; output reg r ) ... endmodule
1173-
--
1174-
-- module top ( ... )
1175-
-- ...
1176-
-- f f_inst ( .p(p), .r(foo));
1177-
-- ...
1178-
-- endmodule
1179-
-- @
1171+
-- > module f ( input p; output reg r ) ... endmodule
1172+
-- >
1173+
-- > module top ( ... )
1174+
-- > ...
1175+
-- > f f_inst ( .p(p), .r(foo));
1176+
-- > ...
1177+
-- > endmodule
11801178
--
11811179
-- would declare a usage of foo, since it is assigned by @f_inst@.
11821180
--

clash-lib/src/Clash/Normalize/Transformations/Case.hs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -454,18 +454,20 @@ matchLiteralContructor c _ _ =
454454

455455
-- | Remove non-reachable alternatives. For example, consider:
456456
--
457-
-- data STy ty where
458-
-- SInt :: Int -> STy Int
459-
-- SBool :: Bool -> STy Bool
457+
-- @
458+
-- data STy ty where
459+
-- SInt :: Int -> STy Int
460+
-- SBool :: Bool -> STy Bool
460461
--
461-
-- f :: STy ty -> ty
462-
-- f (SInt b) = b + 1
463-
-- f (SBool True) = False
464-
-- f (SBool False) = True
465-
-- {-# NOINLINE f #-}
462+
-- f :: STy ty -> ty
463+
-- f (SInt b) = b + 1
464+
-- f (SBool True) = False
465+
-- f (SBool False) = True
466+
-- {\-\# NOINLINE f \#-\}
466467
--
467-
-- g :: STy Int -> Int
468-
-- g = f
468+
-- g :: STy Int -> Int
469+
-- g = f
470+
-- @
469471
--
470472
-- @f@ is always specialized on @STy Int@. The SBool alternatives are therefore
471473
-- unreachable. Additional information can be found at:
@@ -498,7 +500,7 @@ caseElemNonReachable _ e = return e
498500
-- GHC generates Core that looks like:
499501
--
500502
-- @
501-
-- f = \(x :: Unsigned 4) -> case x == fromInteger 3 of
503+
-- f = \\(x :: Unsigned 4) -> case x == fromInteger 3 of
502504
-- False -> case x == fromInteger 2 of
503505
-- False -> case x == fromInteger 1 of
504506
-- False -> case x == fromInteger 0 of
@@ -515,7 +517,7 @@ caseElemNonReachable _ e = return e
515517
-- This transformation transforms the above Core to the saner:
516518
--
517519
-- @
518-
-- f = \(x :: Unsigned 4) -> case x of
520+
-- f = \\(x :: Unsigned 4) -> case x of
519521
-- _ -> error "incomplete case"
520522
-- 0 -> fromInteger 3
521523
-- 1 -> fromInteger 2

clash-lib/src/Clash/Normalize/Transformations/Cast.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ import Clash.Util (ClashException(..), curLoc)
4242
-- transforms to:
4343
-- @
4444
-- y = f' a
45-
-- where f' x' = (\x -> g x) (cast x')
45+
-- where f' x' = (\\x -> g x) (cast x')
4646
-- @
4747
--
4848
-- The reason d'etre for this transformation is that we hope to end up with

clash-lib/src/Clash/Normalize/Transformations/MultiPrim.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ import Clash.Rewrite.Util (changed)
5858
-- will be rewritten to:
5959
--
6060
-- @
61-
-- \(x :: a) ->
61+
-- \\(x :: a) ->
6262
-- let
6363
-- r = prim @a @b @c x r0 r1 -- With 'Clash.Core.Term.MultiPrim'
6464
-- r0 = c$multiPrimSelect r0 r

clash-lib/src/Clash/Normalize/Transformations/Specialize.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ import Clash.Util (ClashException(..))
141141
-- Imagine
142142
--
143143
-- @
144-
-- (\x -> e) u
144+
-- (\\x -> e) u
145145
-- @
146146
--
147147
-- where @u@ has a free variable named @x@, rewriting this to:

clash-lib/src/Clash/Primitives/DSL.hs

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -842,14 +842,12 @@ instHO bbCtx fPos (resTy, bbResTy) argsWithTypes = do
842842
--
843843
-- A typical result is that a
844844
--
845-
-- @
846-
-- component fifo port
847-
-- ( rst : in std_logic
848-
-- ...
849-
-- ; full : out std_logic
850-
-- ; empty : out std_logic );
851-
-- end component;
852-
-- @
845+
-- > component fifo port
846+
-- > ( rst : in std_logic
847+
-- > ...
848+
-- > ; full : out std_logic
849+
-- > ; empty : out std_logic );
850+
-- > end component;
853851
--
854852
-- declaration would be added in the appropriate place.
855853
compInBlock
@@ -1068,9 +1066,7 @@ notExpr nm aExpr = do
10681066

10691067
-- | Creates a BV that produces the following vhdl:
10701068
--
1071-
-- @
1072-
-- (0 to n => ARG)
1073-
-- @
1069+
-- > (0 to n => ARG)
10741070
--
10751071
-- TODO: Implement for (System)Verilog
10761072
pureToBV
@@ -1090,9 +1086,7 @@ pureToBV nm n arg = do
10901086

10911087
-- | Creates a BV that produces the following vhdl:
10921088
--
1093-
-- @
1094-
-- std_logic_vector(resize(ARG, n))
1095-
-- @
1089+
-- > std_logic_vector(resize(ARG, n))
10961090
--
10971091
-- TODO: Implement for (System)Verilog
10981092
pureToBVResized

clash-prelude/src/Clash/Annotations/Primitive.hs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,8 @@ data HDL
201201
--
202202
-- You create a package which has a @myfancyip.cabal@ file with the following stanza:
203203
--
204-
-- @
205-
-- data-files: path\/to\/MyFancyIP.primitives
206-
-- cpp-options: -DCABAL
207-
-- @
204+
-- > data-files: path/to/MyFancyIP.primitives
205+
-- > cpp-options: -DCABAL
208206
--
209207
-- and a @MyFancyIP.hs@ module with the simulation definition and primitive.
210208
--

clash-prelude/src/Clash/Annotations/SynthesisAttributes.hs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,9 @@ type Annotate (a :: Type) (attrs :: k) = a
4141
-- | Synthesis attributes are directives passed to synthesis tools, such as
4242
-- Quartus. An example of such an attribute in VHDL:
4343
--
44-
-- @
45-
-- attribute chip_pin : string;
46-
-- attribute chip_pin of sel : signal is \"C4\";
47-
-- attribute chip_pin of data : signal is "D1, D2, D3, D4";
48-
-- @
44+
-- > attribute chip_pin : string;
45+
-- > attribute chip_pin of sel : signal is "C4";
46+
-- > attribute chip_pin of data : signal is "D1, D2, D3, D4";
4947
--
5048
-- This would instruct the synthesis tool to map the wire /sel/ to pin /C4/, and
5149
-- wire /data/ to pins /D1/, /D2/, /D3/, and /D4/. To achieve this in Clash, /Attr/s
@@ -92,7 +90,7 @@ type Annotate (a :: Type) (attrs :: k) = a
9290
-- @
9391
-- f :: Signal System Bool \`Annotate\` 'StringAttr \"chip_pin\" \"C4\"
9492
-- -> Signal System Bool
95-
-- f x = id x -- Using a lambda, i.e. f = \x -> id x also works
93+
-- f x = id x -- Using a lambda, i.e. f = \\x -> id x also works
9694
-- @
9795
--
9896
-- will reliably show the annotation in the generated HDL, but

0 commit comments

Comments
 (0)