@@ -36,7 +36,6 @@ import Prelude hiding (any)
36
36
37
37
import Options.Applicative.Common
38
38
import Options.Applicative.Types
39
- import Options.Applicative.Help.Ann
40
39
import Options.Applicative.Help.Chunk
41
40
import Options.Applicative.Help.Pretty
42
41
@@ -57,7 +56,7 @@ safelast = foldl' (const Just) Nothing
57
56
58
57
-- | Generate description for a single option.
59
58
optDesc :: ParserPrefs -> OptDescStyle -> ArgumentReachability -> Option a -> (Chunk Doc , Parenthetic )
60
- optDesc pprefs style _reachability opt = first (annTrace 2 " optDesc " ) $
59
+ optDesc pprefs style _reachability opt =
61
60
let names =
62
61
sort . optionNames . optMain $ opt
63
62
meta =
@@ -96,7 +95,7 @@ optDesc pprefs style _reachability opt = first (annTrace 2 "optDesc") $
96
95
97
96
-- | Generate descriptions for commands.
98
97
cmdDesc :: ParserPrefs -> Parser a -> [(Maybe String , Chunk Doc )]
99
- cmdDesc pprefs = fmap ( fmap (annTrace 2 " cmdDesc " )) <$> mapParser desc
98
+ cmdDesc pprefs = mapParser desc
100
99
where
101
100
desc _ opt =
102
101
case optMain opt of
@@ -111,18 +110,18 @@ cmdDesc pprefs = fmap (fmap (annTrace 2 "cmdDesc")) <$> mapParser desc
111
110
112
111
-- | Generate a brief help text for a parser.
113
112
briefDesc :: ParserPrefs -> Parser a -> Chunk Doc
114
- briefDesc = fmap (annTrace 2 " briefDesc " ) . briefDesc' True
113
+ briefDesc = briefDesc' True
115
114
116
115
-- | Generate a brief help text for a parser, only including mandatory
117
116
-- options and arguments.
118
117
missingDesc :: ParserPrefs -> Parser a -> Chunk Doc
119
- missingDesc = fmap (annTrace 2 " missingDesc " ) . briefDesc' False
118
+ missingDesc = briefDesc' False
120
119
121
120
-- | Generate a brief help text for a parser, allowing the specification
122
121
-- of if optional arguments are show.
123
122
briefDesc' :: Bool -> ParserPrefs -> Parser a -> Chunk Doc
124
- briefDesc' showOptional pprefs = fmap (annTrace 2 " briefDesc' " )
125
- . wrapOver NoDefault MaybeRequired
123
+ briefDesc' showOptional pprefs =
124
+ wrapOver NoDefault MaybeRequired
126
125
. foldTree pprefs style
127
126
. mfilterOptional
128
127
. treeMapParser (optDesc pprefs style)
@@ -141,19 +140,15 @@ briefDesc' showOptional pprefs = fmap (annTrace 2 "briefDesc'")
141
140
-- | Wrap a doc in parentheses or brackets if required.
142
141
wrapOver :: AltNodeType -> Parenthetic -> (Chunk Doc , Parenthetic ) -> Chunk Doc
143
142
wrapOver altnode mustWrapBeyond (chunk, wrapping)
144
- | chunkIsEffectivelyEmpty chunk =
145
- annTrace 3 " wrapOver0" <$> chunk
146
- | altnode == MarkDefault =
147
- annTrace 3 " wrapOver1" <$> fmap brackets chunk
148
- | wrapping > mustWrapBeyond =
149
- annTrace 3 " wrapOver2" <$> fmap parens chunk
150
- | otherwise =
151
- annTrace 3 " wrapOver3" chunk
143
+ | chunkIsEffectivelyEmpty chunk = chunk
144
+ | altnode == MarkDefault = fmap brackets chunk
145
+ | wrapping > mustWrapBeyond = fmap parens chunk
146
+ | otherwise = chunk
152
147
153
148
-- Fold a tree of option docs into a single doc with fully marked
154
149
-- optional areas and groups.
155
150
foldTree :: ParserPrefs -> OptDescStyle -> OptTree (Chunk Doc , Parenthetic ) -> (Chunk Doc , Parenthetic )
156
- foldTree _ _ (Leaf x) = first (annTrace 3 " foldTree1 " )
151
+ foldTree _ _ (Leaf x) =
157
152
x
158
153
foldTree prefs s (MultNode xs) =
159
154
( let generous :: Chunk Doc
@@ -179,7 +174,7 @@ foldTree prefs s (MultNode xs) =
179
174
leads :: [Chunk Doc ]
180
175
leads = fmap pure (pretty " " : repeat (line <> pretty " " ))
181
176
182
- foldTree prefs s (AltNode b xs) = first (annTrace 3 " foldTree2 " ) $
177
+ foldTree prefs s (AltNode b xs) =
183
178
(\ x -> (x, NeverRequired ))
184
179
. fmap groupOrNestLine
185
180
. wrapOver b MaybeRequired
@@ -211,7 +206,7 @@ foldTree prefs s (AltNode b xs) = first (annTrace 3 "foldTree2") $
211
206
leads :: [Chunk Doc ]
212
207
leads = fmap pure (pretty " " : repeat (line <> pretty " | " ))
213
208
214
- foldTree prefs s (BindNode x) = first (annTrace 3 " foldTree3 " ) $
209
+ foldTree prefs s (BindNode x) =
215
210
let rendered =
216
211
wrapOver NoDefault NeverRequired (foldTree prefs s x)
217
212
@@ -223,17 +218,17 @@ foldTree prefs s (BindNode x) = first (annTrace 3 "foldTree3") $
223
218
224
219
-- | Generate a full help text for a parser
225
220
fullDesc :: ParserPrefs -> Parser a -> Chunk Doc
226
- fullDesc = fmap (annTrace 2 " fullDesc " ) <$> optionsDesc False
221
+ fullDesc = optionsDesc False
227
222
228
223
-- | Generate a help text for the parser, showing
229
224
-- only what is relevant in the "Global options: section"
230
225
globalDesc :: ParserPrefs -> Parser a -> Chunk Doc
231
- globalDesc = fmap (annTrace 2 " globalDesc " ) <$> optionsDesc True
226
+ globalDesc = optionsDesc True
232
227
233
228
-- | Common generator for full descriptions and globals
234
229
optionsDesc :: Bool -> ParserPrefs -> Parser a -> Chunk Doc
235
- optionsDesc global pprefs = fmap (annTrace 2 " optionsDesc " )
236
- . tabulate (prefTabulateFill pprefs)
230
+ optionsDesc global pprefs =
231
+ tabulate (prefTabulateFill pprefs)
237
232
. catMaybes
238
233
. mapParser doc
239
234
where
@@ -292,7 +287,7 @@ parserHelp pprefs p =
292
287
vcatChunks (snd <$> a)
293
288
group_title _ = mempty
294
289
295
- with_title title = annTrace 1 " with_title " . fmap (string title .$. )
290
+ with_title title = fmap (string title .$. )
296
291
297
292
298
293
parserGlobals :: ParserPrefs -> Parser a -> ParserHelp
@@ -305,7 +300,7 @@ parserGlobals pprefs p =
305
300
306
301
-- | Generate option summary.
307
302
parserUsage :: ParserPrefs -> Parser a -> String -> Doc
308
- parserUsage pprefs p progn = annTrace 2 " parserUsage " $
303
+ parserUsage pprefs p progn =
309
304
case prefUsageOverflow pprefs of
310
305
UsageOverflowAlign ->
311
306
hsep
0 commit comments