Verified Commit 7438d3c8 authored by Camil Staps's avatar Camil Staps 🙂

Remove Regex dependency

parent 011c4de3
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment