From b282af35ad4b0bb8d90e517f4b9ff03c22234090 Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Wed, 7 Sep 2022 15:07:04 +0200 Subject: Copy-edit specification --- src/exe/Doc.lhs | 6 +++--- src/exe/Main.lhs | 34 +++++++++++++++++++--------------- 2 files changed, 22 insertions(+), 18 deletions(-) (limited to 'src/exe') diff --git a/src/exe/Doc.lhs b/src/exe/Doc.lhs index 40508cb..711050b 100644 --- a/src/exe/Doc.lhs +++ b/src/exe/Doc.lhs @@ -13,8 +13,8 @@ Building documentation > 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 +The documentation can be generated by running ``cabal run pesto-doc``. It is +exclusively based on the restructuredText inside this package’s literal Haskell source code. .. _restructuredText: http://docutils.sourceforge.net/rst.html @@ -47,7 +47,7 @@ highlighting and MathJax for formulas. > > main = do -The module Codec.Pesto serves as starting point and it includes every other +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. diff --git a/src/exe/Main.lhs b/src/exe/Main.lhs index 2f67ffd..dc360fd 100644 --- a/src/exe/Main.lhs +++ b/src/exe/Main.lhs @@ -12,27 +12,20 @@ User interface > import Codec.Pesto.Lint (lint, extractMetadata, Metadata(..), LintResult (LintResult)) > import Codec.Pesto.Serialize (serialize) -The user-interface has different modes of operation. All of them read a single -recipe from the standard input. +The user-interface reads a single recipe from the standard input. > main = do > (op:_) <- getArgs > s <- getContents -> either malformedRecipe (run op) (parse s) +> either malformedRecipe (run op) (parse s) + +It has three modes of operation, described in the next sections. > run "dot" = runDot > run "metadata" = runMeta > run "ingredients" = runIngredients > run _ = const (putStrLn "unknown operation") -> malformedRecipe = print - -> streamToGraph stream = (nodes, edges) -> where -> doc = (head . extract . snd . unzip) stream -> nodes = zip [firstNodeId..] doc -> edges = toGraph nodes ++ resolveReferences nodes - dot ^^^ @@ -41,7 +34,7 @@ can represent recipes as well. Example: .. code:: bash - cabal run --verbose=0 pesto dot < spaghetti.pesto | dot -Tpng > spaghetti.png + cabal run --verbose=0 pesto dot < spaghetti.pesto | dot -Tpng > spaghetti.png > runDot stream = putStrLn $ toDot dotNodes dotEdges > where @@ -50,10 +43,10 @@ can represent recipes as well. Example: > (lintNodes, lintEdges) = unzip $ map (uncurry lintToNodesEdges) > $ zip [maxId..] (lint nodes edges) > dotNodes = concat [ -> [("node", [("fontname", "Roboto Semi-Light")])] +> [("node", [("fontname", "Roboto Semi-Light")])] > , map (\(a, label) -> (show a, [("label", serialize label)])) nodes > , lintNodes -> ] +> ] > dotEdges = concat [ > map (both show) edges > , concat lintEdges @@ -72,7 +65,7 @@ can represent recipes as well. Example: > <> "}" > where > edgeToDot (a, b) = a <> " -> " <> b <> ";" -> nodeToDot (a, b) = a <> " [" <> mconcat (mapToDot b) <> "];" +> nodeToDot (a, b) = a <> " [" <> mconcat (mapToDot b) <> "];" > mapToDot = map kvToDot > kvToDot (k, v) = k <> "=\"" <> quoteString v <> "\"" @@ -104,3 +97,14 @@ alternatives into account yet. > csvQty (Quantity a b c) = intercalate "," [serialize a, b, c] +Appendix +^^^^^^^^ + +> malformedRecipe = print + +> streamToGraph stream = (nodes, edges) +> where +> doc = (head . extract . snd . unzip) stream +> nodes = zip [firstNodeId..] doc +> edges = toGraph nodes ++ resolveReferences nodes + -- cgit v1.2.3