haskell-gi-0.24.0: Generate Haskell bindings for GObject Introspection capable libraries
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.GI.CodeGen.GtkDoc

Description

A parser for gtk-doc formatted documentation, see https://developer.gnome.org/gtk-doc-manual/ for the spec.

Synopsis

Documentation

parseGtkDoc :: Text -> GtkDoc Source #

Parse the given gtk-doc formatted documentation.

Examples

Expand
>>> parseGtkDoc ""
GtkDoc []
>>> parseGtkDoc "func()"
GtkDoc [SymbolRef (FunctionRef "func")]
>>> parseGtkDoc "literal"
GtkDoc [Literal "literal"]
>>> parseGtkDoc "This is a long literal"
GtkDoc [Literal "This is a long literal"]
>>> parseGtkDoc "Call foo() for free cookies"
GtkDoc [Literal "Call ",SymbolRef (FunctionRef "foo"),Literal " for free cookies"]
>>> parseGtkDoc "The signal ::activate is related to gtk_button_activate()."
GtkDoc [Literal "The signal ",SymbolRef (LocalSignalRef "activate"),Literal " is related to ",SymbolRef (FunctionRef "gtk_button_activate"),Literal "."]
>>> parseGtkDoc "The signal ##%#GtkButton::activate is related to gtk_button_activate()."
GtkDoc [Literal "The signal ##%",SymbolRef (SignalRef "GtkButton" "activate"),Literal " is related to ",SymbolRef (FunctionRef "gtk_button_activate"),Literal "."]
>>> parseGtkDoc "# A section\n\n## and a subsection ##\n"
GtkDoc [SectionHeader 1 (GtkDoc [Literal "A section"]),Literal "\n",SectionHeader 2 (GtkDoc [Literal "and a subsection "])]
>>> parseGtkDoc "Compact list:\n- First item\n- Second item"
GtkDoc [Literal "Compact list:\n",List [ListItem (GtkDoc [Literal "First item"]) [],ListItem (GtkDoc [Literal "Second item"]) []]]
>>> parseGtkDoc "Spaced list:\n\n- First item\n\n- Second item"
GtkDoc [Literal "Spaced list:\n",List [ListItem (GtkDoc [Literal "First item"]) [],ListItem (GtkDoc [Literal "Second item"]) []]]
>>> parseGtkDoc "List with urls:\n- [test](http://test)\n- ![](image.png)"
GtkDoc [Literal "List with urls:\n",List [ListItem (GtkDoc [ExternalLink (Link {linkName = "test", linkAddress = "http://test"})]) [],ListItem (GtkDoc [Image (Link {linkName = "", linkAddress = "image.png"})]) []]]

newtype GtkDoc Source #

A parsed representation of gtk-doc formatted documentation.

Constructors

GtkDoc [Token] 

Instances

Instances details
Eq GtkDoc Source # 
Instance details

Defined in Data.GI.CodeGen.GtkDoc

Methods

(==) :: GtkDoc -> GtkDoc -> Bool #

(/=) :: GtkDoc -> GtkDoc -> Bool #

Show GtkDoc Source # 
Instance details

Defined in Data.GI.CodeGen.GtkDoc

Methods

showsPrec :: Int -> GtkDoc -> ShowS #

show :: GtkDoc -> String #

showList :: [GtkDoc] -> ShowS #

data Token Source #

A parsed gtk-doc token.

Constructors

Literal Text 
Comment Text 
Verbatim Text 
CodeBlock (Maybe Language) Text 
ExternalLink Link 
Image Link 
List [ListItem] 
SectionHeader Int GtkDoc

A section header of the given depth.

SymbolRef CRef 

Instances

Instances details
Eq Token Source # 
Instance details

Defined in Data.GI.CodeGen.GtkDoc

Methods

(==) :: Token -> Token -> Bool #

(/=) :: Token -> Token -> Bool #

Show Token Source # 
Instance details

Defined in Data.GI.CodeGen.GtkDoc

Methods

showsPrec :: Int -> Token -> ShowS #

show :: Token -> String #

showList :: [Token] -> ShowS #

newtype Language Source #

The language for an embedded code block.

Constructors

Language Text 

Instances

Instances details
Eq Language Source # 
Instance details

Defined in Data.GI.CodeGen.GtkDoc

Show Language Source # 
Instance details

Defined in Data.GI.CodeGen.GtkDoc

Methods

showsPrec :: Int -> Language -> ShowS #

show :: Language -> String #

showList :: [Language] -> ShowS #

data Link Source #

A link to a resource, either offline or a section of the documentation.

Constructors

Link 

Fields

Instances

data ListItem Source #

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.

Constructors

ListItem GtkDoc [GtkDoc] 

Instances

Instances details
Eq ListItem Source # 
Instance details

Defined in Data.GI.CodeGen.GtkDoc

Show ListItem Source # 
Instance details

Defined in Data.GI.CodeGen.GtkDoc

Methods

showsPrec :: Int -> ListItem -> ShowS #

show :: ListItem -> String #

showList :: [ListItem] -> ShowS #

data CRef Source #

A reference to some symbol in the API.

Constructors

FunctionRef Text 
ParamRef Text 
ConstantRef Text 
SignalRef Text Text 
LocalSignalRef Text 
PropertyRef Text Text 
VMethodRef Text Text 
StructFieldRef Text Text 
TypeRef Text 

Instances

Instances details
Eq CRef Source # 
Instance details

Defined in Data.GI.CodeGen.GtkDoc

Methods

(==) :: CRef -> CRef -> Bool #

(/=) :: CRef -> CRef -> Bool #

Ord CRef Source # 
Instance details

Defined in Data.GI.CodeGen.GtkDoc

Methods

compare :: CRef -> CRef -> Ordering

(<) :: CRef -> CRef -> Bool

(<=) :: CRef -> CRef -> Bool

(>) :: CRef -> CRef -> Bool

(>=) :: CRef -> CRef -> Bool

max :: CRef -> CRef -> CRef

min :: CRef -> CRef -> CRef

Show CRef Source # 
Instance details

Defined in Data.GI.CodeGen.GtkDoc

Methods

showsPrec :: Int -> CRef -> ShowS #

show :: CRef -> String #

showList :: [CRef] -> ShowS #