Jacco Krijnen pushed to branch wip/jacco/haddock/codeblock-highlighting at Glasgow Haskell Compiler / GHC

Commits:

1 changed file:

Changes:

  • utils/haddock/doc/markup.rst
    ... ... @@ -845,24 +845,52 @@ Unicode (or ISO 10646). For example, the references ``λ``,
    845 845
     Code Blocks
    
    846 846
     ~~~~~~~~~~~
    
    847 847
     
    
    848
    -Displayed blocks of code are indicated by surrounding a paragraph with
    
    849
    -``@...@`` or by preceding each line of a paragraph with ``>`` (we often
    
    850
    -call these “bird tracks”). For example: ::
    
    848
    +Displayed blocks of code can be indicated in different ways:
    
    851 849
     
    
    852
    -    -- | This documentation includes two blocks of code:
    
    850
    +- by surrounding a paragraph with ``@...@``
    
    851
    +- by preceding each line of a paragraph with ``>`` (we often
    
    852
    +  call these “bird tracks”)
    
    853
    +- by surrounding a paragraph with triple backticks `` ``` `` (also known
    
    854
    +  as fenced code blocks) and optionally indicating a language. Haddock
    
    855
    +  will apply syntax highlighting when a language is provided.
    
    856
    +
    
    857
    +For example: ::
    
    858
    +
    
    859
    +    -- | This documentation includes four blocks of code:
    
    853 860
         --
    
    854 861
         -- @
    
    855 862
         --     f x = x + x
    
    856 863
         -- @
    
    857 864
         --
    
    858 865
         -- >  g x = x * 42
    
    859
    -
    
    860
    -There is an important difference between the two forms of code block: in
    
    861
    -the bird-track form, the text to the right of the ‘\ ``>``\ ’ is
    
    862
    -interpreted literally, whereas the ``@...@`` form interprets markup as
    
    863
    -normal inside the code block. In particular, ``/`` is markup for italics,
    
    864
    -and so e.g. ``@x / y / z@`` renders as ``x`` followed by italic
    
    865
    -``y`` with no slashes, followed by ``z``.
    
    866
    +    --
    
    867
    +    -- ```
    
    868
    +    -- fix x = f (fix x)
    
    869
    +    -- ```
    
    870
    +    --
    
    871
    +    -- ```haskell
    
    872
    +    -- data Bool = False | True
    
    873
    +    -- ```
    
    874
    +
    
    875
    +
    
    876
    +There is an important difference between the forms of code block: bird
    
    877
    +tracks and fenced code blocks interpret text literally, whereas the
    
    878
    +``@...@`` form interprets haddock markup as normal inside the code
    
    879
    +block.
    
    880
    +
    
    881
    +For example,  ``@x / y / z@`` renders as
    
    882
    +
    
    883
    ++---------------------+-------------------------------+
    
    884
    +| Haddock             | Rendered                      |
    
    885
    ++=====================+===============================+
    
    886
    +| ``@x / y / z@``     | .. raw:: html                 |
    
    887
    +|                     |                               |
    
    888
    +|                     |     <code>x <i>y</i> z</code> |
    
    889
    ++---------------------+-------------------------------+
    
    890
    +| ``> x y z``         | .. raw:: html                 |
    
    891
    +|                     |                               |
    
    892
    +|                     |     <code>x / y / z</code>    |
    
    893
    ++---------------------+-------------------------------+
    
    866 894
     
    
    867 895
     Examples
    
    868 896
     ~~~~~~~~