-
Notifications
You must be signed in to change notification settings - Fork 843
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
stack haddock --haddock-for-hackage #6270
Comments
@pbrisbin, thanks for reporting. I'll look into this, but it is part of Stack that I have not previously investigated, so please bear with me. |
@pbrisbin, while looking into the background to this, I identified: https://hackage.haskell.org/package/standalone-haddock. Beyond its description, I've not looked at it further. Mentioning it in case it is of immediate assistance. |
That does look super useful, thanks! |
Notes for myself: First, looking at what Cabal (the library) does, flags = case haddockTarget of
ForDevelopment -> flags'
ForHackage -> flags'
{ haddockHoogle = Flag True
, haddockHtml = Flag True
, haddockHtmlLocation = Flag (pkg_url ++ "/docs")
, haddockContents = Flag (toPathTemplate pkg_url)
, haddockLinkedSource = Flag True
, haddockQuickJump = Flag True
}
pkg_url = "/package/$pkg-$version"
htmlTemplate = fmap toPathTemplate . flagToMaybe . haddockHtmlLocation
$ flags Also: fromFlags :: PathTemplateEnv -> HaddockFlags -> HaddockArgs
fromFlags env flags =
mempty {
...
argLinkSource = if fromFlag (haddockLinkedSource flags)
then Flag ("src/%{MODULE/./-}.html"
,"src/%{MODULE/./-}.html#%{NAME}"
,"src/%{MODULE/./-}.html#line-%{LINE}")
else NoFlag,
argLinkedSource = haddockLinkedSource flags,
argQuickJump = haddockQuickJump flags,
...
argContents = fmap (fromPathTemplate . substPathTemplate env)
(haddockContents flags),
...
argOutput =
Flag $ case [ Html | Flag True <- [haddockHtml flags] ] ++
[ Hoogle | Flag True <- [haddockHoogle flags] ]
of [] -> [ Html ]
os -> os,
...
} Also: getInterfaces :: Verbosity
-> LocalBuildInfo
-> ComponentLocalBuildInfo
-> Maybe PathTemplate -- ^ template for HTML location
-> IO HaddockArgs
getInterfaces verbosity lbi clbi htmlTemplate = do
(packageFlags, warnings) <- haddockPackageFlags verbosity lbi clbi htmlTemplate
traverse_ (warn (verboseUnmarkOutput verbosity)) warnings
return $ mempty {
argInterfaces = packageFlags
} Also (Stack does not support Haddock before version 2.17.2): renderPureArgs :: Version -> Compiler -> Platform -> HaddockArgs -> [String]
renderPureArgs version comp platform args = concat
[ ...
, [ "--quickjump" | isVersion 2 19
, _ <- flagToList . argQuickJump $ args ]
, [ "--hyperlinked-source" | isVersion 2 17
, True <- flagToList . argLinkedSource $ args ]
...
, maybe [] (\(m,e,l) ->
["--source-module=" ++ m
,"--source-entity=" ++ e]
++ if isVersion 2 14 then ["--source-entity-line=" ++ l]
else []
) . flagToMaybe . argLinkSource $ args
...
, maybe [] ((:[]) . ("--use-contents="++)) . flagToMaybe . argContents $ args
...
, map (\o -> case o of Hoogle -> "--hoogle"; Html -> "--html")
. fromFlagOrDefault [] . argOutput $ args
, renderInterfaces . argInterfaces $ args
...
]
where
renderInterfaces = map renderInterface
renderInterface :: (FilePath, Maybe FilePath, Maybe FilePath, Visibility) -> String
renderInterface (i, html, hypsrc, visibility) = "--read-interface=" ++
(intercalate "," $ concat [ [ fromMaybe "" html ]
, -- only render hypsrc path if html path
-- is given and hyperlinked-source is
-- enabled
[ case (html, hypsrc) of
(Nothing, _) -> ""
(_, Nothing) -> ""
(_, Just x) | isVersion 2 17
, fromFlagOrDefault False . argLinkedSource $ args
-> x
| otherwise
-> ""
]
, if haddockSupportsVisibility
then [ case visibility of
Visible -> "visible"
Hidden -> "hidden"
]
else []
, [ i ]
])
isVersion major minor = version >= mkVersion [major,minor] |
Further notes for myself: Working through the above, I think I have the following Haddock flags and options:
|
For Stack, this seems to me to involve
|
Cabal (the library) has a couple of (minor) issues with |
Re #6270 Step 1, provide `--haddock-for-hackage`
Re #6270 Step 3, create archive files of Haddock documentation
Also adds a manual Cabal flag `disable-stack-upload` to `package.yaml`, to facilitate the debugging of `stack upload`.
Also adds a manual Cabal flag `disable-stack-upload` to `package.yaml`, to facilitate the debugging of `stack upload`.
Re #6270 Step 4 Upload document archive to Hackage
@pbrisbin, there is some tidying up to do around the edges, but the I've tested it on Stack itself, as follows: Hackage could not build Haddock documentation for
With the
and, now, The 'latest' version of the online help is updated: https://docs.haskellstack.org/en/latest/build_command/#-no-haddock-for-haddock-flag and https://docs.haskellstack.org/en/latest/build_command/#-no-haddock-for-haddock-flag. |
Thanks @mpilgrem! The docs on Hackage for 2.13.1 look correct in the ways a naive |
Re #6270 Step 5 Improve stack upload error messages
Re #6270 Fix `--haddock-arguments` with `--haddock-for-hackage`
Hi @mpilgrem I think there may be a bug with On our CI, with an un-cached build, we run the following step: stack --stack-yaml stack.yaml --no-terminal build --test --no-run-tests --dependencies-only --haddock --haddock-for-hackage This fails at the very end, after finishing up for the last dependency:
It seems like it's trying to do something related to the eventual docs, but since we're only doing the dependency docs, that archive is not there (yet). Due to the quirks of stack --stack-yaml stack.yaml --no-terminal build --test --no-run-tests --haddock --haddock-for-hackage This works fine, since it builds the app docs to, which I guess it'll need at the end:
I'll admit I'm not exactly sure how doing Haddocks changes the notion of building and caching dependencies in their own step, it truly seems to build the world no matter what I do anyway, so please let me know if this is operator error. |
@pbrisbin, thanks for the report. I think the problem is this: Haddock documentation gets built for each package and then, at the end of the build, it all gets pulled together. In the case of Haddock |
Thanks for the quick response! |
I've spent the better part of two days trying to manually upload haddocks to Hackage (they won't build there due to a system library dependency). I've arrived at a state where:
stack haddock
can build complete, locally browse-able documentation successfully, but it cannot build in a way suitable for publishing to Hackage (if this is wrong, please-please correct me!)cabal haddock
can build documentation meant for Hackage, but it cannot build my project's dependencies documentation (due to aquickjump
-related bug) so what it publishes is missing effectively all linksTherefore, I would love to see
stack haddock
reach feature-parity withcabal haddock --haddock-for-hackage
, so I could solve the first point and stop fighting with the second.As far as I can tell,
--haddock-for-hackage
does a number of things. Some of them I could accomplish externally with the docs afterstack haddock
produces them, but others I cannot.The things
cabal haddock --haddock-for-hackage
does, that I can't seem to make happen by any means are:/package/$pkg-$version
)The things
cabal haddock --haddock-for-hackage
does, that I could make happen externally, but ideally wouldn't have to are:A correctly-structured, and correctly compressed
<package>-<version>-docs.tar.gz
file is created<package>-<version>-docs
that contains only the package's docstar
) compressed with--format=ustar
And lastly,
cabal upload --publish --documentation <archive>
handles the authorizedPUT
to/package/<package>-<version>/docs
to actually publish them, which is another thing I could handle externally, but would be ideal forstack upload
to know how to do.As mentioned, I've been fighting with this, so I have some details that might be useful for investigating this:
The
--haddock-for-hackage
option implies at least:--haddock-hyperlinked-source
--haddock-html-location='/package/$pkg-$version
--haddock-content-location='/package/$pkg-$version
--haddock-quickjump
--haddock-preamble=?I'm not sure?
It's hard to exactly trace through the Cabal code, but the
--x-location
options are key, and are particularly hard (impossible?) for me to accomplish any way besides usingcabal haddock
, as it seems to end up interacting with an isolated package registry in order to locate the dependencies in order to construct by-dependency options to pass tohaddock
telling it where each thing is. In other words,stack haddock
kind of has to do it for me.The text was updated successfully, but these errors were encountered: