-
Notifications
You must be signed in to change notification settings - Fork 237
@since includes package name #749
@since includes package name #749
Conversation
/ cc @hvr |
I figured out the right way to get the package name: I took the liberty to update the comments around When the name of a package cannot be determined (for instance when running Haddock on a standalone test case and without passing Consequently, I propose that we not leave off the package name when in the current package since that would be indistinguishable from the case where the package name could not be determined. |
newtype Meta = Meta { _version :: Maybe Version } deriving (Eq, Show) | ||
data Meta = Meta { _version :: Maybe Version | ||
, _package :: Maybe Package | ||
} deriving (Eq, Show) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alexbiehl I take it this also requires waiting till the next major GHC version, right? Should I move this PR to ghc-head
?
Can we make this controllable via a flag? We already have a precedent for this: a flag for controlling wether to qualify names,
...may make sense here as well. |
If you have an idea for what to specify, sure. Note I already emit a warning if the package name couldn't be determined. In any case, I would be against a flag that just hides this feature. People expect tools to "just do it" and they rarely go digging into options. Just yesterday, I found out about |
@harpocrates the reason I'm asking is, that if I understand it right, the package name can always be determined accurately when running Haddock for Hackage. So in The flag would give us a way to control wether to always prepend the package name (unless it cannot be determined) or only when it can be determined, and the package name doesn't refer to the local package name. The latter would be the mode In other words, the flag isn't about hiding a feature, but rather about controlling it, so that we can accommodate different needs. |
@hvr I understand now, I appreciate the explanation. Stray thought: would it not be preferable for Haddock to have a hard failure when running with this special flag enabled? Anyways we expect cabal to do the right thing and pass the package name, so if something goes wrong, a loud failure could be nice... That way, you know for sure that a since annotation without a package name is not the result of a package name not being resolved. I don't care much either way on this, so I'll implement whatever you prefer. 😄 Also, any naming preferences for such a flag? |
@@ -486,8 +486,13 @@ instance Binary a => Binary (TableCell a) where | |||
return (TableCell i j c) | |||
|
|||
instance Binary Meta where | |||
put_ bh Meta { _version = v } = put_ bh v | |||
get bh = (\v -> Meta { _version = v }) <$> get bh | |||
put_ bh (Meta v p) = do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This changes the Binary
instance. Please also update binaryInterfaceVersion
:
haddock/haddock-api/src/Haddock/InterfaceFile.hs
Lines 84 to 86 in 76d0f9b
binaryInterfaceVersion :: Word16 | |
#if (__GLASGOW_HASKELL__ >= 802) && (__GLASGOW_HASKELL__ < 804) | |
binaryInterfaceVersion = 31 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@@ -33,7 +33,9 @@ import Data.Bitraversable | |||
-- meta-data to comments. We make a structure for this ahead of time | |||
-- so we don't have to gut half the core each time we want to add such | |||
-- info. | |||
newtype Meta = Meta { _version :: Maybe Version } deriving (Eq, Show) | |||
data Meta = Meta { _version :: Maybe Version | |||
, _package :: Maybe Package |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately this is again a breaking change.
@harpocrates well, an obvious name could be |
@hvr This is now done. The |
Good, so we need a |
@alexbiehl yeah, but that one's imho low-prio, and we can if needed have the doc builder use a locally patched version if needed |
@hvr I don't mind making the Cabal change once this gets merged. That's the next big thing I'd like to start hacking on. |
e2e73aa
to
94accd2
Compare
(Alec, I rebased your patches against |
94accd2
to
6c2b52f
Compare
Thanks! I'll fix up the tests in the next couple of days. |
I may end up waiting for rc2 before making tests pass. Right now, I'm running into this issue on my dev machine when running the HTML tests. |
@alexbiehl I'm running into some fundamental problems with the testsuite (beyond having to run everything in an Ubuntu VM). As I understand it, when Should I re-open this against I feel like the "right" thing to do here would be to re-generate the interface files every time we run tests which rely on them, yet that would increase a fair bit the time it takes the tests to run... |
This means that '@SInCE' annotations can be package aware.
This should extract the package name for `@since` annotations the right way. I had to move `modulePackageInfo` around to do this and, in the process, I took the liberty to update it. Since it appears that finding the package name is something that can fail, I added a warning for this case.
Oh, right. There will be a ghc-8.4.2 release soon. I am sure we want to
include the newly themed haddock in there to spread adoption at least for
the core packages, right? Let's put this in then too. Let's wait with the
merge until then.
Alec Theriault <notifications@github.com> schrieb am Mi., 21. März 2018,
20:36:
… @alexbiehl <https://github.com/alexbiehl> I'm running into some
fundamental problems with the testsuite (beyond having to run everything in
an Ubuntu VM).
As I understand it, when html-test runs Haddock, it passes in a bunch of
interface files (for base, array, process, etc.) from the GHC being used.
However, since my changes tweak Meta in (and its Binary instance), I've
had to bump binaryInterfaceVersion, which means that html-test cannot
load in the existing interface files.
Should I re-open this against ghc-head?
I feel like the "right" thing to do here would be to re-generate the
interface files every time we run tests which rely on them, yet that would
increase a fair bit the time it takes the tests to run...
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#749 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AByiid9eJOzzPP0fLdxmCJjYZErK5hThks5tgquugaJpZM4SAD30>
.
|
I am not sure we even can regenerate for base interface files without ghcs
build system.
Alex Biehl <alex.biehl@gmail.com> schrieb am Mi., 21. März 2018, 20:53:
… Oh, right. There will be a ghc-8.4.2 release soon. I am sure we want to
include the newly themed haddock in there to spread adoption at least for
the core packages, right? Let's put this in then too. Let's wait with the
merge until then.
Alec Theriault ***@***.***> schrieb am Mi., 21. März 2018,
20:36:
> @alexbiehl <https://github.com/alexbiehl> I'm running into some
> fundamental problems with the testsuite (beyond having to run everything in
> an Ubuntu VM).
>
> As I understand it, when html-test runs Haddock, it passes in a bunch of
> interface files (for base, array, process, etc.) from the GHC being
> used. However, since my changes tweak Meta in (and its Binary instance),
> I've had to bump binaryInterfaceVersion, which means that html-test
> cannot load in the existing interface files.
>
> Should I re-open this against ghc-head?
>
> I feel like the "right" thing to do here would be to re-generate the
> interface files every time we run tests which rely on them, yet that would
> increase a fair bit the time it takes the tests to run...
>
> —
> You are receiving this because you were mentioned.
>
>
> Reply to this email directly, view it on GitHub
> <#749 (comment)>, or mute
> the thread
> <https://github.com/notifications/unsubscribe-auth/AByiid9eJOzzPP0fLdxmCJjYZErK5hThks5tgquugaJpZM4SAD30>
> .
>
|
As discussed, this is still the usual case (and we should avoid being noisy for it). Although this commit is large, it is basically only about threading a 'Maybe Package' from 'Haddock.render' all the way to 'Haddock.Backends.Xhtml.DocMarkup.renderMeta'.
2670ae1
to
f5b33d4
Compare
Sounds all good to me! |
Alec, it is getting hotter in terms of release approaching. Could you rebase your change one last time? |
This controls when to qualify since annotations with the package they come from. The default is always, but I've left an 'external' variant where only those annotations coming from outside of the current package are qualified.
The @SInCE stuff needs only the package name passed in, so it makes sense to not be forced to pass in a version too.
f5b33d4
to
69e74ea
Compare
Rebased. As soon as this gets merged, I'll update the Cabal side of things. |
For the record: I checked test output and only expected errors happened:
|
* Metadoc stores a package name This means that '@SInCE' annotations can be package aware. * Get the package name the right way This should extract the package name for `@since` annotations the right way. I had to move `modulePackageInfo` around to do this and, in the process, I took the liberty to update it. Since it appears that finding the package name is something that can fail, I added a warning for this case. * Silence warnings * Hide package for local 'since' annotations As discussed, this is still the usual case (and we should avoid being noisy for it). Although this commit is large, it is basically only about threading a 'Maybe Package' from 'Haddock.render' all the way to 'Haddock.Backends.Xhtml.DocMarkup.renderMeta'. * Bump binary interface version * Add a '--since-qual' option This controls when to qualify since annotations with the package they come from. The default is always, but I've left an 'external' variant where only those annotations coming from outside of the current package are qualified. * Make ParserSpec work * Make Fixtures work * Use package name even if package version is not available The @SInCE stuff needs only the package name passed in, so it makes sense to not be forced to pass in a version too.
* Metadoc stores a package name This means that '@SInCE' annotations can be package aware. * Get the package name the right way This should extract the package name for `@since` annotations the right way. I had to move `modulePackageInfo` around to do this and, in the process, I took the liberty to update it. Since it appears that finding the package name is something that can fail, I added a warning for this case. * Silence warnings * Hide package for local 'since' annotations As discussed, this is still the usual case (and we should avoid being noisy for it). Although this commit is large, it is basically only about threading a 'Maybe Package' from 'Haddock.render' all the way to 'Haddock.Backends.Xhtml.DocMarkup.renderMeta'. * Bump binary interface version * Add a '--since-qual' option This controls when to qualify since annotations with the package they come from. The default is always, but I've left an 'external' variant where only those annotations coming from outside of the current package are qualified. * Make ParserSpec work * Make Fixtures work * Use package name even if package version is not available The @SInCE stuff needs only the package name passed in, so it makes sense to not be forced to pass in a version too. (cherry picked from commit 978dbc8)
This changes the rendering of
@since
annotations to include the package that they originated from. This fixes #452 and #550. Here is a snippet of instances from thearray
package which are actually re-exported frombase
. It is now clear that2.1
really is referring to the version ofbase
and notarray
:This is not yet ready to merge:
I noticed something funky when generating the GHC-bundled
stm
docs. I have no idea why, but the package name seems to include the version. Anyone know why?It might be worth trying to leave off the package name when the
@since
annotation is in the current package - I haven't considered this, but it is mentioned in the linked issues