Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix issue #1516 #1517

Merged
merged 3 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release notes of Ampersand

## v5.2.4

- [Issue #1516](https://github.com/AmpersandTarski/Ampersand/issues/1516) It is now possible to only generate datamodel images using --datamodelOnly

## v5.2.3 (17 october 2024)

- [Issue #1482](https://github.com/AmpersandTarski/Ampersand/issues/1482) Fix technical debd from merging Ampersand 4 into Ampersand 5
Expand Down
2 changes: 1 addition & 1 deletion ampersand.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ cabal-version: 2.0
-- see: https://github.com/sol/hpack

name: ampersand
version: 5.2.3
version: 5.2.4
synopsis: Toolsuite for automated design of enterprise information systems.
description: You can define your business processes by means of rules, written in Relation Algebra.
category: Database Design
Expand Down
2 changes: 1 addition & 1 deletion package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: ampersand
version: 5.2.3
version: 5.2.4
author: Stef Joosten
maintainer: stef.joosten@ou.nl
synopsis: Toolsuite for automated design of enterprise information systems.
Expand Down
16 changes: 10 additions & 6 deletions src/Ampersand/Commands/Documentation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,13 @@ doGenDocument fSpec = do
let (thePandoc, thePictures) = fSpec2Pandoc env now fSpec
-- First we need to output the pictures, because they should be present
-- before the actual document is written
genGraphics <- view genGraphicsL
when (genGraphics && fspecFormat /= FPandoc)
$ mapM_ writePicture thePictures
genText <- view genTextL
when genText
$ writepandoc fSpec thePandoc
datamodelsOnly <- view genDatamodelOnlyL
if datamodelsOnly
then mapM_ writePicture $ filter isDatamodel thePictures
else do
genGraphics <- view genGraphicsL
when (genGraphics && fspecFormat /= FPandoc)
$ mapM_ writePicture thePictures
genText <- view genTextL
when genText
$ writepandoc fSpec thePandoc
11 changes: 10 additions & 1 deletion src/Ampersand/Graphic/Graphics.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{-# LANGUAGE FlexibleInstances #-}

module Ampersand.Graphic.Graphics (makePicture, writePicture, Picture (..), PictureTyp (..), imagePathRelativeToDirOutput) where
module Ampersand.Graphic.Graphics (makePicture, writePicture, Picture (..), PictureTyp (..), imagePathRelativeToDirOutput, isDatamodel) where

import Ampersand.ADL1
import Ampersand.Basics hiding (Label)
Expand Down Expand Up @@ -69,6 +69,15 @@ instance Named PictureTyp where -- for displaying a fatal error
Just np -> np
)

isDatamodel :: Picture -> Bool
isDatamodel = isDatamodelType . pType

isDatamodelType :: PictureTyp -> Bool
isDatamodelType pt = case pt of
PTLogicalDM {} -> True
PTTechnicalDM {} -> True
_ -> False

makePicture :: (HasOutputLanguage env) => env -> FSpec -> PictureTyp -> Picture
makePicture env fSpec pr =
case pr of
Expand Down
7 changes: 6 additions & 1 deletion src/Ampersand/Misc/HasClasses.hs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ class (HasOutputLanguage a) => HasDocumentOpts a where
genGraphicsL = documentOptsL . lens xgenGraphics (\x y -> x {xgenGraphics = y})
genTextL :: Lens' a Bool -- Generate text. Useful for generating text and graphics separately.
genTextL = documentOptsL . lens xgenText (\x y -> x {xgenText = y})
genDatamodelOnlyL :: Lens' a Bool -- Generate only the datamodel images. This overrides genGraphicsL and genTextL
genDatamodelOnlyL = documentOptsL . lens xgenDatamodelImagesOnly (\x y -> x {xgenDatamodelImagesOnly = y})

instance HasDocumentOpts DocOpts where
documentOptsL = id
Expand Down Expand Up @@ -371,6 +373,8 @@ data DocOpts = DocOpts
xblackWhite :: !Bool,
-- | a list containing all chapters that are required to be in the generated documentation
xchapters :: ![Chapter],
-- | Only generate datamodel images.
xgenDatamodelImagesOnly :: !Bool,
-- | enable/disable generation of graphics. Used to generate text and graphics in separation.
xgenGraphics :: !Bool,
-- | enable/disable generation of text. Used to generate text and graphics in separation.
Expand All @@ -391,7 +395,8 @@ instance HasOptions DocOpts where
[ ("--blackWhite", tshow $ xblackWhite opts)
]
<> fmap chapters [minBound ..]
<> [ ("--[no-]graphics", tshow $ xgenGraphics opts),
<> [ ("--datamodelOnly", tshow $ xgenDatamodelImagesOnly opts),
("--[no-]graphics", tshow $ xgenGraphics opts),
("--[no-]text", tshow $ xgenText opts),
("--format", tshow $ xfspecFormat opts)
]
Expand Down
11 changes: 10 additions & 1 deletion src/Ampersand/Options/DocOptsParser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ docOptsParser =
DocOpts
<$> blackWhiteP
<*> chaptersP
<*> datamodelOnlyP
<*> genGraphicsP
<*> genTextP
<*> fSpecFormatP
Expand Down Expand Up @@ -87,6 +88,8 @@ docOptsParser =
<$> strOption
( long "format"
<> metavar "FORMAT"
<> value "docx"
<> showDefault
<> completeWith (map (T.unpack . stripF) allFormats)
<> help "The format in which the output is written."
)
Expand Down Expand Up @@ -143,7 +146,13 @@ docOptsParser =
<> "black and white."
)
)

datamodelOnlyP :: Parser Bool
datamodelOnlyP =
switch
( long "datamodelOnly"
<> help
"Only generate datamodel images. This implies --no-text"
)
genLegalRefsP :: Parser Bool
genLegalRefsP =
boolFlags
Expand Down