something like this::
# Basic features of the handin
- @packaging
+ #@packaging
#:ftbfs_all
#:missing_readme
#:readme_no_commentary
# Automated test result section
# Un-comment the appropriate directive for each test failed.
- @tests
+ #@tests
#:ftbfs_all
#:simple_test
#:more_interesting_test
Lines that begin with ``#`` and not ``#!`` will be copied into the skeleton.
Lines beginning with ``#!`` will be ignored entirely, except for some
-additional advanced handling in comments immediately before a ``@`` section
-heading:
+additional advanced handling:
* ``#!\n`` (yes, a literal backslash) will cause an empty line to be emitted
into the skeleton if the containing section is not being skipped.
import Grade.Types
import Grade.Parse (commentStart, commentEnd)
-interpSectionComments :: Bool -> [T.Text] -> Doc e
-interpSectionComments f0 = vcat . go f0
+interpComments :: Bool -> [T.Text] -> Maybe (Doc e)
+interpComments f0 t0 = let r = go f0 t0 in if null r then Nothing else Just (vcat r)
where
go _ [] = []
go _ ("#!noskip":bs) = go False bs
vcat $ punctuate line
$ flip fmap sl
$ \(sn, ExSec (Sec _ _ shidden scl _ sds msh)) ->
- let scl' = interpSectionComments shidden scl in
+ let ic = interpComments shidden in
+ let scl' = ic scl in
if shidden
- then scl'
- else scl'
- `above` "@" <> pretty (unSN sn) <> maybe empty ((empty <+>) . pretty) (fst msh)
- `above` prettyDings sds (vcat [empty, commentStart, empty, commentEnd])
+ then maybe empty id scl'
+ else maybe id above scl' $
+ "#@" <> pretty (unSN sn) <> maybe empty ((empty <+>) . pretty) (fst msh)
+ `above` prettyDings ic sds (vcat [empty, commentStart, empty, commentEnd])
where
- prettyDings [] = id
- prettyDings ds = (indent 1 (vcat $ map prettyDing ds) `above`)
+ prettyDings _ [] = id
+ prettyDings ic ds = (indent 1 (vcat $ map (prettyDing ic) ds) `above`)
- prettyDing (dn, DingDefn _ _ mult dcl) =
- (if not (null dcl)
- then (above (vcat (map pretty dcl)) . indent 1)
- else id)
+ prettyDing ic (dn, DingDefn _ _ mult dcl) =
+ maybe id (\c -> above c . indent 1) (ic dcl)
$ "#:" <> pretty (unDN dn)
<> (if mult then " # repeat as needed" else empty)