summaryrefslogtreecommitdiff
path: root/protocols/codegen/Wayland/CodeGen/Parser.hs
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/codegen/Wayland/CodeGen/Parser.hs')
-rw-r--r--protocols/codegen/Wayland/CodeGen/Parser.hs12
1 files changed, 8 insertions, 4 deletions
diff --git a/protocols/codegen/Wayland/CodeGen/Parser.hs b/protocols/codegen/Wayland/CodeGen/Parser.hs
index 15afbb9..c7023ed 100644
--- a/protocols/codegen/Wayland/CodeGen/Parser.hs
+++ b/protocols/codegen/Wayland/CodeGen/Parser.hs
@@ -6,6 +6,7 @@ import Data.Maybe (fromMaybe)
import Text.XML.Light (Element(..), findAttrBy, QName(..), filterChildName, filterChildrenName, strContent, parseXMLDoc)
import Text.Read (readEither)
import Wayland.CodeGen.Types
+import Control.Applicative ((<|>))
parseProtocolSpec :: String -> Either String Protocol
parseProtocolSpec s = case parseXMLDoc s of
@@ -71,8 +72,7 @@ processEntry el = do
let summary = findAttrBy (matchName "summary") el
pure $ EntryDesc { entryName = name
, entryValue = value
- , entryDescription = description
- , entrySummary = summary
+ , entryDescription = description <|> simpleDescription <$> summary
, entrySince = fromMaybe 1 since
, entryDeprecatedSince = deprecatedSince
}
@@ -105,8 +105,7 @@ processArgument el = do
let enum = findAttrBy (matchName "enum") el
pure $ ArgumentDesc { argName = name
, argType = type'
- , argDescription = description
- , argSummary = summary
+ , argDescription = description <|> simpleDescription <$> summary
, argInterface = interface
, argEnum = enum
, argAllowNull = fromMaybe False allowNull
@@ -142,3 +141,8 @@ readArgumentType "fd" = Right ArgumentFD
readArgumentType "new_id" = Right ArgumentNewID
readArgumentType "object" = Right ArgumentObject
readArgumentType x = Left $ "Expected an argument type, got " ++ x
+
+simpleDescription :: String -> Description
+simpleDescription summary = Description { descSummary = summary
+ , descBody = ""
+ }