@@ -5,6 +5,7 @@ module OpenAPI.Checker.Report
6 , ReportConfig (..)
6 , ReportConfig (..)
7 , ReportTreeStyle (..)
7 , ReportTreeStyle (..)
@@ -56,18 +57,26 @@ data ReportStatus
56 -- there actually are any breaking changes.
57 -- there actually are any breaking changes.
57 OnlyUnsupportedChanges
58 OnlyUnsupportedChanges
60+data ReportMode = OnlyErrors | All
59data ReportConfig = ReportConfig
63data ReportConfig = ReportConfig
60 { treeStyle :: ReportTreeStyle
64 { treeStyle :: ReportTreeStyle
65+ , reportMode :: ReportMode
63instance Default ReportConfig where
68instance Default ReportConfig where
65 ReportConfig
70 ReportConfig
66 { treeStyle = HeadersTreeStyle
71 { treeStyle = HeadersTreeStyle
69data ReportTreeStyle = HeadersTreeStyle | FoldingBlockquotesTreeStyle
75data ReportTreeStyle = HeadersTreeStyle | FoldingBlockquotesTreeStyle
77+twoRowTable :: [(Inlines, Inlines)] -> Blocks
78+twoRowTable x = simpleTable (para . fst <$> x) [para . snd <$> x]
71generateReport :: ReportConfig -> ReportInput -> (Pandoc, ReportStatus)
80generateReport :: ReportConfig -> ReportInput -> (Pandoc, ReportStatus)
72generateReport cfg inp =
81generateReport cfg inp =
73 let partitionUnsupported = P.partition (\(AnIssue _ i) -> issueIsUnsupported i)
82 let partitionUnsupported = P.partition (\(AnIssue _ i) -> issueIsUnsupported i)
@@ -77,23 +86,34 @@ generateReport cfg inp =
77 breakingChangesPresent = not $ P.null breaking
86 breakingChangesPresent = not $ P.null breaking
78 nonBreakingChangesPresent = not $ P.null nonBreaking
87 nonBreakingChangesPresent = not $ P.null nonBreaking
79 unsupportedChangesPresent = not $ P.null unsupported
88 unsupportedChangesPresent = not $ P.null unsupported
89+ nonBreakingChangesShown = case reportMode cfg of
80 builder = buildReport cfg
92 builder = buildReport cfg
83 header 1 "Summary"
95 header 1 "Summary"
84− <> simpleTable
96+ <> twoRowTable
86− <$> [ refOpt breakingChangesPresent breakingChangesId "⚠️ Breaking changes"
97+ ([ ( refOpt breakingChangesPresent breakingChangesId "⚠️ Breaking changes"
98+ , show' $ P.size breaking
102+ nonBreakingChangesShown
87− , refOpt nonBreakingChangesPresent nonBreakingChangesId "🙆 Non-breaking changes"
103+ [ ( refOpt nonBreakingChangesPresent nonBreakingChangesId "🙆 Non-breaking changes"
104+ , show' $ P.size nonBreaking
88− , refOpt unsupportedChangesPresent unsupportedChangesId "🤷 Unsupported feature changes"
107+ ++ [ ( refOpt unsupportedChangesPresent unsupportedChangesId "🤷 Unsupported feature changes"
90− [para . show' <$> [P.size breaking, P.size nonBreaking, P.size unsupported]]
108+ , show' $ P.size unsupported
92 breakingChangesPresent
112 breakingChangesPresent
93 (header 1 (anchor breakingChangesId <> "⚠️ Breaking changes")
113 (header 1 (anchor breakingChangesId <> "⚠️ Breaking changes")
94 <> builder (showErrs breaking))
114 <> builder (showErrs breaking))
96− nonBreakingChangesPresent
116+ (nonBreakingChangesPresent && nonBreakingChangesShown)
97 (header 1 (anchor nonBreakingChangesId <> "🙆 Non-breaking changes")
117 (header 1 (anchor nonBreakingChangesId <> "🙆 Non-breaking changes")
98 <> builder (showErrs nonBreaking))
118 <> builder (showErrs nonBreaking))