From f7b6c800efdc89087565097354d6b9686e268eca Mon Sep 17 00:00:00 2001 From: Henning Guenther Date: Sat, 29 Aug 2009 06:19:55 -0700 Subject: [PATCH] Generate fancy translation table for documentation Ignore-this: 353d70985d048216dcf4522ceef10c26 darcs-hash:20090829131955-a4fee-c9e694757edc00d61e4a4365ef1fe2b0aeb948e8 --- Data/Encoding/Preprocessor/Mapping.hs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Data/Encoding/Preprocessor/Mapping.hs b/Data/Encoding/Preprocessor/Mapping.hs index 736d772..2207b76 100644 --- a/Data/Encoding/Preprocessor/Mapping.hs +++ b/Data/Encoding/Preprocessor/Mapping.hs @@ -35,6 +35,12 @@ parseTranslationTable cont = map (\ln -> let (trans,comm) = break (=='#') ln _ -> Just (tail comm)) ) (lines cont) +buildDocTable :: [(Integer,Maybe Char)] -> [String] +buildDocTable = intersperse "". + map (\(i,mbc) -> show i ++ (case mbc of + Nothing -> "" + Just c -> "\t = &#"++show (ord c)++"; ("++show (ord c)++")")) + {-fillTranslations :: (Ix a,Show a) => a -> a -> [(a,Maybe Char)] -> [(a,Maybe Char)] fillTranslations f t = merge (range (f,t)) where @@ -113,8 +119,11 @@ preprocessMapping tp src trg mods name = do ["{- This file has been auto-generated. Do not edit it. -}" ,"{-# LANGUAGE MagicHash,DeriveDataTypeable #-}" ]++(case doc of - [] -> [] - _ -> ("{- | "++head doc):(map (\ln -> " "++ln) (tail doc)) ++ [" -}"]) + [] -> ["{- |"] + _ -> ("{- | "++head doc):(map (\ln -> " "++ln) (tail doc))) + ++[""] + ++buildDocTable trans + ++[" -}"] ++ ["module "++mod++"("++name++"(..)) where" ,""