Skip to content

Commit

Permalink
created HasShortName class and placed it into its own file to avoid o…
Browse files Browse the repository at this point in the history
…rphan instances; need to remove original refAdd
  • Loading branch information
niazim3 committed May 23, 2018
1 parent 1990165 commit 46331be
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
1 change: 0 additions & 1 deletion code/Language/Drasil/Classes.hs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import Language.Drasil.Chunk.Attribute.Core (Attributes)
import Language.Drasil.Chunk.Constrained.Core (Constraint)
import Language.Drasil.Expr (Expr)


import Control.Lens (Lens')

type UID = String
Expand Down
18 changes: 9 additions & 9 deletions code/Language/Drasil/Printing/Import.hs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import Language.Drasil.Unicode (Special(Partial))
import Language.Drasil.Spec (Sentence(..))
import Language.Drasil.Misc (unit'2Contents)
import Language.Drasil.NounPhrase (phrase, titleize)
import Language.Drasil.Reference
import Language.Drasil.Chunk.Attribute.ShortName

import Language.Drasil.Document

Expand Down Expand Up @@ -262,7 +262,7 @@ createLayout sm = map (sec sm 0)
-- | Helper function for creating sections at the appropriate depth
sec :: HasSymbolTable ctx => ctx -> Int -> Section -> T.LayoutObj
sec sm depth x@(Section title contents _) =
let ref = P.S (refAdd x) in
let ref = P.S (shortname x) in
T.HDiv [(concat $ replicate depth "sub") ++ "section"]
(T.Header depth (spec sm title) ref :
map (layout sm depth) contents) ref
Expand All @@ -274,22 +274,22 @@ getSN c = maybe (error "missing attribute ShortName") id $ getShortName c
-- Called internally by layout.
lay :: HasSymbolTable ctx => ctx -> Contents -> T.LayoutObj
lay sm x@(Table hdr lls t b _) = T.Table ["table"]
((map (spec sm) hdr) : (map (map (spec sm)) lls)) (P.S (refAdd x)) b (spec sm t)
((map (spec sm) hdr) : (map (map (spec sm)) lls)) (P.S (shortname x)) b (spec sm t)
lay sm (Paragraph c) = T.Paragraph (spec sm c)
lay sm (EqnBlock c _) = T.HDiv ["equation"] [T.EqnBlock (P.E (expr c sm))] P.EmptyS
-- FIXME: Make equations referable
lay sm x@(Definition c) = T.Definition c (makePairs sm c) (P.S (refAdd x))
lay sm x@(Definition c) = T.Definition c (makePairs sm c) (P.S (shortname x))
lay sm (Enumeration cs) = T.List $ makeL sm cs
lay sm x@(Figure c f wp _) = T.Figure (P.S (refAdd x)) (spec sm c) f wp
lay sm x@(Figure c f wp _) = T.Figure (P.S (shortname x)) (spec sm c) f wp
lay sm x@(Requirement r) = T.ALUR T.Requirement
(spec sm $ requires r) (P.S $ refAdd x) (spec sm $ getSN r)
(spec sm $ requires r) (P.S $ shortname x) (spec sm $ getSN r)
lay sm x@(Assumption a) = T.ALUR T.Assumption
(spec sm (assuming a)) (P.S (refAdd x)) (spec sm $ getSN a)
(spec sm (assuming a)) (P.S (shortname x)) (spec sm $ getSN a)
lay sm x@(Change lc) = T.ALUR
(if (chngType lc) == Likely then T.LikelyChange else T.UnlikelyChange)
(spec sm (chng lc)) (P.S (refAdd x)) (spec sm $ getSN lc)
(spec sm (chng lc)) (P.S (shortname x)) (spec sm $ getSN lc)
lay sm x@(Graph ps w h t _) = T.Graph (map (\(y,z) -> (spec sm y, spec sm z)) ps)
w h (spec sm t) (P.S (refAdd x))
w h (spec sm t) (P.S (shortname x))
lay sm (Defnt dtyp pairs rn) = T.Definition dtyp (layPairs pairs) (P.S rn)
where layPairs = map (\(x,y) -> (x, map (lay sm) y))
lay sm (Bib bib) = T.Bib $ map (layCite sm) bib
Expand Down
1 change: 1 addition & 0 deletions code/drasil.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ library
, Language.Drasil.Chunk.Attribute
, Language.Drasil.Chunk.Attribute.Core
, Language.Drasil.Chunk.Attribute.Derivation
, Language.Drasil.Chunk.Attribute.ShortName
, Language.Drasil.Chunk.Change
, Language.Drasil.Chunk.Citation
, Language.Drasil.Chunk.Code
Expand Down

0 comments on commit 46331be

Please sign in to comment.