Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
kostmo committed Mar 30, 2023
1 parent b28db54 commit b8b6995
Showing 1 changed file with 24 additions and 16 deletions.
40 changes: 24 additions & 16 deletions src/Swarm/Docs/Pedagogy.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
-- SPDX-License-Identifier: BSD-3-Clause
--
-- Assess pedagogical soundness of the tutorials.
--
-- Approach:
-- 1. Obtain a list of all of the tutorial scenarios, in order
-- 2. Search their "solution" code for `commands`
-- 3. "fold" over the tutorial list, noting which tutorial was first to introduce each command
module Swarm.Docs.Pedagogy (
renderTutorialProgression,
generateIntroductionsSequence,
Expand All @@ -22,11 +27,11 @@ import Data.Map qualified as M
import Data.Maybe (mapMaybe)
import Data.Set (Set)
import Data.Set qualified as S
import Data.Text qualified as T
import Data.Text (Text)
import Data.Text qualified as T
import Swarm.Docs.Util
import Swarm.Game.Entity (loadEntities)
import Swarm.Game.Scenario (Scenario, scenarioDescription, scenarioObjectives, scenarioSolution, scenarioName)
import Swarm.Game.Scenario (Scenario, scenarioDescription, scenarioName, scenarioObjectives, scenarioSolution)
import Swarm.Game.Scenario.Objective (objectiveGoal)
import Swarm.Game.ScenarioInfo (ScenarioCollection, ScenarioInfoPair, flatten, loadScenariosWithWarnings, scenarioCollectionToList, scenarioPath)
import Swarm.Language.Module (Module (..))
Expand Down Expand Up @@ -156,27 +161,30 @@ loadScenarioCollection = simpleErrorHandle $ do
renderUsagesMarkdown :: Int -> CoverageInfo -> Text
renderUsagesMarkdown idx (CoverageInfo (TutorialInfo (s, si) _sCmds dCmds) novelCmds) =
T.unlines $
"" :
firstLine
""
: firstLine
: "================"
: otherLines
where
otherLines = concat
[ pure $ "`" <> T.pack (view scenarioPath si) <> "`"
, [""]
, pure $ "*" <> T.strip (view scenarioDescription s) <> "*"
, [""]
, renderSection "Commands introduced in this solution" $ renderCmds novelCmds
, [""]
, renderSection "Commands found in description" $ renderCmds dCmds
]
otherLines =
concat
[ pure $ "`" <> T.pack (view scenarioPath si) <> "`"
, [""]
, pure $ "*" <> T.strip (view scenarioDescription s) <> "*"
, [""]
, renderSection "Commands introduced in this solution" $ renderCmds novelCmds
, [""]
, renderSection "Commands found in description" $ renderCmds dCmds
]

renderSection title content =
[title, "----------------"] <> content

renderCmds cmds = pure $ if null cmds
then "<none>"
else commaList . map linkifyCommand . sort . map (T.pack . show) . S.toList $ cmds
renderCmds cmds =
pure $
if null cmds
then "<none>"
else commaList . map linkifyCommand . sort . map (T.pack . show) . S.toList $ cmds

linkifyCommand c = "[" <> c <> "](" <> commandsWikiPrefix <> c <> ")"

Expand Down

0 comments on commit b8b6995

Please sign in to comment.