-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial work on replacing Doc with HelpDoc and AnsiDoc. Not compiling
yet.
- Loading branch information
Showing
6 changed files
with
162 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
module Options.Applicative.Help.HelpDoc | ||
( HelpDoc, | ||
HelpType (..), | ||
ansiDocToHelpDoc, | ||
helpDocToAnsiDoc, | ||
annotateHelp, | ||
annotateStyle, | ||
) | ||
where | ||
|
||
import Options.Applicative.Help.Pretty (AnsiDoc, AnsiStyle, annotate, reAnnotate) | ||
import qualified Prettyprinter as PP | ||
import Prelude | ||
|
||
type HelpDoc = PP.Doc HelpAnn | ||
|
||
data HelpAnn = HelpAnnType HelpType | HelpAnnStyle AnsiStyle | ||
|
||
data HelpType = CmdName | OptionName | Description | Title | Metavar | ||
|
||
annotateHelp :: HelpType -> HelpDoc -> HelpDoc | ||
annotateHelp helpType = annotate $ HelpAnnType helpType | ||
|
||
annotateStyle :: AnsiStyle -> HelpDoc -> HelpDoc | ||
annotateStyle ansiStyle = annotate $ HelpAnnStyle ansiStyle | ||
|
||
ansiDocToHelpDoc :: AnsiDoc -> HelpDoc | ||
ansiDocToHelpDoc = reAnnotate HelpAnnStyle | ||
|
||
helpDocToAnsiDoc :: HelpDoc -> AnsiDoc | ||
-- TODO(Martin): I will want to probably use reAnnotate here -> for each HelpAnn, I will generate 0 | ||
-- to N AnsiStyle annotations. However maybe I should not do this for Docs, but for SimpleDocStream, | ||
-- as they recommended! So maybe we should not implement this function, but instead one that does | ||
-- SimpleDocStream HelpAnn -> SimpleDocStream AnsiStyle. | ||
helpDocToAnsiDoc = error "TODO" |
Oops, something went wrong.