Safe Haskell | Safe-Infered |
---|
- defaultMain :: Map Text Loom -> IO ()
- parse :: Monad m => (FilePath -> m ByteString) -> FilePath -> m (Either ParseError Document)
- tangle :: Monad m => (FilePath -> ByteString -> m ()) -> Bool -> Document -> m ()
- weave :: Loom -> Document -> ByteString
- data Document
- documentBlocks :: Document -> [Block]
- documentOptions :: Document -> Map Text Text
- documentLoomName :: Document -> Maybe Text
- data Block
- data Content
- data Position
- positionFile :: Position -> FilePath
- positionLine :: Position -> Integer
- data ParseError
- parseErrorPosition :: ParseError -> Position
- parseErrorMessage :: ParseError -> Text
- type Loom = Document -> LoomM ()
- data LoomM a
- data LoomOptions
- loomOptionTabSize :: LoomOptions -> Integer
- looms :: Map Text Loom
- loomDebug :: Loom
- loomHTML :: Loom
- loomLaTeX :: Loom
- loomMarkdown :: Loom
- loomNoWeb :: Loom
Basic operations
defaultMain :: Map Text Loom -> IO ()Source
Run Anansi with the provided looms. Loom names are namespaced by their
package name, such as "anansi.noweb"
or "anansi-hscolour.html"
.
If your looms aren't available on Hackage, a Java-style name such as
"com.mycompany.myformat"
is a good alternative.
:: Monad m | |
=> (FilePath -> m ByteString) | File loader |
-> FilePath | Path to the root file |
-> m (Either ParseError Document) |
Parse a set of files into a Document
. If a parse failure occurs, a
ParseError
will be returned instead.
:: Monad m | |
=> (FilePath -> ByteString -> m ()) | File writer |
-> Bool | Enable writing #line declarations |
-> Document | |
-> m () |
Write a Document
to files. Paths passed to the file writer are pulled
directly from the document, so if you need to process them further, that
logic must be placed in the writer computation.
In most cases, users will want to write #line
pragmas to tangled source,
so error messages will refer back to the original input files. Haddock does
not handle these pragmas properly, so disable them when the tangled sources
will be processed into API documentation.
weave :: Loom -> Document -> ByteStringSource
Write a document to some sort of document markup. This will typically be rendered into documentation by external tools, such as LaTeX or a web browser.
This writes a ByteString
rather than Text
so that looms have full
control over character encoding.
Documents
documentBlocks :: Document -> [Block]Source
documentOptions :: Document -> Map Text TextSource
A map of :option
commands found in the document. If
the same option is specified multiple times, the most recent will
be used.
documentLoomName :: Document -> Maybe TextSource
The last :loom
command given, if any. A document does not
require a loom name if it's just going to be tangled, or will be
woven by the user calling weave
. Documents woven by
defaultMain
do require a loom name.
ContentText Position Text | |
ContentMacro Position Text Text | A macro reference within a content block. The first |
Document parsing
data ParseError Source
Eq ParseError | |
Show ParseError | |
Error ParseError | ignore me |
Looms
type Loom = Document -> LoomM ()Source
A loom contains all the logic required to convert a Document
into
markup suitable for processing with an external documentation tool.
Within a loom, use ask
to retrieve the LoomOptions
, and
tell
to append data to the output.
data LoomOptions Source
A set of processed :option
commands related to looms. Looms are always
free to check options manually, but this simplifies common cases.
Built-in looms
looms = Data.Map.fromList [ ("anansi.debug",loomDebug
) , ("anansi.html",loomHTML
) , ("anansi.latex",loomLaTeX
) , ("anansi.markdown",loomMarkdown
) , ("anansi.noweb",loomNoWeb
) ]
Just show
each block. This is useful for seeing exactly what your
document is being parsed to.
Generate simple, <pre>
-based HTML. Users who would like to weave
specialized HTML to fit with their existing templates are encouraged to
copy this loom and modify it as needed.
Generate simple, alltt
-based LaTeX. Users who would like to weave
specialized LaTeX to fit with their existing templates are encouraged to
copy this loom and modify it as needed.
Generate Markdown. Modified from LaTeX.hs.