@@ -5,6 +5,7 @@ module OpenAPI.Checker.Report
55 , Pandoc
66 , ReportConfig (..)
77 , ReportTreeStyle (..)
8+ , ReportMode (..)
89 )
910where
1011
@@ -56,18 +57,26 @@ data ReportStatus
5657 -- there actually are any breaking changes.
5758 OnlyUnsupportedChanges
5859
60+data ReportMode = OnlyErrors | All
61+ deriving stock (Eq)
62+
5963data ReportConfig = ReportConfig
6064 { treeStyle :: ReportTreeStyle
65+ , reportMode :: ReportMode
6166 }
6267
6368instance Default ReportConfig where
6469 def =
6570 ReportConfig
6671 { treeStyle = HeadersTreeStyle
72+ , reportMode = All
6773 }
6874
6975data ReportTreeStyle = HeadersTreeStyle | FoldingBlockquotesTreeStyle
7076
77+twoRowTable :: [(Inlines, Inlines)] -> Blocks
78+twoRowTable x = simpleTable (para . fst <$> x) [para . snd <$> x]
79+
7180generateReport :: ReportConfig -> ReportInput -> (Pandoc, ReportStatus)
7281generateReport cfg inp =
7382 let partitionUnsupported = P.partition (\(AnIssue _ i) -> issueIsUnsupported i)
@@ -77,23 +86,34 @@ generateReport cfg inp =
7786 breakingChangesPresent = not $ P.null breaking
7887 nonBreakingChangesPresent = not $ P.null nonBreaking
7988 unsupportedChangesPresent = not $ P.null unsupported
89+ nonBreakingChangesShown = case reportMode cfg of
90+ All -> True
91+ OnlyErrors -> False
8092 builder = buildReport cfg
8193 report =
8294 doc $
8395 header 1 "Summary"
84− <> simpleTable
85− (para
86− <$> [ refOpt breakingChangesPresent breakingChangesId "⚠️ Breaking changes"
87− , refOpt nonBreakingChangesPresent nonBreakingChangesId "🙆 Non-breaking changes"
88− , refOpt unsupportedChangesPresent unsupportedChangesId "🤷 Unsupported feature changes"
89− ])
90− [para . show' <$> [P.size breaking, P.size nonBreaking, P.size unsupported]]
96+ <> twoRowTable
97+ ([ ( refOpt breakingChangesPresent breakingChangesId "⚠️ Breaking changes"
98+ , show' $ P.size breaking
99+ )
100+ ]
101+ ++ when'
102+ nonBreakingChangesShown
103+ [ ( refOpt nonBreakingChangesPresent nonBreakingChangesId "🙆 Non-breaking changes"
104+ , show' $ P.size nonBreaking
105+ )
106+ ]
107+ ++ [ ( refOpt unsupportedChangesPresent unsupportedChangesId "🤷 Unsupported feature changes"
108+ , show' $ P.size unsupported
109+ )
110+ ])
91111 <> when'
92112 breakingChangesPresent
93113 (header 1 (anchor breakingChangesId <> "⚠️ Breaking changes")
94114 <> builder (showErrs breaking))
95115 <> when'
96− nonBreakingChangesPresent
116+ (nonBreakingChangesPresent && nonBreakingChangesShown)
97117 (header 1 (anchor nonBreakingChangesId <> "🙆 Non-breaking changes")
98118 <> builder (showErrs nonBreaking))
99119 <> when'