From 7b2990b55da8a43e1fe4d8c04e77a76ebac446c8 Mon Sep 17 00:00:00 2001 From: Hannes Schulze Date: Wed, 14 Aug 2024 22:34:25 +0200 Subject: add documentation to generated code --- protocols/codegen/Wayland/CodeGen/Parser.hs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'protocols/codegen/Wayland/CodeGen/Parser.hs') 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 = "" + } -- cgit v1.3.1