summaryrefslogtreecommitdiff
path: root/lib/astal/io
diff options
context:
space:
mode:
Diffstat (limited to 'lib/astal/io')
-rw-r--r--lib/astal/io/application.vala6
-rw-r--r--lib/astal/io/file.vala2
-rw-r--r--lib/astal/io/gir.py58
-rw-r--r--lib/astal/io/meson.build48
-rw-r--r--lib/astal/io/process.vala8
-rw-r--r--lib/astal/io/time.vala6
6 files changed, 101 insertions, 27 deletions
diff --git a/lib/astal/io/application.vala b/lib/astal/io/application.vala
index a420128..c7bd311 100644
--- a/lib/astal/io/application.vala
+++ b/lib/astal/io/application.vala
@@ -21,8 +21,8 @@ public interface Application : Object {
}
/**
- * Starts a [[email protected]] and binds `XDG_RUNTIME_DIR/astal/<instance_name>.sock`.
- * This socket is then used by the astal cli. Not meant for public usage, but for [[email protected]_socket].
+ * Starts a [[email protected]] and binds `XDG_RUNTIME_DIR/astal/<instance_name>.sock`.
+ * This socket is then used by the astal cli. Not meant for public usage, but for [[email protected]_socket].
*/
public SocketService acquire_socket(Application app, out string sock) throws Error {
var name = app.instance_name;
@@ -186,7 +186,7 @@ public async string read_sock(SocketConnection conn) throws IOError {
* Write the socket of an Astal.Application instance.
*/
public async void write_sock(SocketConnection conn, string response) throws IOError {
- yield conn.output_stream.write_async(response.concat("\x04").data, Priority.DEFAULT);
+ yield conn.output_stream.write_async(@"$response\x04".data, Priority.DEFAULT);
}
[DBus (name="io.Astal.Application")]
diff --git a/lib/astal/io/file.vala b/lib/astal/io/file.vala
index e57f449..57b6dc0 100644
--- a/lib/astal/io/file.vala
+++ b/lib/astal/io/file.vala
@@ -48,7 +48,7 @@ public async void write_file_async(string path, string content) throws Error {
/**
* Monitor a file for changes. If the path is a directory, monitor it recursively.
* The callback will be called passed two parameters: the path of the file
- * that changed and an [[email protected]] indicating the reason.
+ * that changed and an [[email protected]] indicating the reason.
*/
public FileMonitor? monitor_file(string path, Closure callback) {
try {
diff --git a/lib/astal/io/gir.py b/lib/astal/io/gir.py
new file mode 100644
index 0000000..9ef680f
--- /dev/null
+++ b/lib/astal/io/gir.py
@@ -0,0 +1,58 @@
+"""
+Vala's generated gir does not contain comments,
+so we use valadoc to generate them. However, they are formatted
+for valadoc and not gi-docgen so we need to fix it.
+"""
+
+import xml.etree.ElementTree as ET
+import html
+import sys
+import subprocess
+
+
+def fix_gir(name: str, gir: str, out: str):
+ namespaces = {
+ "": "http://www.gtk.org/introspection/core/1.0",
+ "c": "http://www.gtk.org/introspection/c/1.0",
+ "glib": "http://www.gtk.org/introspection/glib/1.0",
+ }
+ for prefix, uri in namespaces.items():
+ ET.register_namespace(prefix, uri)
+
+ tree = ET.parse(gir)
+ root = tree.getroot()
+
+ for doc in root.findall(".//doc", namespaces):
+ if doc.text:
+ doc.text = (
+ html.unescape(doc.text).replace("<para>", "").replace("</para>", "")
+ )
+
+ if (inc := root.find("c:include", namespaces)) is not None:
+ inc.set("name", f"{name}.h")
+ else:
+ print("no c:include tag found", file=sys.stderr)
+ exit(1)
+
+ tree.write(out, encoding="utf-8", xml_declaration=True)
+
+
+def valadoc(name: str, gir: str, args: list[str]):
+ cmd = ["valadoc", "-o", "docs", "--package-name", name, "--gir", gir, *args]
+ try:
+ subprocess.run(cmd, check=True, text=True, capture_output=True)
+ except subprocess.CalledProcessError as e:
+ print(e.stderr, file=sys.stderr)
+ exit(1)
+
+
+if __name__ == "__main__":
+ name = sys.argv[1]
+ in_out = sys.argv[2].split(":")
+ args = sys.argv[3:]
+
+ gir = in_out[0]
+ out = in_out[1] if len(in_out) > 1 else gir
+
+ valadoc(name, gir, args)
+ fix_gir(name, gir, out)
diff --git a/lib/astal/io/meson.build b/lib/astal/io/meson.build
index 426a6d6..023dece 100644
--- a/lib/astal/io/meson.build
+++ b/lib/astal/io/meson.build
@@ -36,35 +36,41 @@ deps = [
dependency('gio-2.0'),
]
-sources = [
- config,
+sources = [config] + files(
'application.vala',
'file.vala',
'process.vala',
'time.vala',
'variable.vala',
-]
+)
lib = library(
meson.project_name(),
sources,
dependencies: deps,
+ vala_args: ['--vapi-comments'],
vala_header: meson.project_name() + '.h',
vala_vapi: meson.project_name() + '-' + api_version + '.vapi',
- vala_gir: gir,
version: meson.project_version(),
install: true,
- install_dir: [true, true, true, true],
+ install_dir: [true, true, true],
)
-import('pkgconfig').generate(
- lib,
- name: meson.project_name(),
- filebase: meson.project_name() + '-' + api_version,
- version: meson.project_version(),
- subdirs: meson.project_name(),
- requires: deps,
- install_dir: libdir / 'pkgconfig',
+pkgs = []
+foreach dep : deps
+ pkgs += ['--pkg=' + dep.name()]
+endforeach
+
+gir_tgt = custom_target(
+ gir,
+ command: [find_program('python3'), files('gir.py'), meson.project_name(), gir]
+ + pkgs
+ + sources,
+ input: sources,
+ depends: lib,
+ output: gir,
+ install: true,
+ install_dir: get_option('datadir') / 'gir-1.0',
)
custom_target(
@@ -72,14 +78,24 @@ custom_target(
command: [
find_program('g-ir-compiler'),
'--output', '@OUTPUT@',
- '--shared-library', libdir / '@PLAINNAME@',
+ '--shared-library', get_option('prefix') / get_option('libdir') / '@PLAINNAME@',
meson.current_build_dir() / gir,
],
input: lib,
output: typelib,
- depends: lib,
+ depends: [lib, gir_tgt],
install: true,
- install_dir: libdir / 'girepository-1.0',
+ install_dir: get_option('libdir') / 'girepository-1.0',
+)
+
+import('pkgconfig').generate(
+ lib,
+ name: meson.project_name(),
+ filebase: meson.project_name() + '-' + api_version,
+ version: meson.project_version(),
+ subdirs: meson.project_name(),
+ requires: deps,
+ install_dir: get_option('libdir') / 'pkgconfig',
)
executable(
diff --git a/lib/astal/io/process.vala b/lib/astal/io/process.vala
index 8767012..cfd05b9 100644
--- a/lib/astal/io/process.vala
+++ b/lib/astal/io/process.vala
@@ -1,5 +1,5 @@
/**
- * `Process` provides shortcuts for [[email protected]] with sane defaults.
+ * `Process` provides shortcuts for [[email protected]] with sane defaults.
*/
public class AstalIO.Process : Object {
private void read_stream(DataInputStream stream, bool err) {
@@ -92,7 +92,7 @@ public class AstalIO.Process : Object {
/**
* Start a new subprocess with the given command
- * which is parsed using [[email protected]_argv].
+ * which is parsed using [[email protected]_parse_argv].
*/
public static Process subprocess(string cmd) throws Error {
string[] argv;
@@ -125,7 +125,7 @@ public class AstalIO.Process : Object {
/**
* Execute a command synchronously.
- * The command is parsed using [[email protected]_argv].
+ * The command is parsed using [[email protected]_parse_argv].
*
* @return stdout of the subprocess
*/
@@ -160,7 +160,7 @@ public class AstalIO.Process : Object {
/**
* Execute a command asynchronously.
- * The command is parsed using [[email protected]_argv].
+ * The command is parsed using [[email protected]_parse_argv].
*
* @return stdout of the subprocess
*/
diff --git a/lib/astal/io/time.vala b/lib/astal/io/time.vala
index 29e7e1f..a799f2b 100644
--- a/lib/astal/io/time.vala
+++ b/lib/astal/io/time.vala
@@ -38,7 +38,7 @@ public class AstalIO.Time : Object {
}
/**
- * Start an interval timer with a [[email protected]].
+ * Start an interval timer with default Priority.
*/
public Time.interval_prio(uint interval, int prio = Priority.DEFAULT, Closure? fn) {
connect_closure(fn);
@@ -50,7 +50,7 @@ public class AstalIO.Time : Object {
}
/**
- * Start a timeout timer with a [[email protected]].
+ * Start a timeout timer with default Priority.
*/
public Time.timeout_prio(uint timeout, int prio = Priority.DEFAULT, Closure? fn) {
connect_closure(fn);
@@ -62,7 +62,7 @@ public class AstalIO.Time : Object {
}
/**
- * Start an idle timer with a [[email protected]].
+ * Start an idle timer with default priority.
*/
public Time.idle_prio(int prio = Priority.DEFAULT_IDLE, Closure? fn) {
connect_closure(fn);