summaryrefslogtreecommitdiff
path: root/src/exe
diff options
context:
space:
mode:
Diffstat (limited to 'src/exe')
-rw-r--r--src/exe/Doc.lhs6
-rw-r--r--src/exe/Main.lhs34
2 files changed, 22 insertions, 18 deletions
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
+