Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add initial docspec setup. #124

Closed
wants to merge 9 commits into from
Closed

Conversation

andreabedini
Copy link

This adds the setup required to run doc-testing using cabal-docspec, developed by @phadej.

This is the same setup that the the "kmettverse" uses (e.g. the comonad package).

It also starts converting existing documentation to docspecs, i.e. the Control.Monad.Except module.

This adds the setup required to run doc-testing using cabal-docspec,
developed by Oleg Grenrus (@phadej). This is the same setup that the the
"kmettverse" uses (e.g. the comonad package).

It also starts converting existing documentation to docspecs, i.e. the
Control.Monad.Except module.
@andreabedini
Copy link
Author

I went ahead and converted the remaming examples to docspec format. A couple of observations:

  • cabal-docspec works by feeding code to ghci, this means that declarations have to be entered one at the tiem and in the right order. I had to slightly rework the Contol.Monad.Reader example to get it work.
  • Where possible, I turned top level mains into a inline example, adding the expected result to the documentation.
  • The Control.Monad.Reader example uses Data.Map from containers. cabal-docspec reuses the build plan built by cabal and containers is not a build dependency of mtl, so it would not be available to cabal-docspec. As per the cabal-docspec documentation, to get this to work I have added a line to cabal.project to include containers in the build plan, and told cabal-docspec to add that package to ghci.

@kozross
Copy link
Collaborator

kozross commented May 21, 2022

@andreabedini I'm very happy that someone has undertaken this: it looks great! However, we need to ensure that this passes CI, and it currently fails on macOS. I also suspect it'll fail on Windows.

@andreabedini
Copy link
Author

@kozross thanks. I have been too liberal in copying comonad’s setup without realising how specific that environment is. I’ll get this to work on Monday!

@kozross
Copy link
Collaborator

kozross commented May 22, 2022

@andreabedini If you want something that's more general, you can follow my text-ascii setup. It should work everywhere.

@andreabedini
Copy link
Author

@andreabedini If you want something that's more general, you can follow my text-ascii setup. It should work everywhere.

oh, I like your setup! I wish cabal-docspec was on Hackage (or had binaries for macOS and Windows).

@andreabedini
Copy link
Author

@andreabedini If you want something that's more general, you can follow my text-ascii setup. It should work everywhere.

I like your setup, but after thinking a bit about it, I belive we should only run docspec on the platforms we have a binary release for, which AFAIK is only Linux.

The reason is not adding complexity to the mtl CI. I would not want mtl CI to become a CI for cabal-docspec. E.g. Oleg uses ghc 8.10.4 on his repository. What if 9.2 breaks cabal-docspec?

@kozross
Copy link
Collaborator

kozross commented May 23, 2022

I'm really torn about this. On the one hand, you are absolutely right, but on the other hand, I feel this is basically relegating other platforms to second-class status in the CI, which I oppose.

@andreabedini
Copy link
Author

I'm really torn about this. On the one hand, you are absolutely right, but on the other hand, I feel this is basically relegating other platforms to second-class status in the CI, which I oppose.

<3 I am 1000% with you on this! Perhaps we should direct our efforts to support Oleg?

Also, docspec on linux vs no docspec anywhere is still a step forward!

@emilypi
Copy link
Member

emilypi commented Jul 5, 2022

Gargantuan effort thank you! 😄

emilypi
emilypi previously approved these changes Jul 5, 2022
@emilypi
Copy link
Member

emilypi commented Jul 5, 2022

If cabal-docspec breaks, i'll pick it up i suppose.

@emilypi emilypi dismissed their stale review July 5, 2022 18:12

Let's just use @kozross's fork and get homogeneous coverage

@emilypi
Copy link
Member

emilypi commented Jul 5, 2022

I like your setup, but after thinking a bit about it, I belive we should only run docspec on the platforms we have a binary release for, which AFAIK is only Linux.

This doesn't make sense to me. What about having a binary privileges it to be doctested, when the doctests are part of the test contract for every distribution on every platform? Koz already has a fork that covers mac and windows. We should be committing to doctests as a supplement to the unit and property tests we already do, not as coverage for any binary, and further, we don't cut binaries, we cut archives with source.

@andreabedini
Copy link
Author

This doesn't make sense to me.

That's ok. I guess my real intent was to delimit as much as possible what's on mtl's team plate and what is not. Using a fork of cabal-extras works fine and it allows us to cover all platforms, which is great, but also brings in more work on @kozross :-) Reading back what I wrote I think by "having a binary release for" I meant to say "someone else is responsible for".

I am happy with whatever way you decide to go. Doc-testing is the goal here, not the details of how we install the tool.

Do you want me to update this PR following @kozross text-ascii setup?

@kozross
Copy link
Collaborator

kozross commented Jul 11, 2022

@andreabedini That would be ideal, yes.

@andreabedini
Copy link
Author

Hey @kozross @emilypi, is there anything else to be done for this PR? Thanks

@andreabedini
Copy link
Author

nevermind, they CI fails. I will have a look.

@andreabedini
Copy link
Author

right, cabal-docspec fails to compile on ghc 9.4.1, which is the kind of issues I was expecting in my previous comment. I guess I can just disable doc testing on ghc 9.4.1?

@andreabedini
Copy link
Author

At this point doc testing should be done with cabal's new code generators feature e.g. https://github.com/gbaz/cabal-doctest-demo

@andreabedini andreabedini deleted the docspec branch August 30, 2023 10:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants