@@ -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)
@@ -142,18 +141,17 @@ briefDesc' showOptional pprefs = fmap (annTrace 2 "briefDesc'")
142
141
wrapOver :: AltNodeType -> Parenthetic -> (Chunk Doc , Parenthetic ) -> Chunk Doc
143
142
wrapOver altnode mustWrapBeyond (chunk, wrapping)
144
143
| chunkIsEffectivelyEmpty chunk =
145
- annTrace 3 " wrapOver0 " <$> chunk
144
+ chunk
146
145
| altnode == MarkDefault =
147
- annTrace 3 " wrapOver1 " <$> fmap brackets chunk
146
+ fmap brackets chunk
148
147
| wrapping > mustWrapBeyond =
149
- annTrace 3 " wrapOver2" <$> fmap parens chunk
150
- | otherwise =
151
- annTrace 3 " wrapOver3" chunk
148
+ fmap parens chunk
149
+ | otherwise = chunk
152
150
153
151
-- Fold a tree of option docs into a single doc with fully marked
154
152
-- optional areas and groups.
155
153
foldTree :: ParserPrefs -> OptDescStyle -> OptTree (Chunk Doc , Parenthetic ) -> (Chunk Doc , Parenthetic )
156
- foldTree _ _ (Leaf x) = first (annTrace 3 " foldTree1 " )
154
+ foldTree _ _ (Leaf x) =
157
155
x
158
156
foldTree prefs s (MultNode xs) =
159
157
( let generous :: Chunk Doc
@@ -179,7 +177,7 @@ foldTree prefs s (MultNode xs) =
179
177
leads :: [Chunk Doc ]
180
178
leads = fmap pure (pretty " " : repeat (line <> pretty " " ))
181
179
182
- foldTree prefs s (AltNode b xs) = first (annTrace 3 " foldTree2 " ) $
180
+ foldTree prefs s (AltNode b xs) =
183
181
(\ x -> (x, NeverRequired ))
184
182
. fmap groupOrNestLine
185
183
. wrapOver b MaybeRequired
@@ -211,7 +209,7 @@ foldTree prefs s (AltNode b xs) = first (annTrace 3 "foldTree2") $
211
209
leads :: [Chunk Doc ]
212
210
leads = fmap pure (pretty " " : repeat (line <> pretty " | " ))
213
211
214
- foldTree prefs s (BindNode x) = first (annTrace 3 " foldTree3 " ) $
212
+ foldTree prefs s (BindNode x) =
215
213
let rendered =
216
214
wrapOver NoDefault NeverRequired (foldTree prefs s x)
217
215
@@ -223,21 +221,17 @@ foldTree prefs s (BindNode x) = first (annTrace 3 "foldTree3") $
223
221
224
222
-- | Generate a full help text for a parser
225
223
fullDesc :: ParserPrefs -> Parser a -> Chunk Doc
226
- fullDesc = fmap (annTrace 2 " fullDesc " ) <$> optionsDesc False
224
+ fullDesc = optionsDesc False
227
225
228
226
-- | Generate a help text for the parser, showing
229
227
-- only what is relevant in the "Global options: section"
230
228
globalDesc :: ParserPrefs -> Parser a -> Chunk Doc
231
- globalDesc = fmap (annTrace 2 " globalDesc " ) <$> optionsDesc True
229
+ globalDesc = optionsDesc True
232
230
233
231
-- | Common generator for full descriptions and globals
234
232
optionsDesc :: Bool -> ParserPrefs -> Parser a -> Chunk Doc
235
- optionsDesc global pprefs = fmap (annTrace 2 " optionsDesc" )
236
- . tabulate (prefTabulateFill pprefs)
237
- . catMaybes
238
- . mapParser doc
233
+ optionsDesc global pprefs = tabulate (prefTabulateFill pprefs) . catMaybes . mapParser doc
239
234
where
240
- doc :: MonadPlus m => ArgumentReachability -> Option a -> m (Doc , Doc )
241
235
doc info opt = do
242
236
guard . not . isEmpty $ n
243
237
guard . not . isEmpty $ h
@@ -292,7 +286,7 @@ parserHelp pprefs p =
292
286
vcatChunks (snd <$> a)
293
287
group_title _ = mempty
294
288
295
- with_title title = annTrace 1 " with_title " . fmap (string title .$. )
289
+ with_title title = fmap (string title .$. )
296
290
297
291
298
292
parserGlobals :: ParserPrefs -> Parser a -> ParserHelp
@@ -305,7 +299,7 @@ parserGlobals pprefs p =
305
299
306
300
-- | Generate option summary.
307
301
parserUsage :: ParserPrefs -> Parser a -> String -> Doc
308
- parserUsage pprefs p progn = annTrace 2 " parserUsage " $
302
+ parserUsage pprefs p progn =
309
303
case prefUsageOverflow pprefs of
310
304
UsageOverflowAlign ->
311
305
hsep
0 commit comments