diff --git a/Clean/Doc.icl b/Clean/Doc.icl index 3f2a490c3ee00965106f9bed6cbd0e637e6ac1e6..2bec9846ba3b8ccf2e52075e9980f0115e2c8328 100644 --- a/Clean/Doc.icl +++ b/Clean/Doc.icl @@ -26,8 +26,6 @@ from Text import class Text(join,split,trim,rtrim), import Text.Language import Text.Parsers.Simple.ParserCombinators -import Regex - from Clean.Types import :: Type, :: TypeRestriction import qualified Clean.Types.Parse as T @@ -148,16 +146,20 @@ docBlockToDoc{|OBJECT|} fx doc = appFst OBJECT <$> fx doc docBlockToDoc{|MultiLineString|} (Left [s]) = Right (MultiLine $ trimMultiLine $ split "\n" s, []) -docBlockToDoc{|ParamDoc|} (Left [s]) = case match rgx (fromString s) of - [(_,_,groups):_] -> Right ( - { name = toString <$> lookup (NotNamed 0) groups - , description = case lookup (NotNamed 1) groups of - Just cs=:[_:_] -> Just (toString cs) - _ -> Nothing +docBlockToDoc{|ParamDoc|} (Left [s]) = case findName (fromString s) of + Just (name,rest) -> Right ( + { name = Just $ toString name + , description = case rest of + [] -> Nothing + _ -> Just $ toString rest }, []) - [] -> Right ({name=Nothing, description=Just s}, []) + _ -> Right ({name=Nothing, description=Just s}, []) where - rgx = regex ['^(\\w+):\\s*(.*)$'] + findName cs + # (name,cs) = span (\c -> isAlphanum c || c == '`') cs + | not (isEmpty name) && not (isEmpty cs) && hd cs == ':' + = Just (toString name, dropWhile isSpace (tl cs)) + = Nothing docBlockToDoc{|Type|} (Left []) = Left InternalNoDataError docBlockToDoc{|Type|} (Left ss) = case [v \\ Just v <- map ('T'.parseType o fromString) ss] of