module Darcs.UI.Options.Markdown ( optionsMarkdown ) where
import Darcs.Prelude
import Data.Functor.Compose ( Compose(..) )
import System.Console.GetOpt ( OptDescr(..), ArgDescr(..) )
import Darcs.UI.Options.Util ( DarcsOptDescr )
optionsMarkdown :: [DarcsOptDescr f] -> String
optionsMarkdown :: [DarcsOptDescr f] -> String
optionsMarkdown [DarcsOptDescr f]
opts = [String] -> String
unlines
[ String
"<table>", [String] -> String
unlines ((DarcsOptDescr f -> String) -> [DarcsOptDescr f] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map DarcsOptDescr f -> String
forall f. DarcsOptDescr f -> String
optionMarkdown [DarcsOptDescr f]
opts), String
"</table>" ]
optionMarkdown :: DarcsOptDescr f -> String
optionMarkdown :: DarcsOptDescr f -> String
optionMarkdown (Compose (Option String
a [String]
b (NoArg AbsolutePath -> f
_) String
h)) = [String] -> String
unlines
[ String
"<tr>", String
"<td>", String -> String
showShortOptionsMd String
a, String
"</td>"
, String
"<td>", [String] -> String
showLongOptionsMd [String]
b , String
"</td>"
, String
"<td>", String
h, String
"</td>"
, String
"</tr>" ]
optionMarkdown (Compose (Option String
a [String]
b (ReqArg String -> AbsolutePath -> f
_ String
arg) String
h)) = [String] -> String
unlines
[ String
"<tr>", String
"<td>", String -> String
showShortOptionsMd String
a, String
"</td>"
, String
"<td>", [String] -> String
showLongOptionsMd ((String -> String) -> [String] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map (String -> String -> String
forall a. [a] -> [a] -> [a]
++(Char
' ' Char -> String -> String
forall a. a -> [a] -> [a]
: String
arg)) [String]
b), String
"</td>"
, String
"<td>", String
h, String
"</td>", String
"</tr>" ]
optionMarkdown (Compose (Option String
a [String]
b (OptArg Maybe String -> AbsolutePath -> f
_ String
arg) String
h)) = [String] -> String
unlines
[ String
"<tr>", String
"<td>", String -> String
showShortOptionsMd String
a, String
"</td>"
, String
"<td>", [String] -> String
showLongOptionsMd ((String -> String) -> [String] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map (String -> String -> String
forall a. [a] -> [a] -> [a]
++(String
"[="String -> String -> String
forall a. [a] -> [a] -> [a]
++String
argString -> String -> String
forall a. [a] -> [a] -> [a]
++String
"]")) [String]
b), String
"</td>"
, String
"<td>", String
h, String
"</td>", String
"</tr>" ]
showShortOptionsMd :: [Char] -> String
showShortOptionsMd :: String -> String
showShortOptionsMd [] = String
""
showShortOptionsMd [Char
c] = String
"`-"String -> String -> String
forall a. [a] -> [a] -> [a]
++[Char
c]String -> String -> String
forall a. [a] -> [a] -> [a]
++String
"` "
showShortOptionsMd (Char
c:String
cs) = String
"`-"String -> String -> String
forall a. [a] -> [a] -> [a]
++[Char
c]String -> String -> String
forall a. [a] -> [a] -> [a]
++String
"`,"String -> String -> String
forall a. [a] -> [a] -> [a]
++String -> String
showShortOptionsMd String
cs
showLongOptionsMd :: [String] -> String
showLongOptionsMd :: [String] -> String
showLongOptionsMd [] = String
" "
showLongOptionsMd [String
s] = String
"`--" String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
s String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"` "
showLongOptionsMd (String
s:[String]
ss) = String
"`--" String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
s String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"`,"String -> String -> String
forall a. [a] -> [a] -> [a]
++ [String] -> String
showLongOptionsMd [String]
ss