-
Notifications
You must be signed in to change notification settings - Fork 689
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 extra-html-files, for installing extra html files #1182
Conversation
For example, you might have an images/ directory in your project, with images that you refer to from Haddock with: <<images/foo.png>> Then in your Cabal file you would include: extra-html-files: images/*.png And these would both be packaged by sdist, and "cabal haddock" will install them in: ~/.cabal/share/doc/PROJECT/html/images/*.png Fixes #1167
@@ -223,7 +225,7 @@ prepareTree verbosity pkg_descr0 mb_lbi distPref targetDir pps = do | |||
|
|||
when (not (null (licenseFile pkg_descr))) $ | |||
copyFileTo verbosity targetDir (licenseFile pkg_descr) | |||
flip mapM_ (extraSrcFiles pkg_descr) $ \ fpath -> do | |||
flip mapM_ (extraSrcFiles pkg_descr ++ extraHtmlFiles pkg_descr) $ \ fpath -> 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.
forM_ maybe?
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.
I certainly think forM_ is better there too, I just tried to keep the change as minimal as possible.
Can you also update the users' guide? |
let dir = takeDirectory (flat_htmldir </> "html") | ||
InstallDirs { htmldir = flat_htmldir } = | ||
absoluteInstallDirs pkg_descr lbi NoCopyDest | ||
-- sequence_ [ do copyFileTo verbosity dir file | file <- files ] |
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.
Do you need this comment?
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.
No, I only put it in there because it matches how similar constructions are done elsewhere in the code, so I thought the project author may prefer that version for consistency. I think the forM_ usage is clearer, but sometimes people prefer uniformity everywhere.
I'll update the user's guide too, remove the comment, and change the flip mapM_. |
Updated. |
I did a quick test, and it seems to work incorrectly: |
@@ -219,6 +220,13 @@ haddock pkg_descr lbi suffixes flags = do | |||
lbi isVersion2 bi (commonArgs `mappend` exeArgs) | |||
runHaddock verbosity keepTempFiles confHaddock exeArgs' | |||
_ -> return () | |||
|
|||
flip mapM_ (extraHtmlFiles pkg_descr) $ \ fpath -> 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.
Looks like you forgot this one.
I didn't really want to get into making extraneous code revisions, but I've changed a few more |
What about my previous comment? |
Ah, somehow I missed that one. I'll get that fixed. |
Ok, it is now fix and uses the proper mechanism for installing locally and into ~/.cabal. The new code is actually quite a bit simpler than before, which is a good sign. |
Sorry for the delay, I was travelling and had no Internet access. I will take a look at the patch soon. |
@23Skidoo Thanks, for the update! I'm hoping this can make it into 1.17, as I know a few people who have been wanting something similar to this. |
+1 for getting this merged and released soon! |
I've now tested it and it seems to work. Code also looks good to me. Minor issue: if I set @tibbe, @dcoutts - I think this is ready to be merged, are you OK with the naming ( |
Yes, that was the intended behavior, since otherwise we have to deal with complicated rules about prefix stripping. Whatever the file's relative path within their project, is the relative path they should use to refer to the image within their Haddock link. That makes it all pretty straightforward. |
I'm going to merge this in if no-one protests. |
Add extra-html-files, for installing extra html files
For example, you might have an images/ directory in your project, with
images that you refer to from Haddock with:
Then in your Cabal file you would include:
And these would both be packaged by sdist, and "cabal haddock" will
install them in:
Fixes #1167