mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
docs: Add link to online documentation
This commit is contained in:
parent
4eaf735732
commit
e1b7410e51
1 changed files with 73 additions and 1 deletions
|
@ -92,6 +92,23 @@ def get_xml(namespace: str, version: str):
|
||||||
return _xml_cache[filename]
|
return _xml_cache[filename]
|
||||||
|
|
||||||
|
|
||||||
|
ONLINE_DOCS = {
|
||||||
|
"Adw-1": "https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1-latest/",
|
||||||
|
"Gdk-4.0": "https://docs.gtk.org/gdk4/",
|
||||||
|
"GdkPixbuf-2.0": "https://docs.gtk.org/gdk-pixbuf/",
|
||||||
|
"Gio-2.0": "https://docs.gtk.org/gio/",
|
||||||
|
"GLib-2.0": "https://docs.gtk.org/glib/",
|
||||||
|
"GModule-2.0": "https://docs.gtk.org/gmodule/",
|
||||||
|
"GObject-2.0": "https://docs.gtk.org/gobject/",
|
||||||
|
"Gsk-4.0": "https://docs.gtk.org/gsk4/",
|
||||||
|
"Gtk-4.0": "https://docs.gtk.org/gtk4/",
|
||||||
|
"GtkSource-5": "https://gnome.pages.gitlab.gnome.org/gtksourceview/gtksourceview5",
|
||||||
|
"Pango-1.0": "https://docs.gtk.org/Pango/",
|
||||||
|
"Shumate-1.0": "https://gnome.pages.gitlab.gnome.org/libshumate/",
|
||||||
|
"WebKit2-4.1": "https://webkitgtk.org/reference/webkit2gtk/stable/",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class GirType:
|
class GirType:
|
||||||
@property
|
@property
|
||||||
def doc(self) -> T.Optional[str]:
|
def doc(self) -> T.Optional[str]:
|
||||||
|
@ -291,10 +308,17 @@ class GirNode:
|
||||||
except:
|
except:
|
||||||
# Not a huge deal, but if you want docs in the language server you
|
# Not a huge deal, but if you want docs in the language server you
|
||||||
# should ensure .gir files are installed
|
# should ensure .gir files are installed
|
||||||
pass
|
sections.append("Documentation is not installed")
|
||||||
|
|
||||||
|
if self.online_docs:
|
||||||
|
sections.append(f"[Online documentation]({self.online_docs})")
|
||||||
|
|
||||||
return "\n\n---\n\n".join(sections)
|
return "\n\n---\n\n".join(sections)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def online_docs(self) -> T.Optional[str]:
|
||||||
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def signature(self) -> T.Optional[str]:
|
def signature(self) -> T.Optional[str]:
|
||||||
return None
|
return None
|
||||||
|
@ -328,6 +352,14 @@ class Property(GirNode):
|
||||||
def construct_only(self) -> bool:
|
def construct_only(self) -> bool:
|
||||||
return self.tl.PROP_CONSTRUCT_ONLY == 1
|
return self.tl.PROP_CONSTRUCT_ONLY == 1
|
||||||
|
|
||||||
|
@property
|
||||||
|
def online_docs(self) -> T.Optional[str]:
|
||||||
|
if ns := self.get_containing(Namespace).online_docs:
|
||||||
|
assert self.container is not None
|
||||||
|
return f"{ns}property.{self.container.name}.{self.name}.html"
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
class Argument(GirNode):
|
class Argument(GirNode):
|
||||||
def __init__(self, container: GirNode, tl: typelib.Typelib) -> None:
|
def __init__(self, container: GirNode, tl: typelib.Typelib) -> None:
|
||||||
|
@ -380,6 +412,14 @@ class Signal(GirNode):
|
||||||
)
|
)
|
||||||
return f"signal {self.container.full_name}::{self.name} ({args})"
|
return f"signal {self.container.full_name}::{self.name} ({args})"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def online_docs(self) -> T.Optional[str]:
|
||||||
|
if ns := self.get_containing(Namespace).online_docs:
|
||||||
|
assert self.container is not None
|
||||||
|
return f"{ns}signal.{self.container.name}.{self.name}.html"
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
class Interface(GirNode, GirType):
|
class Interface(GirNode, GirType):
|
||||||
def __init__(self, ns: "Namespace", tl: typelib.Typelib):
|
def __init__(self, ns: "Namespace", tl: typelib.Typelib):
|
||||||
|
@ -432,6 +472,13 @@ class Interface(GirNode, GirType):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@property
|
||||||
|
def online_docs(self) -> T.Optional[str]:
|
||||||
|
if ns := self.get_containing(Namespace).online_docs:
|
||||||
|
return f"{ns}interface.{self.name}.html"
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
class Class(GirNode, GirType):
|
class Class(GirNode, GirType):
|
||||||
def __init__(self, ns: "Namespace", tl: typelib.Typelib) -> None:
|
def __init__(self, ns: "Namespace", tl: typelib.Typelib) -> None:
|
||||||
|
@ -544,6 +591,13 @@ class Class(GirNode, GirType):
|
||||||
for impl in self.implements:
|
for impl in self.implements:
|
||||||
yield from impl.signals.values()
|
yield from impl.signals.values()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def online_docs(self) -> T.Optional[str]:
|
||||||
|
if ns := self.get_containing(Namespace).online_docs:
|
||||||
|
return f"{ns}class.{self.name}.html"
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
class TemplateType(GirType):
|
class TemplateType(GirType):
|
||||||
def __init__(self, name: str, parent: T.Optional[GirType]):
|
def __init__(self, name: str, parent: T.Optional[GirType]):
|
||||||
|
@ -646,6 +700,13 @@ class Enumeration(GirNode, GirType):
|
||||||
def assignable_to(self, type: GirType) -> bool:
|
def assignable_to(self, type: GirType) -> bool:
|
||||||
return type == self
|
return type == self
|
||||||
|
|
||||||
|
@property
|
||||||
|
def online_docs(self) -> T.Optional[str]:
|
||||||
|
if ns := self.get_containing(Namespace).online_docs:
|
||||||
|
return f"{ns}enum.{self.name}.html"
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
class Boxed(GirNode, GirType):
|
class Boxed(GirNode, GirType):
|
||||||
def __init__(self, ns: "Namespace", tl: typelib.Typelib) -> None:
|
def __init__(self, ns: "Namespace", tl: typelib.Typelib) -> None:
|
||||||
|
@ -658,6 +719,13 @@ class Boxed(GirNode, GirType):
|
||||||
def assignable_to(self, type) -> bool:
|
def assignable_to(self, type) -> bool:
|
||||||
return type == self
|
return type == self
|
||||||
|
|
||||||
|
@property
|
||||||
|
def online_docs(self) -> T.Optional[str]:
|
||||||
|
if ns := self.get_containing(Namespace).online_docs:
|
||||||
|
return f"{ns}boxed.{self.name}.html"
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
class Bitfield(Enumeration):
|
class Bitfield(Enumeration):
|
||||||
def __init__(self, ns: "Namespace", tl: typelib.Typelib) -> None:
|
def __init__(self, ns: "Namespace", tl: typelib.Typelib) -> None:
|
||||||
|
@ -753,6 +821,10 @@ class Namespace(GirNode):
|
||||||
else:
|
else:
|
||||||
return self.get_type(type_name)
|
return self.get_type(type_name)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def online_docs(self) -> T.Optional[str]:
|
||||||
|
return ONLINE_DOCS.get(f"{self.name}-{self.version}")
|
||||||
|
|
||||||
|
|
||||||
class Repository(GirNode):
|
class Repository(GirNode):
|
||||||
def __init__(self, tl: typelib.Typelib) -> None:
|
def __init__(self, tl: typelib.Typelib) -> None:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue