Skip to content

Commit

Permalink
Refactor documentation sections:
Browse files Browse the repository at this point in the history
- Restructure `introInfo` to focus on `motivation` and `purpose`.
- Adjust `whatInfo` to address `background` and `scope`.
  • Loading branch information
Xinlu-Y committed Sep 3, 2024
1 parent 2de0bd8 commit 915505d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ makeReadMe ReadMeInfo {
folderNum = number,
inputOutput = inoutf} =
makeMd [introInfo name auths (fieldEmptySTR motiv)
(fieldEmptySTR purp)
(fieldEmptySTR sc),
whatInfo $ fieldEmptySTR descr,
(fieldEmptySTR purp),
whatInfo (fieldEmptySTR descr) (fieldEmptySTR sc),
makeInstr imptype configFPs name inoutf,
verInfo progLang progLangVers,
unsupOS unsupportedOSs,
Expand Down
20 changes: 10 additions & 10 deletions code/drasil-printers/lib/Language/Drasil/Markdown/CreateMd.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,25 @@ makeMd :: [Doc] -> Doc
makeMd = vcat . punctuate secSep . filterEmpty

-- | Example title, authors, and maybe purpose section.
introInfo :: String -> [String] -> Maybe String -> Maybe String -> Maybe String -> Doc
introInfo name auths motiv descr sc = introSec (text name) (listToDoc auths) (length auths)
(maybeSub "Motivation" motiv) (maybeSub "Purpose" descr) (maybeSub "Scope" sc)
introInfo :: String -> [String] -> Maybe String -> Maybe String -> Doc
introInfo name auths motiv descr = introSec (text name) (listToDoc auths) (length auths)
(maybeSub "Motivation" motiv) (maybeSub "Purpose" descr)

-- | Instruction section, contains 4 paragraphs, Running, Building, Input-Output and Config Files.
-- The Config file section is only displayed if there are configuration files.
instDoc :: [String] -> String -> (String, String) -> Doc
instDoc cfp name inoutn = regularSec (text "Making Examples")
(runInstDoc inoutn <> doubleSep <> makeInstDoc) <> inOutFile name inoutn <> configSec cfp

-- | 'What' section in generated README file, displays description and scope if not empty
whatInfo :: Maybe String -> Maybe String -> Doc
whatInfo descr sc = regularSec (text "What") (maybeSub "Background" descr <> maybeSub "Scope" sc)

-- | Helper for creating optional Intro subsection as Doc
maybeSub :: String -> Maybe String -> Doc
maybeSub role = maybe empty (\content-> doubleSep <> text ("> " ++ role ++ ":")
<+> upcase content)

-- | 'What' section in generated README file, does not display if empty
whatInfo :: Maybe String -> Doc
whatInfo = maybe empty (regularSec (text "What") . text)

-- | Helper for giving instructions on the command line.
commandLine :: Doc
commandLine = text $ "In your terminal command line, enter the same directory as this " ++
Expand Down Expand Up @@ -131,9 +131,9 @@ bkQuote3 = text "```"
-- FIXME as explained in #2224 we still need to add in the purpose section,
-- this could be done by adding a third parameter to introSec
-- | Constructs introduction section from header and message.
introSec :: Doc -> Doc -> Int -> Doc -> Doc -> Doc -> Doc
introSec hd ms1 l motiv descr sc = text "#" <+> hd <+> contSep <> (if l == 1 then text "> Author:" else text "> Authors: ")
<+> ms1 <> motiv <> descr <> sc
introSec :: Doc -> Doc -> Int -> Doc -> Doc -> Doc
introSec hd ms1 l motiv purp = text "#" <+> hd <+> contSep <> (if l == 1 then text "> Author:" else text "> Authors: ")
<+> ms1 <> motiv <> purp

-- | Constructs regular section section from header and message.
regularSec :: Doc -> Doc -> Doc
Expand Down

0 comments on commit 915505d

Please sign in to comment.