module Drasil.Sections.TableOfAbbAndAcronyms
(tableAbbAccGen, tableAbbAccRef) where
import Language.Drasil
import Data.Drasil.Concepts.Documentation (abbreviation, fullForm, abbAcc)
import Control.Lens ((^.))
import Data.List (sortBy)
import Data.Function (on)
import Drasil.Sections.ReferenceMaterial (emptySectSentPlu)
select :: (Idea s) => [s] -> [(String, s)]
select :: forall s. Idea s => [s] -> [(String, s)]
select [] = []
select (s
x:[s]
xs) = case forall c. Idea c => c -> Maybe String
getA s
x of
Maybe String
Nothing -> forall s. Idea s => [s] -> [(String, s)]
select [s]
xs
Just String
y -> (String
y, s
x) forall a. a -> [a] -> [a]
: forall s. Idea s => [s] -> [(String, s)]
select [s]
xs
tableAbbAccGen :: (Idea s) => [s] -> LabelledContent
tableAbbAccGen :: forall s. Idea s => [s] -> LabelledContent
tableAbbAccGen [] = Reference -> RawContent -> LabelledContent
llcc Reference
tableAbbAccRef forall a b. (a -> b) -> a -> b
$ Sentence -> RawContent
Paragraph forall a b. (a -> b) -> a -> b
$ forall n. NamedIdea n => [n] -> Sentence
emptySectSentPlu [IdeaDict
abbAcc]
tableAbbAccGen [s]
ls = let chunks :: [(String, s)]
chunks = forall a. (a -> a -> Ordering) -> [a] -> [a]
sortBy (forall a. Ord a => a -> a -> Ordering
compare forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
`on` forall a b. (a, b) -> a
fst) forall a b. (a -> b) -> a -> b
$ forall s. Idea s => [s] -> [(String, s)]
select [s]
ls in
Reference -> RawContent -> LabelledContent
llcc Reference
tableAbbAccRef forall a b. (a -> b) -> a -> b
$ [Sentence] -> [[Sentence]] -> Sentence -> Bool -> RawContent
Table
(forall a b. (a -> b) -> [a] -> [b]
map forall n. NamedIdea n => n -> Sentence
titleize [IdeaDict
abbreviation, IdeaDict
fullForm]) (forall a b. [a -> b] -> [a] -> [[b]]
mkTable
[\(String
a,s
_) -> String -> Sentence
S String
a,
\(String
_,s
b) -> forall n. NamedIdea n => n -> Sentence
titleize s
b]
[(String, s)]
chunks)
(forall n. NamedIdea n => n -> Sentence
titleize' IdeaDict
abbAcc) Bool
True
tableAbbAccRef :: Reference
tableAbbAccRef :: Reference
tableAbbAccRef = UID -> Reference
makeTabRef' forall a b. (a -> b) -> a -> b
$ IdeaDict
abbAcc forall s a. s -> Getting a s a -> a
^. forall c. HasUID c => Lens' c UID
uid