diff --git a/app/fetcher/src/CommentRender.hs b/app/fetcher/src/CommentRender.hs index be0ca35..1129f28 100644 --- a/app/fetcher/src/CommentRender.hs +++ b/app/fetcher/src/CommentRender.hs @@ -1,8 +1,9 @@ + {-# LANGUAGE OverloadedStrings #-} module CommentRender where -import Data.List (partition) +import Data.List (dropWhileEnd, partition) import Data.List.NonEmpty (NonEmpty ((:|))) import qualified Data.List.NonEmpty as NE import Data.Set (Set) @@ -162,13 +163,13 @@ genBuildFailuresTable gen_matched_build_section idx (CommitBuilds.BuildWithLogContext (CommitBuilds.NewCommitBuild (Builds.StorableBuild (DbHelpers.WithId ubuild_id universal_build) build_obj) match_obj _ _) (CommitBuilds.LogContext _ log_lines)) = [ M.heading 4 $ T.unwords [ circleci_image_link - , Builds.job_name build_obj + , job_name , M.parens $ T.pack $ MyUtils.renderFrac idx $ length non_upstream_breakages ] , T.unwords summary_info_pieces - ] <> code_block_lines + ] <> M.detailsExpander (M.tagElement "code" $ MatchOccurrences._line_text match_obj) code_block_lines where --- job_name = Builds.job_name build_obj + job_name = Builds.job_name build_obj summary_info_pieces = [ M.bold "Step:" @@ -180,7 +181,7 @@ genBuildFailuresTable code_block_lines = NE.toList $ M.codeBlockFromList $ -- NOTE: this commented-out code just renders the single matched line -- pure $ MatchOccurrences._line_text match_obj - map renderLogLineTuple log_lines + dropWhileEnd T.null $ map renderLogLineTuple log_lines (Builds.NewBuildNumber provider_build_number) = Builds.provider_buildnum universal_build diff --git a/app/markdown-dsl/src/Markdown.hs b/app/markdown-dsl/src/Markdown.hs index 0fd427d..b72cf0a 100644 --- a/app/markdown-dsl/src/Markdown.hs +++ b/app/markdown-dsl/src/Markdown.hs @@ -15,7 +15,7 @@ import qualified HTMLEntities.Builder as HEB import Data.Text.Lazy.Builder (toLazyText) -surround :: [Text] -> Text -> Text +surround :: (Monoid a) => [a] -> a -> a surround brackets = mconcat . (`intersperse` brackets) @@ -40,7 +40,7 @@ codeInline = surround2 "`" sup :: Text -> Text -sup = surround ["", ""] +sup = tagElement "sup" parens :: Text -> Text @@ -51,6 +51,26 @@ bracket :: Text -> Text bracket = surround ["[", "]"] +angleBracket :: Text -> Text +angleBracket = surround ["<", ">"] + + +tagElement :: Text -> Text -> Text +tagElement tag_name = + surround [opening_tag, closing_tag] + where + opening_tag = angleBracket tag_name + closing_tag = angleBracket $ "/" <> tag_name + + +tagElementMultiline :: Text -> [Text] -> [Text] +tagElementMultiline tag_name content = + [opening_tag] ++ content ++ [closing_tag] + where + opening_tag = angleBracket tag_name + closing_tag = angleBracket $ "/" <> tag_name + + supTitle :: Text -> Text -> Text supTitle title = surround brackets where @@ -129,6 +149,15 @@ commaize :: [Text] -> Text commaize = terminate "," +-- | Note that the empty lines padding the markdown +-- inside the html tags are necessary, *as well as* +-- the trailing blank line *after* the closing html tag. +detailsExpander :: Text -> [Text] -> [Text] +detailsExpander heading details = x ++ [""] + where + x = tagElementMultiline "details" $ tagElementMultiline "summary" [heading] <> ([""] ++ details ++ [""]) + + -- | Inserts blank lines between each element paragraphs :: [Text] -> Text paragraphs = T.unlines . intersperse "" diff --git a/app/static/index.html b/app/static/index.html index ea8ba91..1303051 100644 --- a/app/static/index.html +++ b/app/static/index.html @@ -34,7 +34,7 @@