Skip to content

Commit b0353a1

Browse files
committed
Fix haddock source links by manually cpping
Fixes #81
1 parent 738317a commit b0353a1

File tree

6 files changed

+2187
-16
lines changed

6 files changed

+2187
-16
lines changed

.github/workflows/test.yaml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ jobs:
2020
steps:
2121
- uses: actions/checkout@v2
2222

23+
- name: create ~/.local/bin
24+
run: mkdir -p "$HOME/.local/bin"
25+
shell: bash
26+
27+
- name: Add ~/.local/bin to PATH
28+
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
29+
shell: bash
30+
2331
- if: matrix.os == 'windows-latest'
2432
name: Install ghcup on windows
2533
run: Set-ExecutionPolicy Bypass -Scope Process -Force;[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072;Invoke-Command -ScriptBlock ([ScriptBlock]::Create((Invoke-WebRequest https://www.haskell.org/ghcup/sh/bootstrap-haskell.ps1 -UseBasicParsing))) -ArgumentList $false,$true,$true,$false,$false,$false,$false,"C:\","", "C:\msys64"
@@ -43,6 +51,10 @@ jobs:
4351
run: cabal update
4452
shell: bash
4553

54+
- name: Install cpphs
55+
run: cabal install --installdir="$HOME/.local/bin" --overwrite-policy=always --install-method=copy cpphs
56+
shell: bash
57+
4658
- name: Build
4759
run: cabal build --enable-tests --enable-benchmarks
4860
shell: bash
@@ -55,9 +67,9 @@ jobs:
5567
run: cabal haddock
5668
shell: bash
5769

58-
- name: Generate.hs
70+
- name: Check generation
5971
run: |
60-
runhaskell Generate.hs
72+
make all
6173
git diff --exit-code
6274
shell: bash
6375

Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
all: cpp gen
2+
3+
cpp:
4+
cpphs --noline -DIS_WINDOWS=False -DMODULE_NAME=Posix -OSystem/FilePath/Posix.hs System/FilePath/Internal.hs
5+
cpphs --noline -DIS_WINDOWS=True -DMODULE_NAME=Windows -OSystem/FilePath/Windows.hs System/FilePath/Internal.hs
6+
7+
gen:
8+
runhaskell Generate.hs
9+
10+
.PHONY: all cpp gen

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ The answer for this library is "no". While an abstract `FilePath` has some advan
2020

2121
### Developer notes
2222

23-
Most of the code is in `System/FilePath/Internal.hs` which is `#include`'d into both `System/FilePath/Posix.hs` and `System/FilePath/Windows.hs` with the `IS_WINDOWS` CPP define set to either `True` or `False`. This Internal module is a bit weird in that it isn't really a Haskell module, but is more an include file.
23+
Most of the code is in `System/FilePath/Internal.hs` which is `cpphs`'d into both `System/FilePath/Posix.hs` and `System/FilePath/Windows.hs` via `make cpp` and commited to the repo. This Internal module is a bit weird in that it isn't really a Haskell module, but is more an include file.
2424

2525
The library has extensive doc tests. Anything starting with `-- >` is transformed into a doc test as a predicate that must evaluate to `True`. These tests follow a few rules:
2626

2727
* Tests prefixed with `Windows:` or `Posix:` are only tested against that specific implementation - otherwise tests are run against both implementations.
2828
* Any single letter variable, e.g. `x`, is considered universal quantification, and is checked with `QuickCheck`.
2929
* If `Valid x =>` appears at the start of a doc test, that means the property will only be tested with `x` passing the `isValid` predicate.
3030

31-
The tests can be generated by `Generate.hs` in the root of the repo, and will be placed in `tests/TestGen.hs`. The `TestGen.hs` file is checked into the repo, and the CI scripts check that `TestGen.hs` is in sync with what would be generated a fresh - if you don't regenerate `TestGen.hs` the CI will fail.
31+
The tests can be generated by `make gen` in the root of the repo, and will be placed in `tests/TestGen.hs`. The `TestGen.hs` file is checked into the repo, and the CI scripts check that `TestGen.hs` is in sync with what would be generated a fresh - if you don't regenerate `TestGen.hs` the CI will fail.
3232

3333
The `.ghci` file is set up to allow you to type `ghci` to open the library, then `:go` will regenerate the tests and run them.

System/FilePath.hs

Lines changed: 79 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,90 @@ A library for 'FilePath' manipulations, using Posix or Windows filepaths
1515
depending on the platform.
1616
1717
Both "System.FilePath.Posix" and "System.FilePath.Windows" provide the
18-
same interface. See either for examples and a list of the available
19-
functions.
18+
same interface.
2019
-}
2120

2221

2322
#if defined(mingw32_HOST_OS) || defined(__MINGW32__)
24-
module System.FilePath(module System.FilePath.Windows) where
23+
module System.FilePath(
24+
-- * Separator predicates
25+
FilePath,
26+
pathSeparator, pathSeparators, isPathSeparator,
27+
searchPathSeparator, isSearchPathSeparator,
28+
extSeparator, isExtSeparator,
29+
30+
-- * @$PATH@ methods
31+
splitSearchPath, getSearchPath,
32+
33+
-- * Extension functions
34+
splitExtension,
35+
takeExtension, replaceExtension, (-<.>), dropExtension, addExtension, hasExtension, (<.>),
36+
splitExtensions, dropExtensions, takeExtensions, replaceExtensions, isExtensionOf,
37+
stripExtension,
38+
39+
-- * Filename\/directory functions
40+
splitFileName,
41+
takeFileName, replaceFileName, dropFileName,
42+
takeBaseName, replaceBaseName,
43+
takeDirectory, replaceDirectory,
44+
combine, (</>),
45+
splitPath, joinPath, splitDirectories,
46+
47+
-- * Drive functions
48+
splitDrive, joinDrive,
49+
takeDrive, hasDrive, dropDrive, isDrive,
50+
51+
-- * Trailing slash functions
52+
hasTrailingPathSeparator,
53+
addTrailingPathSeparator,
54+
dropTrailingPathSeparator,
55+
56+
-- * File name manipulations
57+
normalise, equalFilePath,
58+
makeRelative,
59+
isRelative, isAbsolute,
60+
isValid, makeValid
61+
) where
2562
import System.FilePath.Windows
2663
#else
27-
module System.FilePath(module System.FilePath.Posix) where
64+
module System.FilePath(
65+
-- * Separator predicates
66+
FilePath,
67+
pathSeparator, pathSeparators, isPathSeparator,
68+
searchPathSeparator, isSearchPathSeparator,
69+
extSeparator, isExtSeparator,
70+
71+
-- * @$PATH@ methods
72+
splitSearchPath, getSearchPath,
73+
74+
-- * Extension functions
75+
splitExtension,
76+
takeExtension, replaceExtension, (-<.>), dropExtension, addExtension, hasExtension, (<.>),
77+
splitExtensions, dropExtensions, takeExtensions, replaceExtensions, isExtensionOf,
78+
stripExtension,
79+
80+
-- * Filename\/directory functions
81+
splitFileName,
82+
takeFileName, replaceFileName, dropFileName,
83+
takeBaseName, replaceBaseName,
84+
takeDirectory, replaceDirectory,
85+
combine, (</>),
86+
splitPath, joinPath, splitDirectories,
87+
88+
-- * Drive functions
89+
splitDrive, joinDrive,
90+
takeDrive, hasDrive, dropDrive, isDrive,
91+
92+
-- * Trailing slash functions
93+
hasTrailingPathSeparator,
94+
addTrailingPathSeparator,
95+
dropTrailingPathSeparator,
96+
97+
-- * File name manipulations
98+
normalise, equalFilePath,
99+
makeRelative,
100+
isRelative, isAbsolute,
101+
isValid, makeValid
102+
) where
28103
import System.FilePath.Posix
29104
#endif

0 commit comments

Comments
 (0)