ask :: Content -> ContentPrevent infinite recursion when using a value from the data store as content.
For example:
Will break with an infinite recursion error. To resolve this do:
[ { x = 3; }
(ref data.x)
]or (if you don’t like typing “ref”):
[ { x = 3; }
(r data.x)
]code :: Language -> Code -> ContentCreate a markdown code block
conix.git.ref :: GitBranchStringThe GIT branch of the conix repo currently being used
conix.git.rev :: GitCommitHashStringThe GIT commit hash of conix repo currently used
conix.git.text :: NixStringString containing a Nix Attribute expression representing conix.git
conix.git.url :: URLStringThe HTTP URL of the conix GIT repo
conix.homepageUrl :: URLStringThe homepage URL of conix
conix.version.major :: NaturalThe major version of the conix repo being used
conix.version.minor :: NaturalThe minor version of the conix repo being used
conix.version.patch :: NaturalThe patch version of the conix repo being used
conix.version.text :: SemanticVersionStringThe semantic version of the conix repo being used.
It is formatted as: major.minor.patch
conixCss :: FileName -> Content -> ContentThe css file conix uses for generating its documentation
css :: FilePath -> ContentWhen used with meta add the local css file to this html file’s includes
digraph :: ImageName -> DOTCode -> ContentShorthand for: dotgraph imgName "digraph { ... }"
dir :: DirName -> Content -> ContentNest the file heirarchy of the given content into the given directory
dotgraph :: ImageName -> DOTCode -> ContentCreate an graph image from the given DOT code
eval :: Content -> { text :: String, drv :: Derivation, data :: AttrSet, refs :: AttrSet, exprs :: AttrSet }Evaluate Content with just the conix library in scope
evalExtended :: Content -> Content -> { text :: String, drv :: Derivation, data :: AttrSet, refs :: AttrSet, exprs :: AttrSet }Evaluate a Content with the conix library extended with the exprs defined in the first Content
expr :: HaskellTypeString -> Content -> aCreate a new API expression with a type, documentation, and a Nix value.
Traditionally Nix modules are just attribute sets with their values being API expressions (e.g a function). Documentation is left as comments and types don’t exist. expr abstracts over documentation, types, and the user defined function to make documentation first class in Nix.
file :: (Text -> Derivation) -> FileNameStr -> Content -> ContentCreate a new file from the text produced by the given content
foldAttrsCond :: (a -> Bool) -> (a -> b) -> (AttrSet b -> b) -> AttrSet a -> bFold an attribute set down while allowing for attribute sets to be a leaf value.
The first function returns true if the given attribute set is a leaf value. The second function maps leaf values to final values. The third function returns a combined final value from the final values of the lower branches.
For example, to sum the leaf values in an attribute set where a leaf is either a nix value or attribute set containing “stop” as an attribute is:
countLeaves = foldAttrsCond
# An attribute set is a leaf if it contains "stop" as an attribute.
(s: s ? stop)
# return the value 1 for each leaf. We don't need the actual value to compute the result.
(_: 1)
# countMap is a flat attribute set containing the previously counted branches.
(countMap: builtins.foldl' (sum: count: sum + count) 0 (builtins.attrValues countMap));
# This should return 5.
nleaves = countLeaves { a = { b = "b"; c = "c"; }; d.e.f = "f"; g = { h = { stop = 2; }; i = 7; }; };foldAttrsIxCond :: ((AttrSet e ) -> Bool) -> (a -> Path -> b) -> (AttrSet b -> b) -> AttrSet a -> bThis is just like foldAttrsCond except the function to convert leaf values into final values also takes in the path from the top of the attribute set for that leaf value.
foldlIx :: (Natural -> b -> a -> b) -> b -> [a] -> bLeft fold with index
html :: FileName -> Content -> ContentCreate an HTML file from the given content
img :: FilePath -> ContentInserts an image in the given document and ensures that the imported image exits and is included in the final derivation
indent :: Natural -> Content -> ContentIndent the text of the content by the given number of spaces
intersperse :: a -> [a] -> [a]Insert the given element inbetween elements of the given list
link :: Content -> ContentGenerate a relative path to the given content
For example:
conix: with conix; [ (html "bob" { x = 3; }) (dir "larry" (html "joe" (link refs.x))) ]
will produce a relative path in the html file “joe” ../bob.html
list :: [Content] -> ContentCreate a bullet list
local :: FilePath -> ContentAdd a local file to the generated derivation
markdown :: FileName -> Content -> ContentCreate a markdown file from the given text
merge :: [Content] -> ContentMerge Contents together. This concatenates text values, collects files into a single directory, and recursively merges data values.
Normally when constructing text values and you wish to concatenate them together one wishes to use something like: foo + "\n" + bar. With merge one can simply write: merge [ foo "\n" bar ] and achieve the same affect.
meta :: [Content] -> ContentConstruct the meta data portion of a Pandoc sytle markdown file
modtxt :: (Text -> Text) -> Content -> ContentModify the text produced by the content
module :: Content -> { Path :: Expression } -> ContentCreate a new module with the given module doc string and attribute set containing expressions.
The first argument is content (typically module level documentation) to insert before API documentation.
For example:
module
''
# String API
This is an api for creating fancy strings.
''
{
appendPeriod = expr
"Content -> Content"
"Appends a period to the given content"
(x: [ x "."])
;
}nest :: PathString -> Content -> ContentNest the data for the given content under a given path
For example:
m: with m;
[
(nest "foo.bar" (n: with n; [{ x = 3; } (r data.x)]))
{x = 4;}
(r data.x)
]
will produce:
```nix
"3344"notice how we’ve defined x in two places. Nesting allows one to keep the first x from overriding the value of the second.
pagetitle :: String -> ContentThe title of the rendered document
pandoc :: OutputFileExtension -> PandocCmdArgs -> BuildInputs -> FileName -> Content -> ContentUse pandoc to construct a file from the given content
pathOf :: LocalFilePath -> ContentWrites the given file path as text and includes the referenced file in the output
pdf :: FileName -> Content -> ContentCreate a PDF file from the given content
printNixVal :: a -> StringPretty print a pure nix-value.
NOTE: do not call this function on a derivation as it will segfault.
r :: Content -> ContentSee ref
run :: Content -> DerivationRuns eval and extracts the derivation
runCode :: (Content -> Content) -> Language -> Code -> ContentCreate a code block and append the results of executing the passed runner
runConixSnippet :: SnippetName -> Content -> ContentRun the given Conix code and insert its resulting text
runExtended :: Content -> Content -> DerivationRuns evalExtended and extracts the derivation
runNixSnippet :: SnippetName -> NixCode -> ContentCreate a Nix code block, execute the code, and append the results as a second code block
set :: AttrSet -> ContentSet a pure attribute set. This appends no new text to the content.
table :: [Content] -> [[Content]] -> ContentCreate a markdown table with the given headers and rows
tell :: AttrSet -> Content -> ContentAdd data to the given content. Attribute paths are absolute and not relative. TODO: add an example
text :: Text -> ContentAppend text to the current file.
textfile :: FileName -> Content -> ContentWrite the content to the given text file
tutorialSnippet :: FileName -> AttrPathName -> Content -> ContentCreate a nix snippet with its content under a reference
using :: (AttrSet -> Content) -> ContentCreates expressions from functions that depend on the final data. Use this as follows:
conix: with conix; <content expression here>Here conix = { pkgs = ...; data = ...; ... } where data is the final data and the rest of the conix attribute set is the conix library and a copy of pkgs of course).