summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars-Dominik Braun <lars@6xq.net>2020-08-24 17:09:34 +0200
committerLars-Dominik Braun <lars@6xq.net>2020-08-24 17:09:34 +0200
commit295dd897297722d07ec2ce5fb82e323fe495c775 (patch)
tree8d9de652a030c34c6be775ca31c159620f52fbf1
parent39f9263fa38c32ce2e3a4f4bedb8349da47a3200 (diff)
downloadpesto-295dd897297722d07ec2ce5fb82e323fe495c775.tar.gz
pesto-295dd897297722d07ec2ce5fb82e323fe495c775.tar.bz2
pesto-295dd897297722d07ec2ce5fb82e323fe495c775.zip
GHC 8.8, cabal 3, pandoc 2.10 compatibility
Move files around to separate Pesto (the library) and Pesto (the executables). Fixes for pandoc API changes.
-rw-r--r--Pesto.cabal18
-rw-r--r--src/exe/Doc.lhs (renamed from src/Doc.lhs)27
-rw-r--r--src/exe/Main.lhs (renamed from src/Main.lhs)1
-rw-r--r--src/exe/Test.lhs (renamed from src/Test.lhs)0
-rw-r--r--src/lib/Codec/Pesto.lhs (renamed from src/Codec/Pesto.lhs)6
-rw-r--r--src/lib/Codec/Pesto/Graph.lhs (renamed from src/Codec/Pesto/Graph.lhs)0
-rw-r--r--src/lib/Codec/Pesto/Lint.lhs (renamed from src/Codec/Pesto/Lint.lhs)5
-rw-r--r--src/lib/Codec/Pesto/Parse.lhs (renamed from src/Codec/Pesto/Parse.lhs)0
-rw-r--r--src/lib/Codec/Pesto/Parse.lhs-boot (renamed from src/Codec/Pesto/Parse.lhs-boot)0
-rw-r--r--src/lib/Codec/Pesto/Serialize.lhs (renamed from src/Codec/Pesto/Serialize.lhs)0
-rw-r--r--template.html66
11 files changed, 29 insertions, 94 deletions
diff --git a/Pesto.cabal b/Pesto.cabal
index ff13d20..e72809d 100644
--- a/Pesto.cabal
+++ b/Pesto.cabal
@@ -15,32 +15,30 @@ cabal-version: >=1.10
-- parsec>=3.1.9 has instance Eq ParseError
library
exposed-modules: Codec.Pesto, Codec.Pesto.Parse, Codec.Pesto.Graph, Codec.Pesto.Lint, Codec.Pesto.Serialize
- -- other-modules:
- -- other-extensions:
- build-depends: base >=4.8 && <4.10, HUnit, parsec >= 3.1.9
- hs-source-dirs: src
+ build-depends: base >=4.8, HUnit, parsec >= 3.1.9
+ hs-source-dirs: src/lib
default-language: Haskell2010
ghc-options: -Werror -Wall -fno-warn-missing-signatures
executable pesto
main-is: Main.lhs
- hs-source-dirs: src
+ hs-source-dirs: src/exe
default-language: Haskell2010
- build-depends: base >=4.8 && <4.10, HUnit, parsec >= 3.1.9
+ build-depends: base >=4.8, HUnit, parsec >= 3.1.9, Pesto
ghc-options: -Werror -Wall -fno-warn-missing-signatures
test-suite pesto-test
type: exitcode-stdio-1.0
main-is: Test.lhs
- hs-source-dirs: src
+ hs-source-dirs: src/exe
default-language: Haskell2010
- build-depends: base >=4.8 && <4.10, Pesto, HUnit, parsec >= 3.1.9
+ build-depends: base >=4.8, Pesto, HUnit, parsec >= 3.1.9, Pesto
ghc-options: -Werror -Wall -fno-warn-missing-signatures
executable pesto-doc
main-is: Doc.lhs
- hs-source-dirs: src
+ hs-source-dirs: src/exe
default-language: Haskell2010
- build-depends: base >=4.8 && <4.10, pandoc >=2.1, text, directory
+ build-depends: base >=4.8, pandoc >=2.10, text, directory, Pesto, containers, doctemplates, either
ghc-options: -Werror -Wall -fno-warn-missing-signatures
diff --git a/src/Doc.lhs b/src/exe/Doc.lhs
index a0d5121..63e9847 100644
--- a/src/Doc.lhs
+++ b/src/exe/Doc.lhs
@@ -5,11 +5,13 @@ Building documentation
> {-# LANGUAGE OverloadedStrings #-}
> import Text.Pandoc
-> import Text.Pandoc.Error (handleError)
-> import Text.Pandoc.Extensions (extensionsFromList)
> import Text.Pandoc.Highlighting (tango)
> import qualified Data.Text.IO as TIO
> import System.Directory (setCurrentDirectory)
+> import Data.Map as M
+> import Text.DocTemplates (ToContext(toVal), Context(..))
+> import Data.Text (pack)
+> import Data.Either.Combinators (rightToMaybe)
The documentation can be generated running ``cabal run pesto-doc``. It is
exclusively based on the restructuredText inside this packages’ literal Haskell
@@ -30,28 +32,31 @@ Pandoc_ outputs a single HTML5 page with syntax highlighting and MathJax for
formulas.
> writeDoc tpl = writeHtml5String def {
-> writerTemplate = Just tpl
+> writerTemplate = tpl
> , writerHighlightStyle = Just tango
> , writerNumberSections = True
> , writerSectionDivs = True
> , writerTabStop = 4
> , writerHTMLMathMethod = MathJax "https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"
-> , writerVariables = [("css", "pesto.css"), ("lang", "en")]
+> , writerVariables = Context $ M.fromList [
+> ("css", toVal $ pack "pesto.css")
+> , ("lang", toVal $ pack "en")
+> , ("include-before", toVal $ pack "<div class=\"wrapper\">")
+> , ("include-after", toVal $ pack "</div>")
+> ]
> }
-
-A slightly customized template is used.
-
+>
> main = do
-> tpl <- readFile "template.html"
The module Codec.Pesto serves as starting point and it includes every other
module in a sensible order. For the relative includes to work, we need to
change our current working directory.
-> setCurrentDirectory "src/Codec"
+> tpl <- runIO $ compileDefaultTemplate "html5"
+> setCurrentDirectory "src/lib/Codec"
> doc <- TIO.readFile "Pesto.lhs"
-> result <- runIO $ readDoc doc >>= writeDoc tpl
-> setCurrentDirectory "../../"
+> result <- runIO $ readDoc doc >>= writeDoc (rightToMaybe tpl)
+> setCurrentDirectory "../../../"
> html <- handleError result
Output is written to the directory ``_build``, which contains the corresponding
diff --git a/src/Main.lhs b/src/exe/Main.lhs
index 61ed180..2f67ffd 100644
--- a/src/Main.lhs
+++ b/src/exe/Main.lhs
@@ -6,7 +6,6 @@ User interface
> module Main (main) where
> import System.Environment (getArgs)
> import Data.List (intercalate)
-> import Data.Monoid ((<>))
>
> import Codec.Pesto.Parse (parse, Instruction (Ingredient), Quantity (..))
> import Codec.Pesto.Graph (extract, toGraph, firstNodeId, resolveReferences)
diff --git a/src/Test.lhs b/src/exe/Test.lhs
index 400192e..400192e 100644
--- a/src/Test.lhs
+++ b/src/exe/Test.lhs
diff --git a/src/Codec/Pesto.lhs b/src/lib/Codec/Pesto.lhs
index 098f9cb..6940b4c 100644
--- a/src/Codec/Pesto.lhs
+++ b/src/lib/Codec/Pesto.lhs
@@ -280,7 +280,7 @@ This project uses cabal. It provides the Codec.Pesto library that implements
the Pesto language as described in the previous sections. It also comes with
three binaries.
-.. include:: ../Main.lhs
-.. include:: ../Test.lhs
-.. include:: ../Doc.lhs
+.. include:: ../../exe/Main.lhs
+.. include:: ../../exe/Test.lhs
+.. include:: ../../exe/Doc.lhs
diff --git a/src/Codec/Pesto/Graph.lhs b/src/lib/Codec/Pesto/Graph.lhs
index 511adca..511adca 100644
--- a/src/Codec/Pesto/Graph.lhs
+++ b/src/lib/Codec/Pesto/Graph.lhs
diff --git a/src/Codec/Pesto/Lint.lhs b/src/lib/Codec/Pesto/Lint.lhs
index 81cb5d6..bc99e14 100644
--- a/src/Codec/Pesto/Lint.lhs
+++ b/src/lib/Codec/Pesto/Lint.lhs
@@ -122,9 +122,8 @@ Both, title and description, are implicit.
> "title"
> , "description"
-The recipe’s language, as 2 character code (`ISO 639-1`__).
-
-__ http://www.loc.gov/standards/iso639-2/php/English_list.php
+The recipe’s language, as 2 character code (`ISO 639-1
+<http://www.loc.gov/standards/iso639-2/php/English_list.php>`_).
> , "language"
diff --git a/src/Codec/Pesto/Parse.lhs b/src/lib/Codec/Pesto/Parse.lhs
index 518b866..518b866 100644
--- a/src/Codec/Pesto/Parse.lhs
+++ b/src/lib/Codec/Pesto/Parse.lhs
diff --git a/src/Codec/Pesto/Parse.lhs-boot b/src/lib/Codec/Pesto/Parse.lhs-boot
index 9096ad7..9096ad7 100644
--- a/src/Codec/Pesto/Parse.lhs-boot
+++ b/src/lib/Codec/Pesto/Parse.lhs-boot
diff --git a/src/Codec/Pesto/Serialize.lhs b/src/lib/Codec/Pesto/Serialize.lhs
index f07e871..f07e871 100644
--- a/src/Codec/Pesto/Serialize.lhs
+++ b/src/lib/Codec/Pesto/Serialize.lhs
diff --git a/template.html b/template.html
deleted file mode 100644
index 7d06e2f..0000000
--- a/template.html
+++ /dev/null
@@ -1,66 +0,0 @@
-<!DOCTYPE html>
-<html$if(lang)$ lang="$lang$"$endif$>
-<head>
-<meta charset="utf-8">
-<meta name="generator" content="pandoc">
-<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
-$for(author-meta)$
-<meta name="author" content="$author-meta$">
-$endfor$
-$if(date-meta)$
-<meta name="dcterms.date" content="$date-meta$">
-$endif$
-<title>$if(title-prefix)$$title-prefix$ - $endif$$title$</title>
-<style type="text/css">code{white-space: pre;}</style>
-<!--[if lt IE 9]>
-<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
-<![endif]-->
-$if(quotes)$
-<style type="text/css">q { quotes: "“" "”" "‘" "’"; }</style>
-$endif$
-$if(highlighting-css)$
-<style type="text/css">
-$highlighting-css$
-</style>
-$endif$
-$for(css)$
-<link rel="stylesheet" href="$css$">
-$endfor$
-$if(math)$
-$math$
-$endif$
-$for(header-includes)$
-$header-includes$
-$endfor$
-</head>
-<body>
-$for(include-before)$
-$include-before$
-$endfor$
-<div class="wrapper">
-$if(title)$
-<header>
-<h1 class="title">$title$</h1>
-$if(subtitle)$
-<h1 class="subtitle">$subtitle$</h1>
-$endif$
-$for(author)$
-<h2 class="author">$author$</h2>
-$endfor$
-$if(date)$
-<h3 class="date">$date$</h3>
-$endif$
-</header>
-$endif$
-$if(toc)$
-<nav id="$idprefix$TOC">
-$toc$
-</nav>
-$endif$
-$body$
-</div>
-$for(include-after)$
-$include-after$
-$endfor$
-</body>
-</html>