Skip to content

Commit

Permalink
clean up synopsis in manual pages
Browse files Browse the repository at this point in the history
Tested-on: morland i686 GNU/Linux
  • Loading branch information
droundy committed Nov 21, 2009
1 parent 9af2900 commit 1162d7e
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 15 deletions.
10 changes: 10 additions & 0 deletions .iolaus.css
Expand Up @@ -23,6 +23,16 @@ ul {
margin-left: 2em;
}

div.verseblock {
text-indent: -5em;
padding-left: 5em;
}

dt {
font-style: italic;
color: #107010;
}

PRE {
background: #eeeeee;
border: 1px solid #888888;
Expand Down
12 changes: 4 additions & 8 deletions Setup.hs
Expand Up @@ -67,13 +67,9 @@ doc =
commandPage lhs =
do rule ["manual/"++lhs2md lhs, "manual/"++lhs2manmd lhs]
["preproc", "Iolaus/Commands/"++lhs] $
do hsin <- cat ("Iolaus/Commands/"++lhs)
mkFile ("manual/"++lhs2md lhs++".in") $
("\n\n\\haskell{"++undr lhs++"_description}\n\n"++
"\\options{"++nam lhs++"}\n\n"++
"\\haskell{"++undr lhs++"_help}\n\n"++
hsin)
x <- systemOut "./preproc" [nam lhs,
do x <- systemOut "./preproc" [nam lhs,
"Iolaus/Commands/"++lhs]
h <- systemOut "./preproc" ["--html", nam lhs,
"Iolaus/Commands/"++lhs]
mkdir "manual"
mkdir "man"
Expand All @@ -82,7 +78,7 @@ doc =
"% David Roundy\n"++
"% date?\n\n"
mkFile ("manual/"++lhs2md lhs)
(header++prefix "../" (cmd lhs)++x)
(header++prefix "../" (cmd lhs)++h)
mkFile ("manual/"++lhs2manmd lhs) (header++x)
m <-markdownToMan ("manual/"++lhs2manmd lhs)
("man/man1/iolaus-"++dash lhs++".1")
Expand Down
36 changes: 29 additions & 7 deletions preproc.hs
Expand Up @@ -10,16 +10,32 @@ import Iolaus.Commands ( command_control_list )
the_commands :: [Command]
the_commands = extract_commands command_control_list

data Formatting = Html | Plain

main :: IO ()
main = do
args <- getArgs
case args of
[x] -> preproc ["\\input{"++x++"}"]
["--html",c,fn] ->
do putStrLn $ "\n# NAME\n"
putStr $ "iolaus "++c++" - "
putStrLn $ command_property command_description the_commands c
putStrLn "\n# SYNOPSIS"
putStrLn $ "<div class='verseblock'>"
putStrLn $ "*iolaus "++c++"* "++get_synopsis Html c
putStrLn $ "</div>"
putStrLn "\n# DESCRIPTION"
putStrLn $ command_property command_help the_commands c
cs <- readFile fn
preproc (lines cs)
putStrLn "\n# OPTIONS"
putStrLn $ get_options c
[c,fn] -> do putStrLn $ "\n# NAME\n"
putStr $ "iolaus "++c++" - "
putStrLn $ command_property command_description the_commands c
putStrLn "\n# SYNOPSIS"
putStrLn $ "*iolaus "++c++"* `"++get_synopsis c++"`"
putStrLn $ "*iolaus "++c++"* "++get_synopsis Plain c
putStrLn "\n# DESCRIPTION"
putStrLn $ command_property command_help the_commands c
cs <- readFile fn
Expand Down Expand Up @@ -62,8 +78,9 @@ get_options :: String -> String
get_options comm = get_com_options $ get_c names the_commands
where names = words comm

get_synopsis :: String -> String
get_synopsis comm = get_com_synopsis $ get_c names the_commands
get_synopsis :: Formatting -> String -> String
get_synopsis f comm = unwords $ get_com_synopsis f (get_c names the_commands)++
command_extra_arg_help (last $ get_c names the_commands)
where names = words comm

instance Show CommandControl where
Expand Down Expand Up @@ -93,11 +110,16 @@ get_c (name:ns) commands =
get n [] = error $ "No such command: "++n
get_c [] _ = error "no command specified"

get_com_synopsis :: [Command] -> String
get_com_synopsis cs = unwords $ map bar $ concatMap optionDescription $
basic_options (Command_data c)
get_com_synopsis :: Formatting -> [Command] -> [String]
get_com_synopsis f cs = map bar $ map optionDescription $
basic_options (Command_data c)
where c = last cs
bar (x,_) = "["++pipeit x++"]"
bar xs = case f of
Html -> "<nobr>["++pipethem (map fst xs)++"]</nobr>"
Plain -> "["++pipethem (map fst xs)++"]"
pipethem (x:y:z) = pipeit x ++ " | " ++ pipethem (y:z)
pipethem [x] = pipeit x
pipethem [] = ""
pipeit (',':' ':r) = " | "++pipeit r
pipeit (x:xs) = x : pipeit xs
pipeit "" = ""
Expand Down

0 comments on commit 1162d7e

Please sign in to comment.