From 4b3eee83dfdcd2bd9027037ce0d46b527805c5a6 Mon Sep 17 00:00:00 2001
From: Beat Hagenlocher
Date: Sun, 13 Oct 2024 14:09:36 +0200
Subject: [PATCH] Add subsites for Cabal, GHC, GHCup and stack (#545)
* Add subsites for Cabal, GHC, GHCup and stack
Fixes #378
* Add missing eof newline
* Make ormolu happy
* Add links to README
---
README.md | 12 +++----
message-index/cabal/index.html | 27 +++++++++++++++
message-index/ghc/index.html | 27 +++++++++++++++
message-index/ghcup/index.html | 27 +++++++++++++++
message-index/index.html | 47 +--------------------------
message-index/site.hs | 41 +++++++++++++----------
message-index/stack/index.html | 27 +++++++++++++++
message-index/templates/messages.html | 39 +++++++++++++++++++++-
8 files changed, 177 insertions(+), 70 deletions(-)
create mode 100644 message-index/cabal/index.html
create mode 100644 message-index/ghc/index.html
create mode 100644 message-index/ghcup/index.html
create mode 100644 message-index/stack/index.html
diff --git a/README.md b/README.md
index 11297d33..6dd41ed1 100644
--- a/README.md
+++ b/README.md
@@ -9,12 +9,12 @@ Haskell tooling emits a variety of errors, warnings, and other messages. In rece
Today, the Haskell Message Index supports three tools. Any user-facing Haskell-related programming tools are welcome to join the effort!
-| Tool | Earliest supported version | Namespace |
-|-------|----------------------------|-----------|
-| GHC | 9.6.1 | `GHC-` |
-| Stack | 2.9.3 | `S-` |
-| GHCup | 0.1.19.0 | `GHCup-` |
-| Cabal | 3.12 | `Cabal-` |
+| Tool | Earliest supported version | Namespace | Link to subpage |
+|-------|----------------------------|-----------|-----------------|
+| GHC | 9.6.1 | `GHC-` | [/ghc](https://errors.haskell.org/ghc) |
+| Stack | 2.9.3 | `S-` | [/stack](https://errors.haskell.org/stack) |
+| GHCup | 0.1.19.0 | `GHCup-` | [/ghcup](https://errors.haskell.org/ghcup) |
+| Cabal | 3.12 | `Cabal-` | [/cabal](https://errors.haskell.org/cabal) |
## Contributing to the Message Index
diff --git a/message-index/cabal/index.html b/message-index/cabal/index.html
new file mode 100644
index 00000000..40109ef5
--- /dev/null
+++ b/message-index/cabal/index.html
@@ -0,0 +1,27 @@
+---
+title: The Haskell Error Index | Cabal
+---
+
+Welcome
+
+
+ This site describes error messages that can be returned by Cabal, including both errors and warnings.
+ Every error and warning has a code that Cabal emits when you run into it—you can look them up below.
+
+
+
+ So far, $messageCount$ Cabal errors and warnings are documented here.
+ If you encounter a message that is not yet documented, please
+ open an issue or
+ submit a pull request with documentation.
+ Pull requests with additional examples and improved explanations for
+ existing messages are also very welcome, as are
+ improvements to the generated site.
+
+
+
+This site is a project of The Haskell Foundation.
+Please get in touch if you have feedback or if you'd like to get involved!
+
+
+$partial("templates/messages.html")$
diff --git a/message-index/ghc/index.html b/message-index/ghc/index.html
new file mode 100644
index 00000000..355b123b
--- /dev/null
+++ b/message-index/ghc/index.html
@@ -0,0 +1,27 @@
+---
+title: The Haskell Error Index | GHC
+---
+
+Welcome
+
+
+ This site describes error messages that can be returned by GHC, including both errors and warnings.
+ Every error and warning has a code that GHC emits when you run into it—you can look them up below.
+
+
+
+ So far, $messageCount$ GHC errors and warnings are documented here.
+ If you encounter a message that is not yet documented, please
+ open an issue or
+ submit a pull request with documentation.
+ Pull requests with additional examples and improved explanations for
+ existing messages are also very welcome, as are
+ improvements to the generated site.
+
+
+
+This site is a project of The Haskell Foundation.
+Please get in touch if you have feedback or if you'd like to get involved!
+
+
+$partial("templates/messages.html")$
diff --git a/message-index/ghcup/index.html b/message-index/ghcup/index.html
new file mode 100644
index 00000000..7820343d
--- /dev/null
+++ b/message-index/ghcup/index.html
@@ -0,0 +1,27 @@
+---
+title: The Haskell Error Index | GHCup
+---
+
+Welcome
+
+
+ This site describes error messages that can be returned by GHCup, including both errors and warnings.
+ Every error and warning has a code that GHCup emits when you run into it—you can look them up below.
+
+
+
+ So far, $messageCount$ GHCup errors and warnings are documented here.
+ If you encounter a message that is not yet documented, please
+ open an issue or
+ submit a pull request with documentation.
+ Pull requests with additional examples and improved explanations for
+ existing messages are also very welcome, as are
+ improvements to the generated site.
+
+
+
+This site is a project of The Haskell Foundation.
+Please get in touch if you have feedback or if you'd like to get involved!
+
+
+$partial("templates/messages.html")$
diff --git a/message-index/index.html b/message-index/index.html
index 792ea64c..301a71c5 100644
--- a/message-index/index.html
+++ b/message-index/index.html
@@ -11,13 +11,6 @@ Welcome
These codes can be looked up below for further information.
-
- Other Haskell-related tools are welcome to add their own messages to the index. Please contact
- the Haskell Foundation
- or open an issue
- to begin the process.
-
-
So far, $messageCount$ errors and warnings are documented here.
If you encounter a message that is not yet documented, please
@@ -34,42 +27,4 @@
Welcome
Please get in touch if you have feedback or if you'd like to get involved!
-The Messages
-
-
-
-$partial("templates/message-list.html")$
-
-
+$partial("templates/messages.html")$
diff --git a/message-index/site.hs b/message-index/site.hs
index 422b059f..240b54d6 100644
--- a/message-index/site.hs
+++ b/message-index/site.hs
@@ -119,23 +119,11 @@ main = hakyll $ do
>>= applyAsTemplate ctx
>>= loadAndApplyTemplate "templates/default.html" ctx
- match "index.html" $ do
- route idRoute
- compile $ do
- messages <- loadAll ("messages/*/index.md" .&&. hasNoVersion)
- let bread = breadcrumbCtx []
- indexCtx =
- mconcat
- [ listField "messages" (messageCtx <> defaultContext) (pure messages),
- bread,
- constField "messageCount" (show (length messages)),
- defaultContext
- ]
-
- getResourceBody
- >>= applyAsTemplate indexCtx
- >>= loadAndApplyTemplate "templates/default.html" indexCtx
- >>= relativizeUrls
+ match "index.html" $ compileFilteredIndex ""
+ match "cabal/index.html" $ compileFilteredIndex "Cabal-"
+ match "ghc/index.html" $ compileFilteredIndex "GHC-"
+ match "ghcup/index.html" $ compileFilteredIndex "GHCup-"
+ match "stack/index.html" $ compileFilteredIndex "S-"
-- Needed for flagInfo below
match "warning-sets/warning-sets-9.5.txt" $ do
@@ -185,6 +173,25 @@ main = hakyll $ do
--------------------------------------------------------------------------------
+compileFilteredIndex :: String -> Rules ()
+compileFilteredIndex prefix = do
+ route idRoute
+ compile $ do
+ messages <- loadAll (fromGlob ("messages/" <> prefix <> "*/index.md") .&&. hasNoVersion)
+ let bread = breadcrumbCtx []
+ indexCtx =
+ mconcat
+ [ listField "messages" (messageCtx <> defaultContext) (pure messages),
+ bread,
+ constField "messageCount" (show (length messages)),
+ defaultContext
+ ]
+
+ getResourceBody
+ >>= applyAsTemplate indexCtx
+ >>= loadAndApplyTemplate "templates/default.html" indexCtx
+ >>= relativizeUrls
+
-- | The file extensions to be shown in example lists
exampleExtensions :: NonEmpty String
exampleExtensions = "hs" :| ["yaml", "cabal"]
diff --git a/message-index/stack/index.html b/message-index/stack/index.html
new file mode 100644
index 00000000..792db5e6
--- /dev/null
+++ b/message-index/stack/index.html
@@ -0,0 +1,27 @@
+---
+title: The Haskell Error Index | Stack
+---
+
+Welcome
+
+
+ This site describes error messages that can be returned by Stack, including both errors and warnings.
+ Every error and warning has a code that Stack emits when you run into it—you can look them up below.
+
+
+
+ So far, $messageCount$ Stack errors and warnings are documented here.
+ If you encounter a message that is not yet documented, please
+ open an issue or
+ submit a pull request with documentation.
+ Pull requests with additional examples and improved explanations for
+ existing messages are also very welcome, as are
+ improvements to the generated site.
+
+
+
+This site is a project of The Haskell Foundation.
+Please get in touch if you have feedback or if you'd like to get involved!
+
+
+$partial("templates/messages.html")$
diff --git a/message-index/templates/messages.html b/message-index/templates/messages.html
index 1e4dc918..aaeba762 100644
--- a/message-index/templates/messages.html
+++ b/message-index/templates/messages.html
@@ -1,2 +1,39 @@
-$body$
+The Messages
+
+
+
$partial("templates/message-list.html")$
+
+