Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
A parser for gtk-doc formatted documentation, see https://developer.gnome.org/gtk-doc-manual/ for the spec.
Synopsis
- parseGtkDoc :: Text -> GtkDoc
- newtype GtkDoc = GtkDoc [Token]
- data Token
- newtype Language = Language Text
- data Link = Link {
- linkName :: Text
- linkAddress :: Text
- data ListItem = ListItem GtkDoc [GtkDoc]
- data CRef
- = FunctionRef DocSymbolName
- | OldFunctionRef Text
- | MethodRef DocSymbolName Text
- | ParamRef Text
- | ConstantRef Text
- | SignalRef DocSymbolName Text
- | OldSignalRef Text Text
- | LocalSignalRef Text
- | PropertyRef DocSymbolName Text
- | OldPropertyRef Text Text
- | VMethodRef Text Text
- | VFuncRef DocSymbolName Text
- | StructFieldRef Text Text
- | CTypeRef Text
- | TypeRef DocSymbolName
- data DocSymbolName
- docName :: Name -> DocSymbolName
- resolveDocSymbol :: DocSymbolName -> Text -> Name
Documentation
parseGtkDoc :: Text -> GtkDoc Source #
Parse the given gtk-doc formatted documentation.
Examples
>>>
parseGtkDoc ""
GtkDoc []
>>>
parseGtkDoc "func()"
GtkDoc [SymbolRef (OldFunctionRef "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 (OldFunctionRef "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 (OldFunctionRef "gtk_button_activate"),Literal "."]
>>>
parseGtkDoc "The signal ##%#GtkButton::activate is related to gtk_button_activate()."
GtkDoc [Literal "The signal ##%",SymbolRef (OldSignalRef "GtkButton" "activate"),Literal " is related to ",SymbolRef (OldFunctionRef "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"})]) []]]
A parsed gtk-doc with fully resolved references.
A parsed gtk-doc token.
The language for an embedded code block.
A link to a resource, either offline or a section of the documentation.
Link | |
|
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.
A reference to some symbol in the API.
data DocSymbolName Source #
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.
RelativeName Text | The symbol without a namespace specified |
AbsoluteName Text Text | Namespace and symbol |
Instances
Show DocSymbolName Source # | |
Defined in Data.GI.CodeGen.GtkDoc showsPrec :: Int -> DocSymbolName -> ShowS # show :: DocSymbolName -> String # showList :: [DocSymbolName] -> ShowS # | |
Eq DocSymbolName Source # | |
Defined in Data.GI.CodeGen.GtkDoc (==) :: DocSymbolName -> DocSymbolName -> Bool # (/=) :: DocSymbolName -> DocSymbolName -> Bool # | |
Ord DocSymbolName Source # | |
Defined in Data.GI.CodeGen.GtkDoc compare :: DocSymbolName -> DocSymbolName -> Ordering # (<) :: DocSymbolName -> DocSymbolName -> Bool # (<=) :: DocSymbolName -> DocSymbolName -> Bool # (>) :: DocSymbolName -> DocSymbolName -> Bool # (>=) :: DocSymbolName -> DocSymbolName -> Bool # max :: DocSymbolName -> DocSymbolName -> DocSymbolName # min :: DocSymbolName -> DocSymbolName -> DocSymbolName # |
docName :: Name -> DocSymbolName Source #
Turn an ordinary Name
into a DocSymbolName
resolveDocSymbol :: DocSymbolName -> Text -> Name Source #
Return a Name
from a potentially relative DocSymbolName
,
using the provided default namespace if the name is relative.