-
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.
Does not compile completely but is starting to make sense.
- Loading branch information
Showing
4 changed files
with
281 additions
and
214 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,34 @@ | ||
{-# LANGUAGE TupleSections #-} | ||
|
||
module Options.Applicative.Help.HelpDoc | ||
( HelpDoc, | ||
HelpType (..), | ||
ansiDocToHelpDoc, | ||
helpDocToAnsiDoc, | ||
annotateHelp, | ||
annotateStyle, | ||
) | ||
where | ||
|
||
import Options.Applicative.Help.Pretty (AnsiDoc) | ||
import Options.Applicative.Help.Pretty (AnsiDoc, AnsiStyle, annotate, reAnnotate) | ||
import qualified Prettyprinter as PP | ||
import Prelude | ||
|
||
type HelpDoc = PP.Doc HelpType | ||
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 | ||
|
||
-- TODO: Make these types more relevant, this was just my quick guess to put something in. | ||
data HelpType = Header | Usage | Description | Title | Undefined | ||
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" |
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
Oops, something went wrong.