-- | Display Drasil documentation nicely for the website.
module Drasil.Website.Documentation where

import Language.Drasil


-- * Haddock Documentation for Drasil Section

-- | Creates the Haddock documentation for all of Drasil.
docsSec :: FilePath -> Section
docsSec :: FilePath -> Section
docsSec FilePath
path = 
  Sentence -> [Contents] -> [Section] -> Reference -> Section
section Sentence
haddockDocsTitle -- Title
  [Sentence -> Contents
mkParagraph forall a b. (a -> b) -> a -> b
$ FilePath -> Sentence
haddockDocsDesc FilePath
path] -- Contents 
  [] forall a b. (a -> b) -> a -> b
$ FilePath -> Sentence -> Reference
makeSecRef FilePath
"Documentation" forall a b. (a -> b) -> a -> b
$ FilePath -> Sentence
S FilePath
"Documentation" -- Section Reference

-- | Haddock Documentation Section title.
haddockDocsTitle :: Sentence
haddockDocsTitle :: Sentence
haddockDocsTitle = FilePath -> Sentence
S FilePath
"Haddock Documentation"

-- | Body paragraph that directs users to the Haddock documentation and a variant with fully exposed modules.
haddockDocsDesc :: FilePath -> Sentence
haddockDocsDesc :: FilePath -> Sentence
haddockDocsDesc FilePath
path = FilePath -> Sentence
S FilePath
"Drasil's framework is primariliy written in Haskell, \
  \so we use Haddock to document our code. The following link will take you \
  \to the current" Sentence -> Sentence -> Sentence
+:+ forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> Sentence -> Sentence
namedRef (FilePath -> Reference
docsRef FilePath
path) (FilePath -> Sentence
S FilePath
"Haddock documentation") 
  Sentence -> Sentence -> Sentence
+:+ FilePath -> Sentence
S FilePath
"for the Drasil framework. A variant with"
  Sentence -> Sentence -> Sentence
+:+ forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> Sentence -> Sentence
namedRef (FilePath -> Reference
fullDocsRef FilePath
path) (FilePath -> Sentence
S FilePath
"fully exposed modules") Sentence -> Sentence -> Sentence
+:+ FilePath -> Sentence
S FilePath
"is also available."

-- | Creates references to the haddock documentation (both normal and full variations).
docsRef, fullDocsRef :: FilePath -> Reference
docsRef :: FilePath -> Reference
docsRef FilePath
path     = FilePath -> FilePath -> ShortName -> Reference
makeURI FilePath
"haddockDocs" (FilePath
path forall a. [a] -> [a] -> [a]
++ FilePath
"index.html") forall a b. (a -> b) -> a -> b
$ Sentence -> ShortName
shortname' forall a b. (a -> b) -> a -> b
$ FilePath -> Sentence
S FilePath
"HaddockDocs"
fullDocsRef :: FilePath -> Reference
fullDocsRef FilePath
path = FilePath -> FilePath -> ShortName -> Reference
makeURI FilePath
"fullHaddockDocs" (FilePath
path forall a. [a] -> [a] -> [a]
++ FilePath
"full/index.html") forall a b. (a -> b) -> a -> b
$ Sentence -> ShortName
shortname' forall a b. (a -> b) -> a -> b
$ FilePath -> Sentence
S FilePath
"fullHaddockDocs"

-- | Gathers all references used in this file.
docRefs :: FilePath -> [Reference]
docRefs :: FilePath -> [Reference]
docRefs FilePath
path = [FilePath -> Reference
docsRef FilePath
path, FilePath -> Reference
fullDocsRef FilePath
path]