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

Fix servant-docs code sample in README #1335

Merged
merged 2 commits into from
Sep 3, 2020

Conversation

szg251
Copy link
Contributor

@szg251 szg251 commented Sep 2, 2020

I found a few problems in the code sample of servant-docs, so I fixed them for later users:

  • toSample function no longer exists
  • DocQueryParam needs a ParamKind argument
  • RQBody should be ReqBody
  • added implicit imports for better readability

Related issue:
#1212

@fisx
Copy link
Member

fisx commented Sep 2, 2020

Thanks! I opened an issue that takes this yet a little further: #1336

I was going to merge this PR as a good step in the right direction, but when I copied your Main.hs over the example file:

example/greet.hs:87:13: error:
    • No instance for (Servant.Docs.Internal.HasDocs
                         (Servant.API.Verbs.Verb
                            'http-types-0.12.3:Network.HTTP.Types.Method.DELETE 200 '[] ()))
        arising from a use of ‘docs’
    • In the expression: docs testApi
      In an equation for ‘greetDocs’: greetDocs = docs testApi
   |
87 | greetDocs = docs testApi

What commit did you test this against?

@szg251
Copy link
Contributor Author

szg251 commented Sep 3, 2020

I am sorry, I didn't notice that! My IDE auto-formatted the code, but I didn't want to introduce more changes than necessary, so I removed the format related changes, that's when these lines must have slipped out of existence.

I guess the real goal here would be to have running examples somewhere in the repository, and then testing them, and generating README based on them in CI. Is that a good solution? (I am still relatively inexperienced with OSS and library development)

@fisx
Copy link
Member

fisx commented Sep 3, 2020

I guess the real goal here would be to have running examples somewhere in the repository, and then testing them, and generating README based on them in CI. Is that a good solution?

Yes, that's what I was trying to suggest in #1336. I think it may be as simple as copying the code from the README.md to the existing eamples/greet.hs, but I haven't looked at it in details. When I tried, the diff looked non-trivial.

Anyway, your readme compiles and runs, the one from master doesn't, so this is an improvement. :)

If you like, you can give #1336 a shot now, or any time.

Thanks for the fix!

@fisx fisx merged commit e3a29ad into haskell-servant:master Sep 3, 2020
@szg251 szg251 deleted the servant-docs-readme branch September 3, 2020 05:38
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.

2 participants