]> hydra-www.ietfng.org Git - grade/commitdiff
Skeleton comments changes main
authorNathaniel Wesley Filardo <nwf@cs.jhu.edu>
Wed, 30 Sep 2015 19:21:18 +0000 (15:21 -0400)
committerNathaniel Wesley Filardo <nwf@cs.jhu.edu>
Wed, 30 Sep 2015 19:21:18 +0000 (15:21 -0400)
Allow structured comments everywhere, as we sometimes want #!.

Comment out the @ lines when generating skeletons, so that an unmodified
skeleton elicits an error from grade rather than a default score, which is
a perfect score with the Score modules currently in tree.

README.rst
lib/Grade/Skeleton.hs

index cfe617ada251e701d10246bb5b70540ddc7f2775..265b03d38cef73360077f0b68004b23c4b8889f6 100644 (file)
@@ -42,7 +42,7 @@ The instructor will have prepared a ``skeleton`` file which will look
 something like this::
 
   # Basic features of the handin 
-  @packaging
+  #@packaging
    #:ftbfs_all
    #:missing_readme
    #:readme_no_commentary
@@ -56,7 +56,7 @@ something like this::
 
   # Automated test result section
   # Un-comment the appropriate directive for each test failed.
-  @tests
+  #@tests
    #:ftbfs_all
    #:simple_test
    #:more_interesting_test
@@ -218,8 +218,7 @@ taste.
 
 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.
index 80dd2ab50fc66f11b2dea995f9e39abcde87e35d..59f13d45308b4eabf4172acd99900393431f5f71 100644 (file)
@@ -7,8 +7,8 @@ import           Text.PrettyPrint.Free
 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
@@ -23,20 +23,19 @@ makeSkel (Defs _ sl) =
   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)