-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d6fdde5
commit 6f60796
Showing
3 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: nix-haddock-linux | ||
|
||
# If you need to debug this action, use following action. | ||
# on: [push, pull_request] | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: cachix/install-nix-action@v7 | ||
- name: Setup repo | ||
- name: Build | ||
run: | | ||
nix-env -i cachix | ||
cachix use tycho01 | ||
nix-build -A synthesis-docs | ||
pwd | ||
find result/ |head | ||
mkdir public | ||
cp -r ./result/share/doc/* public/ | ||
- name: Deploy | ||
if: github.event_name == 'push' && github.ref == 'refs/heads/master' | ||
uses: peaceiris/actions-gh-pages@v3 | ||
with: | ||
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }} | ||
# personal_token: ${{ secrets.PERSONAL_TOKEN }} | ||
# github_token: ${{ secrets.GITHUB_TOKEN }} | ||
publish_dir: ./public |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
{ runCommand, lib, haskellPackages }: | ||
{ hspkgs # Haskell packages to make documentation for. Only those with a "doc" output will be used. | ||
# Note: we do not provide arbitrary additional Haddock options, as these would not be | ||
# applied consistently, since we're reusing the already built Haddock for the packages. | ||
, prologue ? null # Optionally, a file to be used for the Haddock "--prologue" option. | ||
}: | ||
let | ||
hsdocs = builtins.map (x: x.doc) (builtins.filter (x: x ? doc) hspkgs); | ||
in runCommand "haddock-join" { buildInputs = [ hsdocs ]; } '' | ||
# Merge all the docs from the packages. We don't use symlinkJoin because: | ||
# - We are going to want to redistribute this, so we don't want any symlinks. | ||
# - We want to be selective about what we copy (we don't need the hydra | ||
# tarballs from the other packages, for example. | ||
mkdir -p "$out/share/doc" | ||
for pkg in ${lib.concatStringsSep " " hsdocs}; do | ||
cp -R $pkg/share/doc/* "$out/share/doc" | ||
done | ||
# We're going to sed all the files so they'd better be writable! | ||
chmod -R +w $out/share/doc | ||
# We're now going to rewrite all the pre-generated Haddock HTML output | ||
# so that links point to the appropriate place within our combined output, | ||
# rather than into the store. | ||
root=$out/share/doc | ||
for f in $(find $out -name "*.html"); do | ||
# Replace all links to the docs we're processing with relative links | ||
# to the root of the doc directory we're creating - the rest of the link is | ||
# the same. | ||
# Also, it's not a a file:// link now because it's a relative URL instead | ||
# of an absolute one. | ||
relpath=$(realpath --relative-to=$(dirname $f) --no-symlinks $root) | ||
pkgsRegex="${"file://(" + (lib.concatStringsSep "|" hsdocs) + ")/share/doc"}" | ||
sed -i -r "s,$pkgsRegex,$relpath,g" "$f" | ||
# Now also replace the index/contents links so they point to (what will be) | ||
# the combined ones instead. | ||
# Match the enclosing quotes to make sure the regex for index.html doesn't also match | ||
# the trailing part of doc-index.html | ||
sed -i -r "s,\"index\.html\",\"$relpath/share/doc/index.html\",g" "$f" | ||
sed -i -r "s,\"doc-index\.html\",\"$relpath/share/doc/doc-index.html\",g" "$f" | ||
done | ||
# Move to the docdir. We do this so that we can give relative docpaths to | ||
# Haddock so it will generate relative (relocatable) links in the index. | ||
cd $out/share/doc | ||
# Collect all the interface files and their docpaths (in this case | ||
# we can just use the enclosing directory). | ||
interfaceOpts=() | ||
for interfaceFile in $(find . -name "*.haddock"); do | ||
docdir=$(dirname $interfaceFile) | ||
interfaceOpts+=("--read-interface=$docdir,$interfaceFile") | ||
done | ||
# Generate the contents and index | ||
${haskellPackages.ghc}/bin/haddock \ | ||
--gen-contents \ | ||
--gen-index \ | ||
${lib.optionalString (prologue != null) "--prologue ${prologue}"} \ | ||
"''${interfaceOpts[@]}" | ||
'' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters