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

support for multiline text doctest properties #1609

Closed
thielema opened this issue Jul 26, 2023 · 3 comments
Closed

support for multiline text doctest properties #1609

thielema opened this issue Jul 26, 2023 · 3 comments

Comments

@thielema
Copy link
Contributor

Doctest supports multiline syntax :{ .. :} for doctest unit tests, e.g.

>>> :{ runMyTest
   longArgumentA
   longArgumentB
   longArgumentC
:}
expected output

but it does not support that syntax for doctest properties, that is

prop> :{ runMyTest
   longArgumentA
   longArgumentB
   longArgumentC
:}

We would like to support multiline syntax for properties in doctest-extract, though, which is currently blocked by missing support in Haddock. We have factored out the doctest parser to https://hackage.haskell.org/package/doctest-lib, thus haddock and doctest-extract and doctest could use the same parser.

See also: sol/doctest#131

@Kleidukos
Copy link
Member

Hi, thank you for this ticket, but Haddock now lives full-time in the GHC repository!
Read more at https://discourse.haskell.org/t/haddock-now-lives-in-the-ghc-repository/9576.

Let me know if you feel it is still needed, and I'll migrate it. :)

@ruifengx
Copy link

As an end user, I still would like this feature to be implemented. Currently, multi-line doctest unit tests are actually not supported by Haddock; it just works by coincidence.

For the following doc comment:

-- >>> :{
-- some
--   test
--   lines
-- :}

Haddock renders the first line (i.e., :{) as code (with a bold font), but the rest of lines as output text (with a normal font). Ideally, the code block should instead be written as follows:

-- >>> :{
-- >>> some
-- >>>   test
-- >>>   lines
-- >>> :}

so as to indicate all these lines are test code instead of output texts, but Haddock would trim the leading whitespace, resulting in incorrect layout.

Anyway, I believe this issue is still relevant for Haddock and should be migrated to the GHC repo on GitLab. One of the few things I miss after returning to Haskell from Rust is the integration of doctests, and I sincerely hope this situation could improve over time.

@thielema
Copy link
Contributor Author

It is implemented but seems to have been dropped due to the move of Haddock into GHC repository:
#1619

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants