scotty-web / scotty

Haskell web framework inspired by Ruby's Sinatra, using WAI and Warp (Official Repository)
http://hackage.haskell.org/package/scotty
BSD 3-Clause "New" or "Revised" License
1.71k stars 132 forks source link

Add doctest #354

Closed ocramz closed 6 months ago

ocramz commented 7 months ago

closes #353

ocramz commented 7 months ago

WIP example docstrings using curl should be ported to use hspec-wai

ocramz commented 7 months ago

I've ported a few docstrings to doctest, now we can be sure the examples stay in sync with the code :)

There's a bit of code duplication but doctest doesn't seem to follow module imports and I'd rather not import 'http-client' into the main scotty library.

ocramz commented 7 months ago

@fumieval have you used doctest before? Do you have an idea for fixing the error in the $setup block that appeared in CI?

On Mon, 4 Dec 2023 at 02:43, Fumiaki Kinoshita @.***> wrote:

@.**** approved this pull request.

— Reply to this email directly, view it on GitHub https://github.com/scotty-web/scotty/pull/354#pullrequestreview-1761474143, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABNBDKBG6KYANKIQOPMA7MTYHUTEZAVCNFSM6AAAAABACLACS6VHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMYTONRRGQ3TIMJUGM . You are receiving this because you authored the thread.Message ID: @.***>

fumieval commented 7 months ago

Hmm I'm not quite sure what is going on :/

ocramz commented 6 months ago

@fumieval ahh figured this out! it's a GHCi bug, unrelated to doctest. GHCi only recently started supporting multiline imports : https://github.com/scotty-web/scotty/actions/runs/7075697407/job/19258105080?pr=354#step:7:95, related GHC ticket: https://gitlab.haskell.org/ghc/ghc/-/issues/20473

ocramz commented 6 months ago

@fumieval I've turned doctest into a pure () for GHCs older than 9.4.6 , wdyt? https://github.com/scotty-web/scotty/pull/354/commits/de8d7397068690bf2cb3193023070dea0c4abae0

ocramz commented 6 months ago

I'll merge this for now, we can revisit later if needed.