| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Language.Drasil.Document
Description
Document Description Language.
Synopsis
- enumBullet :: Reference -> [Sentence] -> LabelledContent
- enumBulletU :: [Sentence] -> Contents
- enumSimple :: Reference -> Integer -> Sentence -> [Sentence] -> LabelledContent
- enumSimpleU :: Integer -> Sentence -> [Sentence] -> Contents
- mkEnumSimpleD :: (Referable c, HasShortName c, Definition c) => [c] -> [Contents]
- lbldExpr :: ModelExpr -> Reference -> LabelledContent
- unlbldExpr :: ModelExpr -> Contents
- unlbldCode :: Expr -> Contents
- foldlSP :: [Sentence] -> Contents
- foldlSP_ :: [Sentence] -> Contents
- foldlSPCol :: [Sentence] -> Contents
- data Contents
- data ListType
- data ItemType
- data RawContent
- = Table [Sentence] [[Sentence]] Title Bool
- | Paragraph Sentence
- | EqnBlock ModelExpr
- | DerivBlock Sentence [RawContent]
- | Enumeration ListType
- | Defini [(Identifier, [Contents])]
- | Figure Lbl Filepath MaxWidthPercent HasCaption
- | Bib BibRef
- | Graph [(Sentence, Sentence)] (Maybe Width) (Maybe Height) Lbl
- | CodeBlock Expr
- type ListTuple = (Title, ItemType, Maybe String)
- type MaxWidthPercent = Float
- class HasContents c where
- accessContents :: Lens' c RawContent
- data LabelledContent = LblC {}
- newtype UnlabelledContent = UnlblC {}
- data HasCaption
- type Lbl = Sentence
- type Filepath = String
- type Author = Sentence
- type Title = Sentence
- data DecRef = DR {}
- class HasDecRef c where
- getDecRefs :: Lens' c [DecRef]
- dRef :: (IsChunk r, HasRefAddress r, HasShortName r) => r -> DecRef
- dRefInfo :: (IsChunk r, HasRefAddress r, HasShortName r) => r -> RefInfo -> DecRef
- sentToExp :: Sentence -> [ModelExpr]
- extractMExprs :: HasContents a => a -> [ModelExpr]
- extractSents :: HasContents a => a -> [Sentence]
- extractSents' :: HasContents a => [a] -> [Sentence]
- extractChRefs :: HasContents a => [a] -> Set UID
- getSec :: Section -> [Sentence]
- extractSectionsBib :: ChunkDB -> [Section] -> BibRef
- resolveBibliography :: ChunkDB -> Set UID -> [Citation]
- data Reference = Reference UID LblType ShortName
- class HasReference c where
- getReferences :: Lens' c [Reference]
- ref :: (IsChunk r, HasRefAddress r, HasShortName r) => r -> Reference
- refS :: (IsChunk r, HasRefAddress r, HasShortName r) => r -> Sentence
- namedRef :: (IsChunk r, HasRefAddress r, HasShortName r) => r -> Sentence -> Sentence
- complexRef :: (IsChunk r, HasRefAddress r, HasShortName r) => r -> RefInfo -> Sentence
- namedComplexRef :: (IsChunk r, HasRefAddress r, HasShortName r) => r -> Sentence -> RefInfo -> Sentence
- section :: Sentence -> [Contents] -> [Section] -> Reference -> Section
- fig :: Lbl -> Filepath -> RawContent
- figNoCap :: Lbl -> Filepath -> RawContent
- figWithWidth :: Lbl -> Filepath -> MaxWidthPercent -> RawContent
- figNoCapWithWidth :: Lbl -> Filepath -> MaxWidthPercent -> RawContent
- data Section = Section {}
- data SecCons
- llcc :: UID -> LblType -> ShortName -> RawContent -> LabelledContent
- llccFig :: String -> RawContent -> LabelledContent
- llccTab :: String -> RawContent -> LabelledContent
- llccEqn :: String -> RawContent -> LabelledContent
- llccFig' :: UID -> RawContent -> LabelledContent
- llccTab' :: UID -> RawContent -> LabelledContent
- llccEqn' :: UID -> RawContent -> LabelledContent
- ulcc :: RawContent -> UnlabelledContent
- data Document
- mkParagraph :: Sentence -> Contents
- mkFig :: Reference -> RawContent -> Contents
- mkRawLC :: RawContent -> Reference -> LabelledContent
- data ShowTableOfContents
- checkToC :: Document -> Document
- makeTabRef :: String -> Reference
- makeFigRef :: String -> Reference
- makeSecRef :: String -> Sentence -> Reference
- makeEqnRef :: String -> Reference
- makeURI :: String -> String -> ShortName -> Reference
- makeTabRef' :: UID -> Reference
- makeFigRef' :: UID -> Reference
- makeSecRef' :: UID -> Sentence -> Reference
- makeEqnRef' :: UID -> Reference
- makeURI' :: UID -> String -> ShortName -> Reference
- chgsStart :: (HasShortName x, Referable x) => x -> Sentence -> Sentence
- definedIn :: (Referable r, HasShortName r, DefinesQuantity r) => r -> Sentence
- definedIn' :: (Referable r, HasShortName r, DefinesQuantity r) => r -> Sentence -> Sentence
- definedIn'' :: (Referable r, HasShortName r) => r -> Sentence
- definedIn''' :: (Quantity q, Referable r, HasShortName r) => q -> r -> Sentence
- fromReplace :: (Referable r, HasShortName r, Quantity q) => r -> q -> Sentence
- fromSource :: (Referable r, HasShortName r) => r -> Sentence
- fromSources :: (Referable r, HasShortName r) => [r] -> Sentence
- fmtU :: MayHaveUnit a => Sentence -> a -> Sentence
- follows :: (Referable r, HasShortName r) => Sentence -> r -> Sentence
- makeListRef :: [a] -> Section -> [Sentence]
- addPercent :: Show a => a -> Sentence
- maybeChanged :: Sentence -> Sentence -> Sentence
- maybeExpanded :: Sentence -> Sentence -> Sentence
- maybeWOVerb :: Sentence -> Sentence -> Sentence
- showingCxnBw :: NamedIdea c => c -> Sentence -> Sentence
- substitute :: (Referable r, HasShortName r, DefinesQuantity r) => [r] -> Sentence
- typUncr :: (Double, Maybe Int) -> Sentence
- underConsidertn :: ConceptChunk -> Sentence
- unwrap :: Maybe UnitDefn -> Sentence
- fterms :: (NamedIdea c, NamedIdea d) => (NP -> NP -> t) -> c -> d -> t
- eqN :: Int -> Sentence
- eqnWSource :: (Referable r, HasShortName r) => ModelExpr -> r -> Sentence
- bulletFlat :: [Sentence] -> ListType
- bulletNested :: [Sentence] -> [ListType] -> ListType
- itemRefToSent :: String -> Sentence -> Sentence
- makeTMatrix :: Eq a => [Sentence] -> [[a]] -> [a] -> [[Sentence]]
- mkEnumAbbrevList :: Integer -> Sentence -> [Sentence] -> [(Sentence, ItemType)]
- mkTableFromColumns :: [(Sentence, [Sentence])] -> ([Sentence], [[Sentence]])
- noRefs :: [ItemType] -> [(ItemType, Maybe String)]
- refineChain :: NamedIdea c => [(c, Section)] -> Sentence
- tAndDOnly :: Concept s => s -> ItemType
- tAndDWAcc :: Concept s => s -> ItemType
- tAndDWSym :: (Concept s, Quantity a) => s -> a -> ItemType
- zipSentList :: [[Sentence]] -> [Sentence] -> [[Sentence]] -> [[Sentence]]
List Creation Functions
enumBullet :: Reference -> [Sentence] -> LabelledContent Source #
Creates a bulleted list.
enumBulletU :: [Sentence] -> Contents Source #
Same as enumBullet but unlabelled.
enumSimple :: Reference -> Integer -> Sentence -> [Sentence] -> LabelledContent Source #
Currently Unused. Creates a simple bulleted list that labels things with a title and number:
- lb - Reference,
- s - start index for the enumeration,
- t - title of the list,
- l - list to be enumerated.
For example, if we want to create a list of data definitions, we could call the function as follows:
enumSimple _ 2 (S "DD") [def1, def2, ...]
And the resulting LabelledContent would be rendered as:
- DD2: def1
- DD3: def2
- DD4: def3 ...
enumSimpleU :: Integer -> Sentence -> [Sentence] -> Contents Source #
Same as enumSimple but unlabelled.
mkEnumSimpleD :: (Referable c, HasShortName c, Definition c) => [c] -> [Contents] Source #
Convenience function for transforming referable concepts into a bulleted list.
Used in drasil-docLang in making the assumptions, goals, and requirements sections.
Output is of the kind Concept Name: definition of concept.
Displaying Expressions
lbldExpr :: ModelExpr -> Reference -> LabelledContent Source #
Displays a given expression and attaches a Reference to it.
unlbldExpr :: ModelExpr -> Contents Source #
Same as eqUnR except content is unlabelled (does not attach a Reference).
unlbldCode :: Expr -> Contents Source #
Unlabelled code expression
Folds
foldlSPCol :: [Sentence] -> Contents Source #
Same as foldlSP but uses foldlSentCol.
Contents may be labelled or unlabelled.
Constructors
| UlC UnlabelledContent | |
| LlC LabelledContent |
Instances
| HasContents Contents Source # | Access the |
Defined in Language.Drasil.Document.Core Methods accessContents :: Lens' Contents RawContent Source # | |
Denotes the different possible types that can be used as a list.
Constructors
| Bullet [(ItemType, Maybe String)] | Bulleted list. |
| Numeric [(ItemType, Maybe String)] | Enumerated list. |
| Simple [ListTuple] | Simple list with items denoted by |
| Desc [ListTuple] | Descriptive list, renders as "Title: Item" (see |
| Definitions [ListTuple] | Renders a list of " |
Denotes how something should behave in a list (ListType).
data RawContent Source #
Types of layout objects we deal with explicitly.
Constructors
| Table [Sentence] [[Sentence]] Title Bool | table has: header-row, data(rows), label/caption, and a bool that determines whether or not to show label. |
| Paragraph Sentence | Paragraphs are just sentences. |
| EqnBlock ModelExpr | Block of Equations holds an expression. |
| DerivBlock Sentence [RawContent] | Grants the ability to label a group of |
| Enumeration ListType | For enumerated lists. |
| Defini [(Identifier, [Contents])] | Defines something with a type, identifier, and |
| Figure Lbl Filepath MaxWidthPercent HasCaption | For creating figures in a document includes whether the figure has a caption. |
| Bib BibRef | Grants the ability to reference something. |
| Graph [(Sentence, Sentence)] (Maybe Width) (Maybe Height) Lbl | Contain a graph with coordinates ( |
| CodeBlock Expr | Block for codes |
type MaxWidthPercent = Float Source #
MaxWidthPercent should be kept in the range 1-100.
Values outside this range may have unexpected results.
Used for specifying max figure width as
pagewidth*MaxWidthPercent/100.
class HasContents c where Source #
Members of this class must have RawContent.
Instances
| HasContents Contents Source # | Access the |
Defined in Language.Drasil.Document.Core Methods accessContents :: Lens' Contents RawContent Source # | |
| HasContents LabelledContent Source # | Access the |
Defined in Language.Drasil.Document.Core Methods accessContents :: Lens' LabelledContent RawContent Source # | |
| HasContents UnlabelledContent Source # | Access the |
Defined in Language.Drasil.Document.Core Methods accessContents :: Lens' UnlabelledContent RawContent Source # | |
data LabelledContent Source #
Contains a Reference and RawContent.
Instances
newtype UnlabelledContent Source #
Only contains RawContent.
Constructors
| UnlblC | |
Fields | |
Instances
| HasContents UnlabelledContent Source # | Access the |
Defined in Language.Drasil.Document.Core Methods accessContents :: Lens' UnlabelledContent RawContent Source # | |
data HasCaption Source #
Indicates whether a figure has a caption or not.
Constructors
| NoCaption | |
| WithCaption |
Instances
| Eq HasCaption Source # | |
Defined in Language.Drasil.Document.Core | |
Type
For holding a Reference that is decorated with extra information (ex. page numbers, equation sources, etc.).
Instances
| HasChunkRefs DecRef Source # | |
| HasUID DecRef Source # | Finds the |
Defined in Language.Drasil.Document.DecoratedReference | |
| HasRefAddress DecRef Source # | Finds the reference address contained in a |
| HasShortName DecRef Source # | Finds the shortname of the reference address used for the |
| Eq DecRef Source # | Equal if |
Class
Constructors
dRef :: (IsChunk r, HasRefAddress r, HasShortName r) => r -> DecRef Source #
dRefInfo :: (IsChunk r, HasRefAddress r, HasShortName r) => r -> RefInfo -> DecRef Source #
extractMExprs :: HasContents a => a -> [ModelExpr] Source #
Extracts ModelExprs from something that HasContents.
extractSents :: HasContents a => a -> [Sentence] Source #
Extracts Sentences from something that HasContents.
extractSents' :: HasContents a => [a] -> [Sentence] Source #
extractChRefs :: HasContents a => [a] -> Set UID Source #
Extracts all referenced UIDs from things that have RawContents.
extractSectionsBib :: ChunkDB -> [Section] -> BibRef Source #
Extract bibliography entries from generated sections. This version extracts from fully expanded Sections, capturing citations that are only created during document generation (like those in orgOfDocIntro).
resolveBibliography :: ChunkDB -> Set UID -> [Citation] Source #
Given a ChunkDB and a set of UIDs, looks up the corresponding
Citations and returns them sorted by author, year, and title.
FIXME: This function assumes that all UIDs in the set correspond to
Citations in the database. If a UID does not correspond to a Citation,
it is simply ignored. This should rather rely on a set of 'UIDRef Citation's.
Type
A Reference contains the identifier (UID), a reference address (LblType),
a human-readable shortname (ShortName), and any extra information about the reference (RefInfo).
Instances
| HasChunkRefs Reference Source # | |
| HasUID Reference Source # | |
Defined in Language.Drasil.Document.Reference | |
| HasRefAddress Reference Source # | Finds the reference address contained in a |
| HasShortName Reference Source # | Finds the shortname of the reference address used for the |
| Eq Reference Source # | Equal if |
Class
class HasReference c where Source #
A class that contains a list of References.
Constructors
ref :: (IsChunk r, HasRefAddress r, HasShortName r) => r -> Reference Source #
Projector function that creates a Reference from something Referable.
refS :: (IsChunk r, HasRefAddress r, HasShortName r) => r -> Sentence Source #
namedRef :: (IsChunk r, HasRefAddress r, HasShortName r) => r -> Sentence -> Sentence Source #
complexRef :: (IsChunk r, HasRefAddress r, HasShortName r) => r -> RefInfo -> Sentence Source #
Takes a Reference with additional display info. Uses the internal shortname for its display name.
namedComplexRef :: (IsChunk r, HasRefAddress r, HasShortName r) => r -> Sentence -> RefInfo -> Sentence Source #
fig :: Lbl -> Filepath -> RawContent Source #
Figure smart constructor with a Lbl and a Filepath. Assumes 100% of page width as max width. Defaults to WithCaption.
figWithWidth :: Lbl -> Filepath -> MaxWidthPercent -> RawContent Source #
Figure smart constructor that allows for customized max widths. Defaults to WithCaption.
figNoCapWithWidth :: Lbl -> Filepath -> MaxWidthPercent -> RawContent Source #
Figure smart constructor with customized max widths and no caption.
Instances
| HasChunkRefs Section Source # | |
| HasUID Section Source # | |
Defined in Language.Drasil.Document.Sections | |
| HasRefAddress Section Source # | Finds the reference address of a |
| Referable Section Source # | Finds the reference information of a |
| HasShortName Section Source # | Finds the short name of a |
| Eq Section Source # | |
Section Contents are split into subsections or contents, where contents
are standard layout objects (see Contents).
llcc :: UID -> LblType -> ShortName -> RawContent -> LabelledContent Source #
Smart constructor for labelled content chunks. Now builds a Reference using the provided UID instead of extracting it from the Reference.
llccFig :: String -> RawContent -> LabelledContent Source #
Helper for creating labelled content with a figure reference.
llccTab :: String -> RawContent -> LabelledContent Source #
Helper for creating labelled content with a table reference.
llccEqn :: String -> RawContent -> LabelledContent Source #
Helper for creating labelled content with an equation reference.
llccFig' :: UID -> RawContent -> LabelledContent Source #
Helper for creating labelled content with a UID-based figure reference.
llccTab' :: UID -> RawContent -> LabelledContent Source #
Helper for creating labelled content with a UID-based table reference.
llccEqn' :: UID -> RawContent -> LabelledContent Source #
Helper for creating labelled content with a UID-based equation reference.
ulcc :: RawContent -> UnlabelledContent Source #
Smart constructor for unlabelled content chunks (no Reference).
mkParagraph :: Sentence -> Contents Source #
Smart constructor that wraps UnlabelledContent into Contents.
mkFig :: Reference -> RawContent -> Contents Source #
Smart constructor that wraps LabelledContent into Contents.
Takes a Reference to extract UID, LblType, and ShortName for the labelled content.
mkRawLC :: RawContent -> Reference -> LabelledContent Source #
Smart constructor similar to llcc, but takes in RawContent first.
Takes a Reference to extract UID, LblType, and ShortName for the labelled content.
data ShowTableOfContents Source #
Determines whether or not the table of contents appears on the generated artifacts.
checkToC :: Document -> Document Source #
Manually removes the first section of a document (table of contents section). temp fix for Notebook (see if we need this in notebook later)
makeTabRef :: String -> Reference Source #
Create a reference for a table. Takes in the name of a table (which will also be used for its shortname).
makeFigRef :: String -> Reference Source #
Create a reference for a figure. Takes in the name of a figure (which will also be used for its shortname).
makeSecRef :: String -> Sentence -> Reference Source #
Create a reference for a section. Takes in the name of a section and a shortname for the section.
makeEqnRef :: String -> Reference Source #
Create a reference for a equation. Takes in the name of the equation (which will also be used for its shortname).
makeTabRef' :: UID -> Reference Source #
Variants of makeTabRef that takes a UID instead of a String.
makeFigRef' :: UID -> Reference Source #
Variants of makeFigRef that takes a UID instead of a String.
makeSecRef' :: UID -> Sentence -> Reference Source #
Variants of makeSecRef that takes a UID instead of a String.
makeEqnRef' :: UID -> Reference Source #
Variants of makeEqnRef that takes a UID instead of a String.
Reference-related Functions
Attach a Reference and a Sentence in different ways.
chgsStart :: (HasShortName x, Referable x) => x -> Sentence -> Sentence Source #
Output is of the form "reference - sentence".
definedIn :: (Referable r, HasShortName r, DefinesQuantity r) => r -> Sentence Source #
definedIn' :: (Referable r, HasShortName r, DefinesQuantity r) => r -> Sentence -> Sentence Source #
definedIn'' :: (Referable r, HasShortName r) => r -> Sentence Source #
definedIn''' :: (Quantity q, Referable r, HasShortName r) => q -> r -> Sentence Source #
Takes a Symbol and its Reference (does not append a period at the
end!). Outputs as "symbol is defined in source".
fromReplace :: (Referable r, HasShortName r, Quantity q) => r -> q -> Sentence Source #
fromSource :: (Referable r, HasShortName r) => r -> Sentence Source #
Wraps "from reference" in parentheses.
fromSources :: (Referable r, HasShortName r) => [r] -> Sentence Source #
Similar to fromSource but takes a list of references instead of one.
fmtU :: MayHaveUnit a => Sentence -> a -> Sentence Source #
Takes an amount as a Sentence and appends a unit to it.
follows :: (Referable r, HasShortName r) => Sentence -> r -> Sentence Source #
Appends "following reference" to the end of a Sentence.
makeListRef :: [a] -> Section -> [Sentence] Source #
Takes a list and a Section, then generates a list of that section's reference to
match the length of the list.
Sentence-related Functions
See Reference-related Functions as well.
maybeChanged :: Sentence -> Sentence -> Sentence Source #
Helper functions for making likely change statements. Uses form .likelyFrame parameter1 _ parameter2
maybeExpanded :: Sentence -> Sentence -> Sentence Source #
Helper functions for making likely change statements. Uses form .likelyFrame parameter1 _ parameter2
maybeWOVerb :: Sentence -> Sentence -> Sentence Source #
Helper functions for making likely change statements. Uses form .likelyFrame parameter1 _ parameter2
substitute :: (Referable r, HasShortName r, DefinesQuantity r) => [r] -> Sentence Source #
Takes a list of Referables and Symbols and outputs as a Sentence "By substituting symbols, this can be written as:".
typUncr :: (Double, Maybe Int) -> Sentence Source #
Formats typical uncertainty data to be displayed.
underConsidertn :: ConceptChunk -> Sentence Source #
Returns the Sentence "The chunk under consideration is chunkDefinition".
fterms :: (NamedIdea c, NamedIdea d) => (NP -> NP -> t) -> c -> d -> t Source #
Apply a binary function to the terms of two named ideas, instead of to the named
ideas themselves. Ex. fterms compoundPhrase t1 t2 instead of
compoundPhrase (t1 ^. term) (t2 ^. term).
eqnWSource :: (Referable r, HasShortName r) => ModelExpr -> r -> Sentence Source #
Takes an expression and a Referable and outputs as a Sentence "expression (source)".
List-related Functions
makeTMatrix :: Eq a => [Sentence] -> [[a]] -> [a] -> [[Sentence]] Source #
Makes a traceability matrix from a list of row titles, a list of rows of "checked" columns, and a list of columns.
mkTableFromColumns :: [(Sentence, [Sentence])] -> ([Sentence], [[Sentence]]) Source #
Helper for making a table from a columns.
noRefs :: [ItemType] -> [(ItemType, Maybe String)] Source #
Converts lists of simple ItemTypes into a list which may be used
in Contents but is not directly referable.
refineChain :: NamedIdea c => [(c, Section)] -> Sentence Source #
Create a list in the pattern of "The __ are refined to the __". Note: Order matters!
tAndDOnly :: Concept s => s -> ItemType Source #
Helpful combinators for making Sentences into Terminologies with Definitions.
Returns of the form: "term - termDefinition".
tAndDWAcc :: Concept s => s -> ItemType Source #
Helpful combinators for making Sentences into Terminologies with Definitions.
Returns of the form: "term (abbreviation) - termDefinition".
tAndDWSym :: (Concept s, Quantity a) => s -> a -> ItemType Source #
Helpful combinators for making Sentences into Terminologies with Definitions.
Returns of the form: "term (symbol) - termDefinition".
zipSentList :: [[Sentence]] -> [Sentence] -> [[Sentence]] -> [[Sentence]] Source #
Distributes a list of Sentences by prepending individual Sentences once to an existing list of Sentences.
For example:
>>>zipSentList [S "Hi", S "Hey", S "Hi"] [[S "Hello"], [S "World"], [S "Hello", S "World"]][[S "Hi", S "Hello"], [S "Hey", S "World"], [S "Hi", S "Hello", S "World"]]