Skip to content

Commit 6953972

Browse files
authored
Merge pull request #10941 from haskell/haddocks-for-autogen
Add Haddock documentation to Cabal's autogen modules
2 parents 7e0f040 + 1a7fb5d commit 6953972

File tree

5 files changed

+153
-5
lines changed

5 files changed

+153
-5
lines changed

Cabal/src/Distribution/Simple/Build/PackageInfoModule/Z.hs

+23
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,23 @@ render z_root = execWriter $ do
2424
return ()
2525
tell "{-# OPTIONS_GHC -Wno-missing-import-lists #-}\n"
2626
tell "{-# OPTIONS_GHC -w #-}\n"
27+
tell "\n"
28+
tell "{-|\n"
29+
tell "Module : PackageInfo_"
30+
tell (zPackageName z_root)
31+
tell "\n"
32+
tell "Description : Contents of some of the package's Cabal file's fields.\n"
33+
tell "\n"
34+
tell "WARNING: This module was generated by Cabal. Any modifications will be\n"
35+
tell "overwritten if the module is regenerated.\n"
36+
tell "\n"
37+
tell "This module exports values that record information from some of the fields of\n"
38+
tell "the package's Cabal package description file (Cabal file).\n"
39+
tell "\n"
40+
tell "For further information about the fields in a Cabal file, see the Cabal User\n"
41+
tell "Guide.\n"
42+
tell "-}\n"
43+
tell "\n"
2744
tell "module PackageInfo_"
2845
tell (zPackageName z_root)
2946
tell " (\n"
@@ -37,23 +54,29 @@ render z_root = execWriter $ do
3754
tell "import Data.Version (Version(..))\n"
3855
tell "import Prelude\n"
3956
tell "\n"
57+
tell "-- |The content of the @name@ field of the package's Cabal file, but with any\n"
58+
tell "-- hyphen characters replaced by underscore characters.\n"
4059
tell "name :: String\n"
4160
tell "name = "
4261
tell (show $ zPackageName z_root)
4362
tell "\n"
63+
tell "-- |The content of the @version@ field of the package's Cabal file.\n"
4464
tell "version :: Version\n"
4565
tell "version = Version "
4666
tell (zVersionDigits z_root)
4767
tell " []\n"
4868
tell "\n"
69+
tell "-- |The content of the @synopsis@ field of the package's Cabal file.\n"
4970
tell "synopsis :: String\n"
5071
tell "synopsis = "
5172
tell (show $ zSynopsis z_root)
5273
tell "\n"
74+
tell "-- |The content of the @copyright@ field of the package's Cabal file.\n"
5375
tell "copyright :: String\n"
5476
tell "copyright = "
5577
tell (show $ zCopyright z_root)
5678
tell "\n"
79+
tell "-- |The content of the @homepage@ field of the package's Cabal file.\n"
5780
tell "homepage :: String\n"
5881
tell "homepage = "
5982
tell (show $ zHomepage z_root)

Cabal/src/Distribution/Simple/Build/PathsModule/Z.hs

+66-1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,25 @@ render z_root = execWriter $ do
5353
return ()
5454
tell "{-# OPTIONS_GHC -Wno-missing-import-lists #-}\n"
5555
tell "{-# OPTIONS_GHC -w #-}\n"
56+
tell "\n"
57+
tell "{-|\n"
58+
tell "Module : Paths_"
59+
tell (zManglePkgName z_root (zPackageName z_root))
60+
tell "\n"
61+
tell "Description : Data file location, and package version and installation\n"
62+
tell " directories.\n"
63+
tell "\n"
64+
tell "WARNING: This module was generated by Cabal. Any modifications will be\n"
65+
tell "overwritten if the module is regenerated.\n"
66+
tell "\n"
67+
tell "This module exports a function to locate data files, and values that record\n"
68+
tell "the version of the package and some directories which the package has been\n"
69+
tell "configured to be installed into.\n"
70+
tell "\n"
71+
tell "For further information about Cabal's options for its configuration step, and\n"
72+
tell "their default values, see the Cabal User Guide.\n"
73+
tell "-}\n"
74+
tell "\n"
5675
tell "module Paths_"
5776
tell (zManglePkgName z_root (zPackageName z_root))
5877
tell " (\n"
@@ -101,17 +120,63 @@ render z_root = execWriter $ do
101120
tell "catchIO = Exception.catch\n"
102121
return ()
103122
tell "\n"
123+
tell "-- |The package version.\n"
104124
tell "version :: Version\n"
105125
tell "version = Version "
106126
tell (zVersionDigits z_root)
107127
tell " []\n"
108128
tell "\n"
129+
tell "-- |If the argument is a filename, the result is the name of a corresponding\n"
130+
tell "-- file on the system on which the program is running, if the file were listed\n"
131+
tell "-- in the @data-files@ field of the package's Cabal package description file.\n"
132+
tell "-- No check is performed that the given filename is listed in that field.\n"
109133
tell "getDataFileName :: FilePath -> IO FilePath\n"
110134
tell "getDataFileName name = do\n"
111135
tell " dir <- getDataDir\n"
112136
tell " return (dir `joinFileName` name)\n"
113137
tell "\n"
114-
tell "getBinDir, getLibDir, getDynLibDir, getDataDir, getLibexecDir, getSysconfDir :: IO FilePath\n"
138+
tell "-- |The location of the directory specified by Cabal's @--bindir@ option (where\n"
139+
tell "-- executables that the user might invoke are installed). This can be overridden\n"
140+
tell "-- at runtime using the environment variable "
141+
tell (zManglePkgName z_root (zPackageName z_root))
142+
tell "_bindir.\n"
143+
tell "getBinDir :: IO FilePath\n"
144+
tell "\n"
145+
tell "-- |The location of the directory specified by Cabal's @--libdir@ option (where\n"
146+
tell "-- object libraries are installed). This can be overridden at runtime using the\n"
147+
tell "-- environment variable "
148+
tell (zManglePkgName z_root (zPackageName z_root))
149+
tell "_libdir.\n"
150+
tell "getLibDir :: IO FilePath\n"
151+
tell "\n"
152+
tell "-- |The location of the directory specified by Cabal's @--dynlibdir@ option\n"
153+
tell "-- (where dynamic libraries are installed). This can be overridden at runtime\n"
154+
tell "-- using the environment variable "
155+
tell (zManglePkgName z_root (zPackageName z_root))
156+
tell "_dynlibdir.\n"
157+
tell "getDynLibDir :: IO FilePath\n"
158+
tell "\n"
159+
tell "-- |The location of the directory specified by Cabal's @--datadir@ option (where\n"
160+
tell "-- architecture-independent data files are installed). This can be overridden at\n"
161+
tell "-- runtime using the environment variable "
162+
tell (zManglePkgName z_root (zPackageName z_root))
163+
tell "_datadir.\n"
164+
tell "getDataDir :: IO FilePath\n"
165+
tell "\n"
166+
tell "-- |The location of the directory specified by Cabal's @--libexedir@ option\n"
167+
tell "-- (where executables that are not expected to be invoked directly by the user\n"
168+
tell "-- are installed). This can be overridden at runtime using the environment\n"
169+
tell "-- variable "
170+
tell (zManglePkgName z_root (zPackageName z_root))
171+
tell "_libexedir.\n"
172+
tell "getLibexecDir :: IO FilePath\n"
173+
tell "\n"
174+
tell "-- |The location of the directory specified by Cabal's @--sysconfdir@ option\n"
175+
tell "-- (where configuration files are installed). This can be overridden at runtime\n"
176+
tell "-- using the environment variable "
177+
tell (zManglePkgName z_root (zPackageName z_root))
178+
tell "_sysconfdir.\n"
179+
tell "getSysconfDir :: IO FilePath\n"
115180
tell "\n"
116181
let
117182
z_var0_function_defs = do

changelog.d/pr-10941

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
synopsis: "Haddock documentation added to Paths_pkgname and PackageInfo_pkgname modules"
3+
packages: [Cabal]
4+
prs: 10941
5+
---
6+
7+
The automatically-generated modules `Paths_pkgname` and `PackageInfo_pkgname`
8+
now include Haddock documentation.

doc/cabal-package-description-file.rst

+4-3
Original file line numberDiff line numberDiff line change
@@ -3083,9 +3083,10 @@ modules of the package. This module defines a function
30833083
30843084
getDataFileName :: FilePath -> IO FilePath
30853085
3086-
If the argument is a filename listed in the :pkg-field:`data-files` field, the
3087-
result is the name of the corresponding file on the system on which the
3088-
program is running.
3086+
If the argument is a filename, the result is the name of a corresponding file on
3087+
the system on which the program is running, if the filename were listed in the
3088+
:pkg-field:`data-files` field. No check is performed that the given filename is
3089+
listed in that field.
30893090

30903091
.. Note::
30913092

templates/Paths_pkg.template.hs

+52-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,23 @@
1414
{% endif %}
1515
{-# OPTIONS_GHC -Wno-missing-import-lists #-}
1616
{-# OPTIONS_GHC -w #-}
17+
18+
{-|
19+
Module : Paths_{{ manglePkgName packageName }}
20+
Description : Data file location, and package version and installation
21+
directories.
22+
23+
WARNING: This module was generated by Cabal. Any modifications will be
24+
overwritten if the module is regenerated.
25+
26+
This module exports a function to locate data files, and values that record
27+
the version of the package and some directories which the package has been
28+
configured to be installed into.
29+
30+
For further information about Cabal's options for its configuration step, and
31+
their default values, see the Cabal User Guide.
32+
-}
33+
1734
module Paths_{{ manglePkgName packageName }} (
1835
version,
1936
getBinDir, getLibDir, getDynLibDir, getDataDir, getLibexecDir,
@@ -52,15 +69,49 @@ catchIO :: IO a -> (Exception.IOException -> IO a) -> IO a
5269
catchIO = Exception.catch
5370
{% endif %}
5471

72+
-- |The package version.
5573
version :: Version
5674
version = Version {{ versionDigits }} []
5775

76+
-- |If the argument is a filename, the result is the name of a corresponding
77+
-- file on the system on which the program is running, if the file were listed
78+
-- in the @data-files@ field of the package's Cabal package description file.
79+
-- No check is performed that the given filename is listed in that field.
5880
getDataFileName :: FilePath -> IO FilePath
5981
getDataFileName name = do
6082
dir <- getDataDir
6183
return (dir `joinFileName` name)
6284

63-
getBinDir, getLibDir, getDynLibDir, getDataDir, getLibexecDir, getSysconfDir :: IO FilePath
85+
-- |The location of the directory specified by Cabal's @--bindir@ option (where
86+
-- executables that the user might invoke are installed). This can be overridden
87+
-- at runtime using the environment variable {{ manglePkgName packageName }}_bindir.
88+
getBinDir :: IO FilePath
89+
90+
-- |The location of the directory specified by Cabal's @--libdir@ option (where
91+
-- object libraries are installed). This can be overridden at runtime using the
92+
-- environment variable {{ manglePkgName packageName }}_libdir.
93+
getLibDir :: IO FilePath
94+
95+
-- |The location of the directory specified by Cabal's @--dynlibdir@ option
96+
-- (where dynamic libraries are installed). This can be overridden at runtime
97+
-- using the environment variable {{ manglePkgName packageName }}_dynlibdir.
98+
getDynLibDir :: IO FilePath
99+
100+
-- |The location of the directory specified by Cabal's @--datadir@ option (where
101+
-- architecture-independent data files are installed). This can be overridden at
102+
-- runtime using the environment variable {{ manglePkgName packageName }}_datadir.
103+
getDataDir :: IO FilePath
104+
105+
-- |The location of the directory specified by Cabal's @--libexedir@ option
106+
-- (where executables that are not expected to be invoked directly by the user
107+
-- are installed). This can be overridden at runtime using the environment
108+
-- variable {{ manglePkgName packageName }}_libexedir.
109+
getLibexecDir :: IO FilePath
110+
111+
-- |The location of the directory specified by Cabal's @--sysconfdir@ option
112+
-- (where configuration files are installed). This can be overridden at runtime
113+
-- using the environment variable {{ manglePkgName packageName }}_sysconfdir.
114+
getSysconfDir :: IO FilePath
64115

65116
{% defblock function_defs %}
66117
minusFileName :: FilePath -> String -> FilePath

0 commit comments

Comments
 (0)