packages feed

haskell-gi 0.26.7 → 0.26.8

raw patch · 7 files changed

+135/−80 lines, 7 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

+ Data.GI.CodeGen.API: ScopeTypeForever :: Scope
+ Data.GI.CodeGen.GtkDoc: AbsoluteName :: Text -> Text -> DocSymbolName
+ Data.GI.CodeGen.GtkDoc: RelativeName :: Text -> DocSymbolName
+ Data.GI.CodeGen.GtkDoc: data DocSymbolName
+ Data.GI.CodeGen.GtkDoc: docName :: Name -> DocSymbolName
+ Data.GI.CodeGen.GtkDoc: instance GHC.Classes.Eq Data.GI.CodeGen.GtkDoc.DocSymbolName
+ Data.GI.CodeGen.GtkDoc: instance GHC.Classes.Ord Data.GI.CodeGen.GtkDoc.DocSymbolName
+ Data.GI.CodeGen.GtkDoc: instance GHC.Show.Show Data.GI.CodeGen.GtkDoc.DocSymbolName
+ Data.GI.CodeGen.GtkDoc: resolveDocSymbol :: DocSymbolName -> Text -> Name
+ Data.GI.GIR.Arg: ScopeTypeForever :: Scope
- Data.GI.CodeGen.GtkDoc: FunctionRef :: Name -> CRef
+ Data.GI.CodeGen.GtkDoc: FunctionRef :: DocSymbolName -> CRef
- Data.GI.CodeGen.GtkDoc: MethodRef :: Name -> Text -> CRef
+ Data.GI.CodeGen.GtkDoc: MethodRef :: DocSymbolName -> Text -> CRef
- Data.GI.CodeGen.GtkDoc: PropertyRef :: Name -> Text -> CRef
+ Data.GI.CodeGen.GtkDoc: PropertyRef :: DocSymbolName -> Text -> CRef
- Data.GI.CodeGen.GtkDoc: SignalRef :: Name -> Text -> CRef
+ Data.GI.CodeGen.GtkDoc: SignalRef :: DocSymbolName -> Text -> CRef
- Data.GI.CodeGen.GtkDoc: TypeRef :: Name -> CRef
+ Data.GI.CodeGen.GtkDoc: TypeRef :: DocSymbolName -> CRef
- Data.GI.CodeGen.GtkDoc: VFuncRef :: Name -> Text -> CRef
+ Data.GI.CodeGen.GtkDoc: VFuncRef :: DocSymbolName -> Text -> CRef

Files

ChangeLog.md view
@@ -1,3 +1,11 @@+### 0.26.8+++ Add support for scope type "forever": see [this issue](https://github.com/haskell-gi/haskell-gi/issues/425).++### 0.26.7+++ Work around changing conventions on how to annotate user_data arguments in callbacks, see [this gobject introspection issue](https://gitlab.gnome.org/GNOME/gobject-introspection/-/issues/450) for background.+ ### 0.26.6  + Work around changing conventions about what the `closure n` annotation means: many annotations appear on the callback, pointing to the user_data argument, but sometimes it also appears on the user_data argument, pointing to the callback. See [issue 407](https://github.com/haskell-gi/haskell-gi/issues/407) for a place where this becomes a problem.
haskell-gi.cabal view
@@ -1,5 +1,5 @@ name:                haskell-gi-version:             0.26.7+version:             0.26.8 synopsis:            Generate Haskell bindings for GObject Introspection capable libraries description:         Generate Haskell bindings for GObject Introspection capable libraries. This includes most notably                      Gtk+, but many other libraries in the GObject ecosystem provide introspection data too.
lib/Data/GI/CodeGen/Callable.hs view
@@ -573,6 +573,7 @@                     n -> let destroyName = escapedArgName $ (args callable)!!n                          in line $ "let " <> destroyName <> " = FP.nullFunPtr"                 ScopeTypeCall -> line $ "let " <> closureName <> " = nullPtr"+                ScopeTypeForever -> line $ "let " <> closureName <> " = nullPtr"             _ -> badIntroError $ "Closure \"" <> n <> "\" is not a callback."  freeCallCallbacks :: Callable -> Map.Map Text Text -> ExcCodeGen ()
lib/Data/GI/CodeGen/CtoHaskellMap.hs view
@@ -11,7 +11,7 @@ #endif import Data.Text (Text) -import Data.GI.CodeGen.GtkDoc (CRef(..))+import Data.GI.CodeGen.GtkDoc (CRef(..), docName) import Data.GI.CodeGen.API (API(..), Name(..), Callback(..),                             Constant(..), Flags(..),                             Enumeration(..), EnumerationMember(..),@@ -79,20 +79,20 @@ constRefs :: Name -> Constant -> [(CRef, Hyperlink)] constRefs n c = [(ConstantRef (constantCType c), qualified),                  (CTypeRef (constantCType c), qualified),-                 (TypeRef n, qualified)]+                 (TypeRef (docName n), qualified)]   where qualified = fullyQualifiedValue n (APIConst c) $ name n  -- | Extract the C name of a function. funcRefs :: Name -> Function -> [(CRef, Hyperlink)] funcRefs n f = [(OldFunctionRef (fnSymbol f), qualified),-                (FunctionRef n, qualified)]+                (FunctionRef (docName n), qualified)]   where qualified = fullyQualifiedValue n (APIFunction f) $ lowerName n  -- | Extract the C names of the fields in an enumeration/flags, and -- the name of the type itself. enumRefs :: API -> Name -> Enumeration -> [(CRef, Hyperlink)] enumRefs api n e = (CTypeRef (enumCType e), qualified)-                   : (TypeRef n, qualified)+                   : (TypeRef (docName n), qualified)                    : map memberToRef (enumMembers e)   where qualified = fullyQualifiedType n api $ upperName n         memberToRef :: EnumerationMember -> (CRef, Hyperlink)@@ -109,7 +109,7 @@           let mn' = mn {name = name n <> "_" <> name mn}               qualified = fullyQualifiedValue n api $ lowerName mn'           in [(OldFunctionRef symbol, qualified),-              (MethodRef n (name mn), qualified)]+              (MethodRef (docName n) (name mn), qualified)]  -- | Refs to the signals for a given owner. signalRefs :: Name -> API -> Maybe Text -> [Signal] -> [(CRef, Hyperlink)]@@ -125,7 +125,7 @@               label = Just (owner <> "::" <> sn')               link = ModuleLinkWithAnchor label mod (haddockSignalAnchor <> sn')           in [(OldSignalRef ownerCName sn, link),-              (SignalRef n sn, link)]+              (SignalRef (docName n) sn, link)]  -- | Refs to the properties for a given owner. propRefs :: Name -> API -> Maybe Text -> [Property] -> [(CRef, Hyperlink)]@@ -141,14 +141,14 @@               label = Just (owner <> ":" <> hn)               link = ModuleLinkWithAnchor label mod (haddockAttrAnchor <> hn)           in [(OldPropertyRef ownerCName pn, link),-              (PropertyRef n pn, link)]+              (PropertyRef (docName n) pn, link)]  -- | Given an optional C type and the API constructor construct the -- list of associated refs. maybeCType :: Name -> API -> Maybe Text -> [(CRef, Hyperlink)] maybeCType _ _ Nothing = [] maybeCType n api (Just ctype) = [(CTypeRef ctype, qualified),-                                 (TypeRef n, qualified)]+                                 (TypeRef (docName n), qualified)]   where qualified = fullyQualifiedType n api (upperName n)  -- | Extract the C name of a callback.
lib/Data/GI/CodeGen/GtkDoc.hs view
@@ -8,6 +8,9 @@   , Link(..)   , ListItem(..)   , CRef(..)+  , DocSymbolName(..)+  , docName+  , resolveDocSymbol   ) where  import Prelude hiding (takeWhile)@@ -46,7 +49,8 @@  -- | An item in a list, given by a list of lines (not including ending -- newlines). The list is always non-empty, so we represent it by the--- first line and then a possibly empty list with the rest of the lines.+-- first line and then a possibly empty list with the rest of the+-- lines. data ListItem = ListItem GtkDoc [GtkDoc]   deriving (Show, Eq) @@ -55,24 +59,33 @@   deriving (Show, Eq)  -- | A reference to some symbol in the API.-data CRef = FunctionRef Name+data CRef = FunctionRef DocSymbolName           | OldFunctionRef Text-          | MethodRef Name Text+          | MethodRef DocSymbolName Text           | ParamRef Text           | ConstantRef Text-          | SignalRef Name Text+          | SignalRef DocSymbolName Text           | OldSignalRef Text Text           | LocalSignalRef Text-          | PropertyRef Name Text+          | PropertyRef DocSymbolName Text           | OldPropertyRef Text Text           | VMethodRef Text Text-          | VFuncRef Name Text+          | VFuncRef DocSymbolName Text           | StructFieldRef Text Text           | CTypeRef Text-          | TypeRef Name+          | TypeRef DocSymbolName+          deriving (Show, Eq, Ord)++-- | Reference to a name (of a class, for instance) in the+-- documentation. It can be either relative to the module where the+-- documentation is, of in some other namespace.+data DocSymbolName = RelativeName Text+                     -- ^ The symbol without a namespace specified+                   | AbsoluteName Text Text+                     -- ^ Namespace and symbol   deriving (Show, Eq, Ord) --- | A parsed representation of gtk-doc formatted documentation.+-- | A parsed gtk-doc with fully resolved references. newtype GtkDoc = GtkDoc [Token]   deriving (Show, Eq) @@ -246,7 +259,7 @@ -- -- === __Examples__ -- >>> parseOnly (parseFunctionRef <* endOfInput) "[func@Gtk.init]"--- Right (SymbolRef (FunctionRef (Name {namespace = "Gtk", name = "init"})))+-- Right (SymbolRef (FunctionRef (AbsoluteName "Gtk" "init"))) parseNewFunctionRef :: Parser Token parseNewFunctionRef = do   _ <- string "[func@"@@ -254,14 +267,14 @@   _ <- char '.'   n <- takeWhile1 isCIdent   _ <- char ']'-  return $ SymbolRef $ FunctionRef (Name ns n)+  return $ SymbolRef $ FunctionRef (AbsoluteName ns n)  -- | Parse a method name, of the form -- > [method@Namespace.Object.c_func_name] -- -- === __Examples__ -- >>> parseOnly (parseMethod <* endOfInput) "[method@Gtk.Button.set_child]"--- Right (SymbolRef (MethodRef (Name {namespace = "Gtk", name = "Button"}) "set_child"))+-- Right (SymbolRef (MethodRef (AbsoluteName "Gtk" "Button") "set_child")) parseMethod :: Parser Token parseMethod = do   _ <- string "[method@"@@ -271,14 +284,14 @@   _ <- char '.'   method <- takeWhile1 isCIdent   _ <- char ']'-  return $ SymbolRef $ MethodRef (Name ns n) method+  return $ SymbolRef $ MethodRef (AbsoluteName ns n) method  -- | Parse a reference to a constructor, of the form -- > [ctor@Namespace.Object.c_func_name] -- -- === __Examples__ -- >>> parseOnly (parseConstructor <* endOfInput) "[ctor@Gtk.Builder.new_from_file]"--- Right (SymbolRef (MethodRef (Name {namespace = "Gtk", name = "Builder"}) "new_from_file"))+-- Right (SymbolRef (MethodRef (AbsoluteName "Gtk" "Builder") "new_from_file")) parseConstructor :: Parser Token parseConstructor = do   _ <- string "[ctor@"@@ -288,7 +301,7 @@   _ <- char '.'   method <- takeWhile1 isCIdent   _ <- char ']'-  return $ SymbolRef $ MethodRef (Name ns n) method+  return $ SymbolRef $ MethodRef (AbsoluteName ns n) method  -- | Parse a reference to a type, of the form -- > [class@Namespace.Name]@@ -299,13 +312,13 @@ -- -- === __Examples__ -- >>> parseOnly (parseClass <* endOfInput) "[class@Gtk.Dialog]"--- Right (SymbolRef (TypeRef (Name {namespace = "Gtk", name = "Dialog"})))+-- Right (SymbolRef (TypeRef (AbsoluteName "Gtk" "Dialog"))) -- -- >>> parseOnly (parseClass <* endOfInput) "[iface@Gtk.Editable]"--- Right (SymbolRef (TypeRef (Name {namespace = "Gtk", name = "Editable"})))+-- Right (SymbolRef (TypeRef (AbsoluteName "Gtk" "Editable"))) -- -- >>> parseOnly (parseClass <* endOfInput) "[enum@Gtk.SizeRequestMode]"--- Right (SymbolRef (TypeRef (Name {namespace = "Gtk", name = "SizeRequestMode"})))+-- Right (SymbolRef (TypeRef (AbsoluteName "Gtk" "SizeRequestMode"))) parseClass :: Parser Token parseClass = do   _ <- string "[class@" <|> string "[iface@" <|> string "[enum@"@@ -313,7 +326,7 @@   _ <- char '.'   n <- takeWhile1 isCIdent   _ <- char ']'-  return $ SymbolRef $ TypeRef (Name ns n)+  return $ SymbolRef $ TypeRef (AbsoluteName ns n)  parseSignal :: Parser Token parseSignal = parseOldSignal <|> parseNewSignal@@ -337,7 +350,7 @@ -- -- === __Examples__ -- >>> parseOnly (parseNewSignal <* endOfInput) "[signal@Gtk.AboutDialog::activate-link]"--- Right (SymbolRef (SignalRef (Name {namespace = "Gtk", name = "AboutDialog"}) "activate-link"))+-- Right (SymbolRef (SignalRef (AbsoluteName "Gtk" "AboutDialog") "activate-link")) parseNewSignal :: Parser Token parseNewSignal = do   _ <- string "[signal@"@@ -347,7 +360,7 @@   _ <- string "::"   signal <- takeWhile1 (\c -> (isAscii c && isAlpha c) || c == '-')   _ <- char ']'-  return (SymbolRef (SignalRef (Name ns n) signal))+  return (SymbolRef (SignalRef (AbsoluteName ns n) signal))  -- | Parse a reference to a signal defined in the current module, of the form -- > ::signal@@ -380,7 +393,7 @@ -- -- === __Examples__ -- >>> parseOnly (parseNewProperty <* endOfInput) "[property@Gtk.ProgressBar:show-text]"--- Right (SymbolRef (PropertyRef (Name {namespace = "Gtk", name = "ProgressBar"}) "show-text"))+-- Right (SymbolRef (PropertyRef (AbsoluteName "Gtk" "ProgressBar") "show-text")) parseNewProperty :: Parser Token parseNewProperty = do   _ <- string "[property@"@@ -390,7 +403,7 @@   _ <- char ':'   property <- takeWhile1 (\c -> (isAscii c && isAlpha c) || c == '-')   _ <- char ']'-  return (SymbolRef (PropertyRef (Name ns n) property))+  return (SymbolRef (PropertyRef (AbsoluteName ns n) property))  -- | Parse a property parseProperty :: Parser Token@@ -427,7 +440,7 @@ -- > [vfunc@Namespace.Object.vfunc_name] -- -- >>> parseOnly (parseVFunc <* endOfInput) "[vfunc@Gtk.Widget.get_request_mode]"--- Right (SymbolRef (VFuncRef (Name {namespace = "Gtk", name = "Widget"}) "get_request_mode"))+-- Right (SymbolRef (VFuncRef (AbsoluteName "Gtk" "Widget") "get_request_mode")) parseVFunc :: Parser Token parseVFunc = do   _ <- string "[vfunc@"@@ -437,7 +450,7 @@   _ <- char '.'   vfunc <- parseCIdent   _ <- char ']'-  return (SymbolRef (VFuncRef (Name ns n) vfunc))+  return (SymbolRef (VFuncRef (AbsoluteName ns n) vfunc))  -- | Parse a reference to a virtual method parseVMethod :: Parser Token@@ -674,3 +687,13 @@          parseLine :: Parser Text         parseLine = string "\n  " >> takeWhile1 (/= '\n')++-- | Turn an ordinary `Name` into a `DocSymbolName`+docName :: Name -> DocSymbolName+docName (Name ns n) = AbsoluteName ns n++-- | Return a `Name` from a potentially relative `DocSymbolName`,+-- using the provided default namespace if the name is relative.+resolveDocSymbol :: DocSymbolName -> Text -> Name+resolveDocSymbol (AbsoluteName ns n) _ = Name ns n+resolveDocSymbol (RelativeName n) defaultNS = Name defaultNS n
lib/Data/GI/CodeGen/Haddock.hs view
@@ -33,7 +33,8 @@ import Data.GI.CodeGen.Config (modName, overrides) import Data.GI.CodeGen.CtoHaskellMap (Hyperlink(..)) import Data.GI.CodeGen.GtkDoc (GtkDoc(..), Token(..), CRef(..), Language(..),-                               Link(..), ListItem(..), parseGtkDoc)+                               Link(..), ListItem(..), parseGtkDoc,+                               DocSymbolName(..), resolveDocSymbol, docName) import Data.GI.CodeGen.Overrides (onlineDocsMap) import Data.GI.CodeGen.SymbolNaming (lowerSymbol, signalHaskellName,                                      haddockSignalAnchor)@@ -49,21 +50,21 @@ -- delimiters are not included in the output. -- -- === __Examples__--- >>> formatHaddock M.empty "" (GtkDoc [Literal "Hello ", Literal "World!"])+-- >>> formatHaddock M.empty "" "Test" (GtkDoc [Literal "Hello ", Literal "World!"]) -- "Hello World!" -- -- >>> let c2h = M.fromList [(OldFunctionRef "foo", ValueIdentifier "foo")]--- >>> formatHaddock c2h "" (GtkDoc [SymbolRef (OldFunctionRef "foo")])+-- >>> formatHaddock c2h "" "Test" (GtkDoc [SymbolRef (OldFunctionRef "foo")]) -- "'foo'" -- -- >>> let onlineDocs = "http://wiki.haskell.org"--- >>> formatHaddock M.empty onlineDocs (GtkDoc [ExternalLink (Link "GI" "GObjectIntrospection")])+-- >>> formatHaddock M.empty onlineDocs "Test" (GtkDoc [ExternalLink (Link "GI" "GObjectIntrospection")]) -- "<http://wiki.haskell.org/GObjectIntrospection GI>" ----- >>> formatHaddock M.empty "a" (GtkDoc [List [ListItem (GtkDoc [Image (Link "test" "test.png")]) []]])+-- >>> formatHaddock M.empty "a" "Test" (GtkDoc [List [ListItem (GtkDoc [Image (Link "test" "test.png")]) []]]) -- "\n* <<a/test.png test>>\n"-formatHaddock :: M.Map CRef Hyperlink -> Text -> GtkDoc -> Text-formatHaddock c2h docBase (GtkDoc doc) = T.concat $ map formatToken doc+formatHaddock :: M.Map CRef Hyperlink -> Text -> Text -> GtkDoc -> Text+formatHaddock c2h docBase defaultNS (GtkDoc tokens) = T.concat $ map formatToken tokens   where formatToken :: Token -> Text         formatToken (Literal l) = escape l         formatToken (Comment _) = ""@@ -71,56 +72,70 @@         formatToken (CodeBlock l c) = formatCodeBlock l c         formatToken (ExternalLink l) = formatLink l docBase         formatToken (Image l) = formatImage l docBase-        formatToken (SectionHeader l h) = formatSectionHeader c2h docBase l h-        formatToken (List l) = formatList c2h docBase l+        formatToken (SectionHeader l h) =+          formatSectionHeader c2h docBase defaultNS l h+        formatToken (List l) = formatList c2h docBase defaultNS l         formatToken (SymbolRef cr) = case M.lookup cr c2h of           Just hr -> formatHyperlink hr-          Nothing -> formatUnknownCRef c2h cr+          Nothing -> formatUnknownCRef c2h defaultNS cr --- | Format a `CRef` whose Haskell representation is not known.-formatUnknownCRef :: M.Map CRef Hyperlink -> CRef -> Text-formatUnknownCRef _ (OldFunctionRef f) = formatCRef $ f <> "()"-formatUnknownCRef _ (FunctionRef (Name ns n)) = formatCRef $ ns <> "." <> n-formatUnknownCRef _ (ParamRef p) = "/@" <> lowerSymbol p <> "@/"-formatUnknownCRef _ (LocalSignalRef s) =+-- | Format a `CRef` whose Haskell representation is not known, using+-- a provided default namespace for relative symbols.+formatUnknownCRef :: M.Map CRef Hyperlink -> Text -> CRef -> Text+formatUnknownCRef _ _ (OldFunctionRef f) = formatCRef $ f <> "()"+formatUnknownCRef _ defaultNS (FunctionRef n) =+  formatCRef $ formatDocSymbol n defaultNS+formatUnknownCRef _ _ (ParamRef p) = "/@" <> lowerSymbol p <> "@/"+formatUnknownCRef _ _ (LocalSignalRef s) =   let sn = signalHaskellName s   in "[" <> sn <> "](#" <> haddockSignalAnchor <> sn <> ")"-formatUnknownCRef c2h (SignalRef owner@(Name ns n) signal) =-  case M.lookup (TypeRef owner) c2h of+formatUnknownCRef c2h defaultNS (SignalRef docSymbol signal) =+  let owner@(Name ns n) = resolveDocSymbol docSymbol defaultNS+  in case M.lookup (TypeRef (docName owner)) c2h of     Nothing -> formatCRef $ ns <> "." <> n <> "::" <> signal     Just r -> formatHyperlink r <> "::" <> formatCRef signal-formatUnknownCRef c2h (OldSignalRef owner signal) =+formatUnknownCRef c2h _ (OldSignalRef owner signal) =   case M.lookup (CTypeRef owner) c2h of     Nothing -> formatCRef $ owner <> "::" <> signal     Just r -> formatHyperlink r <> "::" <> formatCRef signal-formatUnknownCRef c2h (OldPropertyRef owner prop) =+formatUnknownCRef c2h _ (OldPropertyRef owner prop) =   case M.lookup (CTypeRef owner) c2h of     Nothing -> formatCRef $ owner <> ":" <> prop     Just r -> formatHyperlink r <> ":" <> formatCRef prop-formatUnknownCRef c2h (PropertyRef owner@(Name ns n) prop) =-  case M.lookup (TypeRef owner) c2h of+formatUnknownCRef c2h defaultNS (PropertyRef docSymbol prop) =+  let owner@(Name ns n) = resolveDocSymbol docSymbol defaultNS+  in case M.lookup (TypeRef (docName owner)) c2h of     Nothing -> formatCRef $ ns <> "." <> n <> ":" <> prop     Just r -> formatHyperlink r <> ":" <> formatCRef prop-formatUnknownCRef c2h (VMethodRef owner vmethod) =+formatUnknownCRef c2h _ (VMethodRef owner vmethod) =   case M.lookup (CTypeRef owner) c2h of     Nothing -> formatCRef $ owner <> "." <> vmethod <> "()"     Just r -> formatHyperlink r <> "." <> formatCRef vmethod <> "()"-formatUnknownCRef c2h (VFuncRef owner@(Name ns n) vmethod) =-  case M.lookup (TypeRef owner) c2h of+formatUnknownCRef c2h defaultNS (VFuncRef docSymbol vmethod) =+  let owner@(Name ns n) = resolveDocSymbol docSymbol defaultNS+  in case M.lookup (TypeRef (docName owner)) c2h of     Nothing -> formatCRef $ ns <> "." <> n <> "." <> vmethod <> "()"     Just r -> formatHyperlink r <> "." <> formatCRef vmethod <> "()"-formatUnknownCRef c2h (MethodRef owner@(Name ns n) method) =-  case M.lookup (TypeRef owner) c2h of+formatUnknownCRef c2h defaultNS(MethodRef docSymbol method) =+  let owner@(Name ns n) = resolveDocSymbol docSymbol defaultNS+  in case M.lookup (TypeRef (docName owner)) c2h of     Nothing -> formatCRef $ ns <> "." <> n <> "." <> method <> "()"     Just r -> formatHyperlink r <> "." <> formatCRef method <> "()"-formatUnknownCRef c2h (StructFieldRef owner field) =+formatUnknownCRef c2h _ (StructFieldRef owner field) =   case M.lookup (CTypeRef owner) c2h of     Nothing -> formatCRef $ owner <> "." <> field     Just r -> formatHyperlink r <> "." <> formatCRef field-formatUnknownCRef _ (CTypeRef t) = formatCRef t-formatUnknownCRef _ (TypeRef (Name ns n)) = formatCRef $ ns <> "." <> n-formatUnknownCRef _ (ConstantRef t) = formatCRef t+formatUnknownCRef _ _ (CTypeRef t) = formatCRef t+formatUnknownCRef _ defaultNS (TypeRef n) =+  formatCRef $ formatDocSymbol n defaultNS+formatUnknownCRef _ _ (ConstantRef t) = formatCRef t +-- | Format the given symbol name in a fully qualified way, using the+-- default namespace if needed.+formatDocSymbol :: DocSymbolName -> Text -> Text+formatDocSymbol (RelativeName n) defaultNS = defaultNS <> "." <> n+formatDocSymbol (AbsoluteName ns n) _ = ns <> "." <> n+ -- | Formatting for an unknown C reference. formatCRef :: Text -> Text formatCRef t = "@/" <> escape t <> "/@"@@ -173,20 +188,20 @@ -- | Format a section header of the given level and with the given -- text. Note that the level will be truncated to 2, if it is larger -- than that.-formatSectionHeader :: M.Map CRef Hyperlink -> Text -> Int -> GtkDoc -> Text-formatSectionHeader c2h docBase level header =-  T.replicate level "=" <> " " <> formatHaddock c2h docBase header <> "\n"+formatSectionHeader :: M.Map CRef Hyperlink -> Text -> Text -> Int -> GtkDoc -> Text+formatSectionHeader c2h docBase defaultNS level header =+  T.replicate level "=" <> " " <> formatHaddock c2h docBase defaultNS header <> "\n"  -- | Format a list of items.-formatList :: M.Map CRef Hyperlink -> Text -> [ListItem] -> Text-formatList c2h docBase items = "\n" <> T.concat (map formatListItem items)+formatList :: M.Map CRef Hyperlink -> Text -> Text -> [ListItem] -> Text+formatList c2h docBase defaultNS items = "\n" <> T.concat (map formatListItem items)   where formatListItem :: ListItem -> Text         formatListItem (ListItem first rest) =           "* " <> format first <> "\n"           <> T.concat (map ((<> "\n") . format) rest)          format :: GtkDoc -> Text-        format = formatHaddock c2h docBase+        format doc = formatHaddock c2h docBase defaultNS doc  -- | Escape the reserved Haddock characters in a given `Text`. --@@ -225,12 +240,14 @@ deprecatedPragma name (Just info) = do   c2h <- getC2HMap   docBase <- getDocBase+  defaultNS <- modName <$> config   line $ "{-# DEPRECATED " <> name <> " " <>-    (T.pack . show) (note <> reason c2h docBase) <> " #-}"-        where reason c2h docBase =+    (T.pack . show) (note <> reason c2h docBase defaultNS) <> " #-}"+        where reason c2h docBase defaultNS =                 case deprecationMessage info of                   Nothing -> []-                  Just msg -> map (formatHaddock c2h docBase . parseGtkDoc)+                  Just msg -> map (formatHaddock c2h docBase defaultNS+                                   . parseGtkDoc)                                   (T.lines msg)               note = case deprecatedSinceVersion info of                        Nothing -> []@@ -238,10 +255,10 @@  -- | Format the given documentation into a set of lines. Note that -- this does include the opening or ending comment delimiters.-formatDocumentation :: M.Map CRef Hyperlink -> Text -> Documentation -> Text-formatDocumentation c2h docBase doc = do+formatDocumentation :: M.Map CRef Hyperlink -> Text -> Text -> Documentation -> Text+formatDocumentation c2h docBase defaultNS doc = do   let description = case rawDocText doc of-        Just raw -> formatHaddock c2h docBase (parseGtkDoc raw)+        Just raw -> formatHaddock c2h docBase defaultNS (parseGtkDoc raw)         Nothing -> "/No description available in the introspection data./"   description <> case sinceVersion doc of                    Nothing -> ""@@ -252,7 +269,8 @@ writeDocumentation pos doc = do   c2h <- getC2HMap   docBase <- getDocBase-  writeHaddock pos (formatDocumentation c2h docBase doc)+  defaultNS <- modName <$> config+  writeHaddock pos (formatDocumentation c2h docBase defaultNS doc)  -- | Like `writeDocumentation`, but allows us to pass explicitly the -- Haddock comment to write.@@ -274,8 +292,9 @@     Just raw -> do       c2h <- getC2HMap       docBase <- getDocBase+      defaultNS <- modName <$> config       let haddock = "/@" <> lowerSymbol (argCName arg) <> "@/: " <>-                    formatHaddock c2h docBase (parseGtkDoc raw)+                    formatHaddock c2h docBase defaultNS (parseGtkDoc raw)       writeHaddock DocAfterSymbol haddock  -- | Write the documentation for the given return value.@@ -283,12 +302,13 @@ writeReturnDocumentation callable skip = do   c2h <- getC2HMap   docBase <- getDocBase+  defaultNS <- modName <$> config   let returnValInfo = if skip                       then []                       else case rawDocText (returnDocumentation callable) of                              Nothing -> []                              Just raw -> ["__Returns:__ " <>-                                           formatHaddock c2h docBase+                                           formatHaddock c2h docBase defaultNS                                            (parseGtkDoc raw)]       throwsInfo = if callableThrows callable                    then ["/(Can throw 'Data.GI.Base.GError.GError')/"]@@ -302,5 +322,6 @@ addSectionDocumentation section doc = do   c2h <- getC2HMap   docBase <- getDocBase-  let formatted = formatDocumentation c2h docBase doc+  defaultNS <- modName <$> config+  let formatted = formatDocumentation c2h docBase defaultNS doc   addSectionFormattedDocs section formatted
lib/Data/GI/GIR/Arg.hs view
@@ -24,6 +24,7 @@            | ScopeTypeCall            | ScopeTypeAsync            | ScopeTypeNotified+           | ScopeTypeForever              deriving (Show, Eq, Ord)  data Arg = Arg {@@ -54,6 +55,7 @@ parseScope "call" = return ScopeTypeCall parseScope "async" = return ScopeTypeAsync parseScope "notified" = return ScopeTypeNotified+parseScope "forever" = return ScopeTypeForever parseScope s = parseError $ "Unknown scope type \"" <> s <> "\""  parseDirection :: Text -> Parser Direction