Skip to content

Commit 7468ff0

Browse files
authored
Merge pull request #6737 from commercialhaskell/haddock
Add missing Haddock documentation
2 parents 35af7d1 + 077de6e commit 7468ff0

File tree

6 files changed

+46
-28
lines changed

6 files changed

+46
-28
lines changed

src/Stack/Build/Cache.hs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ writeSetupConfigMod dir (Just x) = do
259259
writeBinaryFileAtomic fp "Just used for its modification time"
260260
liftIO $ setFileTimes (toFilePath fp) x x
261261

262-
-- | See 'tryGetPackageProjectRoot'
262+
-- | See 'tryGetPackageProjectRoot'.
263263
writePackageProjectRoot ::
264264
HasEnvConfig env
265265
=> Path Abs Dir
@@ -288,7 +288,7 @@ flagCacheKey installed = do
288288
Executable ident -> pure $
289289
configCacheKey installationRoot (ConfigCacheTypeFlagExecutable ident)
290290

291-
-- | Loads the flag cache for the given installed extra-deps
291+
-- | Loads the flag cache for the given installed extra-deps.
292292
tryGetFlagCache ::
293293
HasEnvConfig env
294294
=> Installed
@@ -297,6 +297,7 @@ tryGetFlagCache gid = do
297297
key <- flagCacheKey gid
298298
loadConfigCache key
299299

300+
-- | Write the flag cache for the given installed extra-deps.
300301
writeFlagCache ::
301302
HasEnvConfig env
302303
=> Installed

src/Stack/Build/ExecutePackage.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ announceTask ee taskType action = logInfo $
355355
-- * Checks if the package exists in the precompiled cache, and if so, add it to
356356
-- the database instead of performing the build.
357357
--
358-
-- * Runs the configure step if needed ('ensureConfig')
358+
-- * Runs the configure step if needed (@ensureConfig@)
359359
--
360360
-- * Runs the build step
361361
--

src/Stack/Ghci.hs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,10 @@ data GhciPkgDesc = GhciPkgDesc
186186

187187
-- | Type synonym representing maps from a module name to a map with all of the
188188
-- paths that use that name. Each of those paths is associated with a set of
189-
-- components that contain it. The purpose of this complex structure is for use
190-
-- in 'checkForDuplicateModules'.
189+
-- components that contain it.
190+
191+
-- The purpose of this complex structure is for use in
192+
-- 'checkForDuplicateModules'.
191193
type ModuleMap =
192194
Map ModuleName (Map (Path Abs File) (Set (PackageName, NamedComponent)))
193195

src/Stack/Lock.hs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ instance Pretty LockPrettyException where
5757

5858
instance Exception LockPrettyException
5959

60+
-- | Type representing locked locations.
6061
data LockedLocation a b = LockedLocation
6162
{ original :: a
6263
, completed :: b
@@ -90,6 +91,7 @@ instance FromJSON (WithJSONWarnings (Unresolved SingleRPLI)) where
9091
let withWarnings x = WithJSONWarnings x ws
9192
pure $ withWarnings $ SingleRPLI . NE.head <$> unresolvedRPLIs
9293

94+
-- | Type representing the contents of lock files.
9395
data Locked = Locked
9496
{ snapshotLocations :: [LockedLocation RawSnapshotLocation SnapshotLocation]
9597
, pkgImmutableLocations :: [LockedLocation RawPackageLocationImmutable PackageLocationImmutable]
@@ -127,10 +129,14 @@ loadYamlThrow parser path = do
127129
logJSONWarnings (toFilePath path) warnings
128130
pure res
129131

132+
-- | Yields a t'Stack.Types.SourceMap.SMWanted' taking into account the relevant
133+
-- lock file, if one is applicable and it exists.
130134
lockCachedWanted ::
131135
(HasPantryConfig env, HasRunner env)
132136
=> Path Abs File
137+
-- ^ The relevant Stack project-level configuration file.
133138
-> RawSnapshotLocation
139+
-- ^ The relevant snapshot.
134140
-> ( Map RawPackageLocationImmutable PackageLocationImmutable
135141
-> WantedCompiler
136142
-> Map PackageName (Bool -> RIO env DepPackage)

src/Stack/Path.hs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Types and functions related to Stack's @path@ command.
1414

1515
module Stack.Path
1616
( EnvConfigPathInfo
17+
, UseHaddocks
1718
, path
1819
, pathsFromRunner
1920
, pathsFromConfig
@@ -223,9 +224,12 @@ instance HasBuildConfig EnvConfigPathInfo where
223224
buildConfigL =
224225
lens (.buildConfig) (\x y -> x { buildConfig = y }) . buildConfigL
225226

227+
-- | Type representing whether or not building Haddocks is required.
226228
data UseHaddocks a
227229
= UseHaddocks a
230+
-- ^ Building Haddocks is required.
228231
| WithoutHaddocks a
232+
-- ^ Building Haddocks is not required.
229233

230234
-- | The paths of interest to a user which do require a t'Config' or
231235
-- 'EnvConfig'. The first tuple string is used for a description that the

src/Stack/SourceMap.hs

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ module Stack.SourceMap
1616
, getPLIVersion
1717
, loadGlobalHints
1818
, actualFromGhc
19-
, actualFromHints
2019
, globalCondCheck
2120
, pruneGlobals
2221
, globalsFromHints
@@ -39,7 +38,7 @@ import Stack.Constants ( stackProgName' )
3938
import Stack.PackageDump ( conduitDumpPackage, ghcPkgDump )
4039
import Stack.Prelude
4140
import Stack.Types.Compiler
42-
( ActualCompiler, actualToWanted, wantedToActual )
41+
( ActualCompiler, wantedToActual )
4342
import Stack.Types.CompilerPaths
4443
( CompilerPaths (..), GhcPkgExe, HasCompiler (..) )
4544
import Stack.Types.Config ( HasConfig )
@@ -112,6 +111,8 @@ additionalDepPackage buildHaddocks location = do
112111
}
113112
}
114113

114+
-- | Given a t'PackageName' and its t'SnapshotPackage', yields the corresponding
115+
-- t'DepPackage'.
115116
snapToDepPackage ::
116117
forall env. (HasPantryConfig env, HasLogFunc env, HasProcessContext env)
117118
=> Bool
@@ -136,16 +137,22 @@ snapToDepPackage buildHaddocks name sp = do
136137
}
137138
}
138139

140+
-- | For the given t'CommonPackage', load its generic package description and
141+
-- yield its version.
139142
loadVersion :: MonadIO m => CommonPackage -> m Version
140143
loadVersion common = do
141144
gpd <- liftIO common.gpd
142-
pure (pkgVersion $ PD.package $ PD.packageDescription gpd)
145+
pure gpd.packageDescription.package.pkgVersion
143146

147+
-- | For the given t'PackageLocationImmutable', yield the version of the
148+
-- referenced package.
144149
getPLIVersion :: PackageLocationImmutable -> Version
145150
getPLIVersion (PLIHackage (PackageIdentifier _ v) _ _) = v
146151
getPLIVersion (PLIArchive _ pm) = pkgVersion $ pmIdent pm
147152
getPLIVersion (PLIRepo _ pm) = pkgVersion $ pmIdent pm
148153

154+
-- | For the given @ghc-pkg@ executable, yield the contents of the global
155+
-- package database.
149156
globalsFromDump ::
150157
(HasProcessContext env, HasTerm env)
151158
=> GhcPkgExe
@@ -157,21 +164,24 @@ globalsFromDump pkgexe = do
157164
Map.fromList $ map (pkgName . (.packageIdent) &&& id) $ Map.elems ds
158165
toGlobals <$> ghcPkgDump pkgexe [] pkgConduit
159166

167+
-- | For the given wanted compiler, yield the global hints (if available).
160168
globalsFromHints ::
161169
HasConfig env
162170
=> WantedCompiler
163171
-> RIO env (Map PackageName Version)
164-
globalsFromHints compiler = do
165-
mglobalHints <- loadGlobalHints compiler
166-
case mglobalHints of
167-
Just hints -> pure hints
168-
Nothing -> do
172+
globalsFromHints compiler = loadGlobalHints compiler >>= maybe
173+
( do
169174
prettyWarnL
170175
[ flow "Unable to load global hints for"
171176
, fromString $ T.unpack $ textDisplay compiler
172177
]
173178
pure mempty
179+
)
180+
pure
174181

182+
-- | When the environment 'HasCompiler', for the
183+
-- given t'Stack.Types.SourceMap.SMWanted' and 'ActualCompiler', yield
184+
-- a t'SMActual' parameterised by t'DumpedGlobalPackage'.
175185
actualFromGhc ::
176186
(HasConfig env, HasCompiler env)
177187
=> SMWanted
@@ -187,21 +197,6 @@ actualFromGhc smw compiler = do
187197
, globals
188198
}
189199

190-
actualFromHints ::
191-
(HasConfig env)
192-
=> SMWanted
193-
-> ActualCompiler
194-
-> RIO env (SMActual GlobalPackageVersion)
195-
actualFromHints smw compiler = do
196-
globals <- globalsFromHints (actualToWanted compiler)
197-
pure
198-
SMActual
199-
{ compiler
200-
, project = smw.project
201-
, deps = smw.deps
202-
, globals = Map.map GlobalPackageVersion globals
203-
}
204-
205200
-- | Simple cond check for boot packages - checks only OS and Arch
206201
globalCondCheck ::
207202
(HasConfig env)
@@ -214,9 +209,12 @@ globalCondCheck = do
214209
condCheck c = Left c
215210
pure condCheck
216211

212+
-- | Prune the given packages from GHC's global package database.
217213
pruneGlobals ::
218214
Map PackageName DumpedGlobalPackage
215+
-- ^ Packages in GHC's global package database.
219216
-> Set PackageName
217+
-- ^ Package names to prune.
220218
-> Map PackageName GlobalPackage
221219
pruneGlobals globals deps =
222220
let (prunedGlobals, keptGlobals) =
@@ -225,9 +223,12 @@ pruneGlobals globals deps =
225223
in Map.map (GlobalPackage . pkgVersion . (.packageIdent)) keptGlobals <>
226224
Map.map ReplacedGlobalPackage prunedGlobals
227225

226+
-- | Get the output of @ghc --info@ for the compiler in the environment.
228227
getCompilerInfo :: (HasConfig env, HasCompiler env) => RIO env Builder
229228
getCompilerInfo = view $ compilerPathsL . to (byteString . (.ghcInfo))
230229

230+
-- | For the given 'PackageLocationImmutable', yield its 256-bit cryptographic
231+
-- hash.
231232
immutableLocSha :: PackageLocationImmutable -> Builder
232233
immutableLocSha = byteString . treeKeyToBs . locationTreeKey
233234
where
@@ -236,9 +237,13 @@ immutableLocSha = byteString . treeKeyToBs . locationTreeKey
236237
locationTreeKey (PLIRepo _ pm) = pmTreeKey pm
237238
treeKeyToBs (TreeKey (BlobKey sha _)) = SHA256.toHexBytes sha
238239

240+
-- | Type synonym for functions that yield a t'SMActual' parameterised by
241+
-- t'GlobalPackageVersion' for a given list of project package directories.
239242
type SnapshotCandidate env
240243
= [ResolvedPath Dir] -> RIO env (SMActual GlobalPackageVersion)
241244

245+
-- | For the given raw snapshot location, yield a function to yield a
246+
-- t'SMActual' from a list of project package directories.
242247
loadProjectSnapshotCandidate ::
243248
(HasConfig env)
244249
=> RawSnapshotLocation

0 commit comments

Comments
 (0)