From 02cbf495163ebb9e460a12a8f75a83b05ee86ed9 Mon Sep 17 00:00:00 2001 From: aarne Date: Fri, 18 Oct 2013 08:48:18 +0000 Subject: [PATCH] some fixes in synopsis example display --- lib/doc/MkExxTable.hs | 22 ++++++++++++++++++---- lib/doc/MkSynopsis.hs | 2 +- lib/doc/api-examples.txt | 4 ++-- lib/doc/synopsis-intro.txt | 31 ++++++++++++++++++++++++++++++- 4 files changed, 51 insertions(+), 8 deletions(-) diff --git a/lib/doc/MkExxTable.hs b/lib/doc/MkExxTable.hs index 07120fea8..600b40a96 100644 --- a/lib/doc/MkExxTable.hs +++ b/lib/doc/MkExxTable.hs @@ -1,4 +1,4 @@ -module MkExxTable (getApiExx, ApiExx, prApiEx) where +module MkExxTable (getApiExx, ApiExx, prApiEx, mkEx) where import System.Cmd import System.Environment @@ -13,7 +13,7 @@ main = do getApiExx :: [FilePath] -> IO ApiExx getApiExx xx = do s <- readFile (head xx) - let aet = getApiExxTrees $ filter validOutput $ lines s + let aet = getApiExxTrees $ filter validOutput $ mergeOutput $ lines s aeos <- mapM readApiExxOne xx let aexx = mkApiExx $ ("API",aet) : aeos -- putStrLn $ prApiExx aexx @@ -22,7 +22,7 @@ getApiExx xx = do readApiExxOne file = do s <- readFile file let lang = reverse (take 3 (drop 4 (reverse file))) -- api-exx-*Eng*.txt - let api = getApiExxOne $ filter validOutput $ lines s + let api = getApiExxOne $ filter validOutput $ mergeOutput $ lines s putStrLn $ unlines $ prApiEx api --- return (lang,api) @@ -51,6 +51,13 @@ getApiExxTrees = M.fromList . pairs . map cleanUp -- remove leading prompts and spaces cleanUp = dropWhile (flip elem " >") +--- this makes txt2tags loop... +mergeOutput ls = ls +mergeOutputt ls = case ls of + l@('>':_):ll -> let (ll1,ll2) = span ((/=">") . take 1) ll in unwords (l : map (unwords . words) ll1) : mergeOutput ll2 + _:ll -> mergeOutput ll + _ -> [] + -- only accept lines starting with prompts (to eliminate multi-line gf uncomputed output) validOutput = (==">") . take 1 @@ -76,12 +83,19 @@ mkEx l = unws . bind . mkE . words where mkE e = case e of "atomic":"term":_ -> ["*"] "[]":_ -> ["''"] - "pre":p@('{':_):es -> init (init (drop 2 p)) : [] ---- mkE es -- occurs only on last position + "(table":es -> ["..."] + "table":es -> ["..."] + ('{':_):es -> ["..."] + "pre":p@('{':_):es -> init (init (drop 2 p)) : ["..."] +--- "pre":p@('{':_):es -> init (init (drop 2 p)) : reverse (takeWhile ((/='}') . head) (reverse es)) e0:es -> e0:mkE es _ -> e bind ws = case ws of w : "&+" : u : ws2 -> bind ((w ++ u) : ws2) + w : "Predef.BIND" : u : ws2 -> bind ((w ++ u) : ws2) "&+":ws2 -> bind ws2 + "Predef.BIND":ws2 -> bind ws2 w : ws2 -> w : bind ws2 + w : "++" : ws2 -> w : bind ws2 _ -> ws diff --git a/lib/doc/MkSynopsis.hs b/lib/doc/MkSynopsis.hs index 62ba34aeb..bb16be797 100644 --- a/lib/doc/MkSynopsis.hs +++ b/lib/doc/MkSynopsis.hs @@ -203,7 +203,7 @@ mkTable hasEx isLatex aexx cs = inChunks chsize (\rs -> header : map (unwords . -- make an example with hover-popup translations mkExample es ex = unwords [ "#divreveal", - itf (maybe ex id (M.lookup revealedLang es)), + itf (maybe ex (mkEx revealedLang) (M.lookup revealedLang es)), "#divpopup", "#UL", unwords ["#LI" ++ e | e <- prApiEx es], diff --git a/lib/doc/api-examples.txt b/lib/doc/api-examples.txt index f058cdd86..101d40908 100644 --- a/lib/doc/api-examples.txt +++ b/lib/doc/api-examples.txt @@ -243,9 +243,9 @@ mkUtt (mkNP (mkDet the_Quant (mkNum (mkNumeral n5_Unit))) (mkCN old_A man_N)) mkNP : Det -> N -> NP -- the first man mkUtt (mkNP (mkDet the_Quant (mkNum (mkNumeral n5_Unit))) man_N) mkNP : Numeral -> CN -> NP -- fifty old men -mkUtt (mkNP (mkNumeral (tenfoldSub100 n5_Unit)) (mkCN old_A man_N)) +mkUtt (mkNP (mkNumeral (n5_Unit)) (mkCN old_A man_N)) mkNP : Numeral -> N -> NP -- fifty men -mkUtt (mkNP (mkNumeral (tenfoldSub100 n5_Unit)) man_N) +mkUtt (mkNP (mkNumeral (n5_Unit)) man_N) mkNP : Digits -> CN -> NP -- 51 old men mkUtt (mkNP (mkDigits n5_Dig (mkDigits n1_Dig)) (mkCN old_A man_N)) mkNP : Digits -> N -> NP -- 51 men diff --git a/lib/doc/synopsis-intro.txt b/lib/doc/synopsis-intro.txt index 7b8d628c2..a7e5eac9d 100644 --- a/lib/doc/synopsis-intro.txt +++ b/lib/doc/synopsis-intro.txt @@ -8,7 +8,36 @@ =Introduction= The GF Resource Grammar Library is the standard library for Grammatical Framework. -It covers the morphology and basic syntax of currently 27 languages. +It covers the morphology and basic syntax of currently 29 languages: +Afrikaans, +Bulgarian, +Catalan, +Chinese, +Danish, +Dutch, +English, +Estonian, +Finnish, +French, +German, +Greek, +Hindi, +Japanese, +Italian, +Latvian, +Maltese, +Nepali, +Norwegian bokmål, +Persian, +Polish, +
  • Punjabi, +Romanian, +Russian, +Sindhi, +Spanish, +Swedish, +Thai, +Urdu. This document contains the most important parts of the GF Resource Grammar API, as needed by a GF application programmer.