Skip to content

Commit a92fb77

Browse files
Add the first documented Stack message
1 parent 26c5c12 commit a92fb77

File tree

9 files changed

+78
-16
lines changed

9 files changed

+78
-16
lines changed

CONTRIBUTING.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,20 @@ To document a new error code, the following workflow can be convenient.
4848

4949
### Task Lists
5050

51-
We keep track of which errors are being worked on, and which still require documentation,
51+
We keep track of which GHC errors are being worked on, and which still require documentation,
5252
using a bunch of issues:
5353

5454
- [All error codes that still need documenting are collected here](https://github.com/haskellfoundation/error-message-index/issues/162). This issue contains links to individual issues for every error, allowing the list to be updated as PRs are merged. These individual issues for every error may also contain helpful links to test cases, suggestions on examples, and useful metadata to a contributor.
5555
- There is also an (incomplete) list of issues tagged `good first issue`; these are errors which are especially good for newer contributors to document (no incredibly esoteric type-level errors that are hard to understand, let alone describe!): https://github.com/haskellfoundation/error-message-index/labels/good%20first%20issue
5656
- Issues related to improving the site, the workflow for contributing, or other information are tagged `error-message-index-site`: https://github.com/haskellfoundation/error-message-index/labels/error-message-index-site
5757
- Issues related to improving, clarifying, or extending existing documentation are tagged `error-message-index-improvements`: https://github.com/haskellfoundation/error-message-index/labels/error-message-index-improvements
5858

59+
## Building Stack with Error Codes
60+
61+
The next release of Stack will also include error codes. Until it is
62+
released, building a Git version (which just requires an existing
63+
install of Stack) is sufficient to get the codes.
64+
5965
## Contributing New Messages
6066

6167
The Haskell Message Index is generated from a collection of files on
@@ -64,8 +70,8 @@ disk using Hakyll. Inside the top-level of the site source, there is a
6470
a message whose name is the message code. This subdirectory contains a
6571
file `index.md` that describes the message. Additionally,
6672
subdirectories of the message directory may represent examples - each
67-
example contains a file `index.md` as well as a number of Haskell
68-
files that represent the example.
73+
example contains a file `index.md` as well as a number of Haskell,
74+
Cabal, or YAML files that represent the example.
6975

7076
A message with ID `GHC-123` and two examples might have the following structure:
7177

@@ -87,10 +93,10 @@ named as specified here, while the other components may vary.
8793
You can also use the `makeFolder.sh` templating script. Usage is as follows:
8894

8995
```bash
90-
./makeFolder.sh <NUMERIC-ERROR-CODE> <HaskellModuleName>
96+
./makeFolder.sh <NAMESPACE>-<NUMERIC_ERROR_CODE> <HaskellModuleName>
9197
```
9298

93-
This will generate a folder called `GHC-NUMERIC_ERROR_CODE` containing an empty `index.md` file, a subfolder called `example1` with a corresponding `index.md`, and two blank `before`/`after` Haskell source files.
99+
This will generate a folder called `NAMESPACE-NUMERIC_ERROR_CODE` containing an empty `index.md` file, a subfolder called `example1` with a corresponding `index.md`, and two blank `before`/`after` Haskell source files. Use `GHC` as `NAMESPACE` to document GHC error messages, and `S` as `NAMESPACE` to document Stack errors.
94100

95101
### Message Descriptions
96102

@@ -133,7 +139,6 @@ field. All `.hs` files are shown in the list of files for the
133139
example. The `index.md` file should explain how the files illustrate
134140
the message.
135141

136-
137142
## Contributing to the Site
138143

139144
The site is generated using [Hakyll](https://jaspervdj.be/hakyll/).
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
resolver: lts-19.17

message-index/messages/S-6602/empty/before/empty.yaml

Whitespace-only changes.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
title: Stack does not accept empty YAML files
3+
---
4+
5+
When run with an empty YAML file, Stack fails to parse it. In particular, `stack --stack-yaml empty.yaml build` results in the error:
6+
```
7+
Error: [S-6602]
8+
Could not parse '/PATH/TO/empty.yaml':
9+
Aeson exception:
10+
Error in $: parsing ProjectAndConfigMonoid failed, expected Object, but encountered Null
11+
See http://docs.haskellstack.org/en/stable/yaml_configuration/
12+
```
13+
14+
This can be fixed by specifying a resolver, which is the minimal `stack.yaml` configuration.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
title: Could not parse YAML configuration file
3+
summary: Test summary
4+
severity: error
5+
introduced: 2.10.0
6+
---
7+
8+
This error occurs when Stack is unable to parse a `stack.yaml` file. The error covers the following situations:
9+
10+
* The specified configuration file does not exist
11+
* The configuration file is not well-formed YAML
12+
* The file is well-formed YAML but does not match the expected data schema
13+
14+
The expected file format is described in [the Stack documentation](https://docs.haskellstack.org/en/stable/yaml_configuration/).
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
resolver: lts-19.17
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
title: Not a YAML file
3+
---
4+
5+
This `stack.yaml` file is not syntactically valid YAML. The error that results from `stack --stack-yaml not.yaml build` is:
6+
```text
7+
Error: [S-6602]
8+
Could not parse '/PATH/TO/not.yaml':
9+
YAML parse exception at line 0, column 0,
10+
while parsing a block node:
11+
did not find expected node content
12+
See http://docs.haskellstack.org/en/stable/yaml_configuration/
13+
```

message-index/site.hs

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@ import qualified Data.Aeson as JSON
88
import qualified Data.Aeson.KeyMap as KM
99
import Data.Binary (Binary)
1010
import Data.Data (Typeable)
11+
import Data.Foldable (for_)
1112
import Data.Functor ((<&>))
1213
import Data.List (find, lookup, nub, sort)
14+
import Data.List.NonEmpty (NonEmpty (..))
15+
import qualified Data.List.NonEmpty as NE
1316
import qualified Data.Map.Strict as Map
1417
import Data.Maybe (fromMaybe, listToMaybe, mapMaybe)
1518
import Data.Monoid (mappend)
@@ -40,14 +43,15 @@ main = hakyll $ do
4043
route idRoute
4144
compile copyFileCompiler
4245

43-
match "messages/*/*/**.hs" $
44-
version "raw" $ do
45-
route idRoute
46-
compile getResourceBody
46+
for_ exampleExtensions $ \ext -> do
47+
match (fromGlob $ "messages/*/*/**." <> ext) $
48+
version "raw" $ do
49+
route idRoute
50+
compile getResourceBody
4751

48-
match "messages/*/*/**.hs" $ do
49-
route idRoute
50-
compile copyFileCompiler
52+
match (fromGlob $ "messages/*/*/**." <> ext) $ do
53+
route idRoute
54+
compile copyFileCompiler
5155

5256
match "messages/*/*/index.md" $
5357
version "nav" $ do
@@ -131,12 +135,16 @@ main = hakyll $ do
131135

132136
-- Needed for flagInfo below
133137
match "warning-sets/warning-sets-9.5.txt" $ do
134-
compile $ getResourceBody
138+
compile getResourceBody
135139

136140
match "templates/*" $ compile templateBodyCompiler
137141

138142
--------------------------------------------------------------------------------
139143

144+
-- | The file extensions to be shown in example lists
145+
exampleExtensions :: NonEmpty String
146+
exampleExtensions = "hs" :| ["yaml", "cabal"]
147+
140148
breadcrumbField :: [Identifier] -> Compiler (Context String)
141149
breadcrumbField idents =
142150
(messageTitleField <>) . breadcrumbCtx <$> traverse (load @String . setVersion (Just "nav")) idents
@@ -185,8 +193,13 @@ getExampleFiles = do
185193
["messages", id, exampleName, _mdFile] -> pure (id, exampleName)
186194
_ -> fail "Not processing an example"
187195

188-
before <- loadAll (fromGlob ("messages/" <> id <> "/" <> exampleName <> "/before/*.hs") .&&. hasVersion "raw")
189-
after <- loadAll (fromGlob ("messages/" <> id <> "/" <> exampleName <> "/after/*.hs") .&&. hasVersion "raw")
196+
let beforePattern = foldl1 (.||.) $ exampleExtensions <&> \ext ->
197+
fromGlob ("messages/" <> id <> "/" <> exampleName <> "/before/*." <> ext)
198+
afterPattern = foldl1 (.||.) $ exampleExtensions <&> \ext ->
199+
fromGlob ("messages/" <> id <> "/" <> exampleName <> "/after/*." <> ext)
200+
201+
before <- loadAll (beforePattern .&&. hasVersion "raw")
202+
after <- loadAll (afterPattern .&&. hasVersion "raw")
190203
let allNames = sort $ nub $ map (takeFileName . toFilePath . itemIdentifier) $ before ++ after
191204
pure $
192205
[ Item

0 commit comments

Comments
 (0)