From c2308daf897055e056a0a51fbc445f7902c2f90b Mon Sep 17 00:00:00 2001 From: Kevin Date: Sat, 14 Sep 2024 04:15:27 -0300 Subject: Added examples for python and lua --- docs/libraries/bluetooth.md | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'docs/libraries/bluetooth.md') diff --git a/docs/libraries/bluetooth.md b/docs/libraries/bluetooth.md index 9aa7de7..e37593f 100644 --- a/docs/libraries/bluetooth.md +++ b/docs/libraries/bluetooth.md @@ -71,17 +71,33 @@ bluetoothctl --help ```js [ JavaScript] import Bluetooth from "gi://AstalBluetooth"; -const bluetooth = Bluetooth.get_default() +const bluetooth = Bluetooth.get_default(); -console.log(bluetooth.get_devices().map(d => d.name)) +console.log(bluetooth.get_devices().map((d) => d.name)); ``` ```py [ Python] -# Not yet documented +import gi + +gi.require_version("AstalBluetooth", "0.1") + +from gi.repository import AstalBluetooth + +bluetooth = AstalBluetooth.get_default() + +print("\n".join(d.get_name() for d in bluetooth.get_devices())) ``` ```lua [ Lua] --- Not yet documented +local lgi = require("lgi") + +local AstalBluetooth = lgi.require("AstalBluetooth", "0.1") + +local bluetooth = AstalBluetooth.get_default() + +for _, d in ipairs(bluetooth.devices) do + print(d.name) +end ``` ```vala [ Vala] -- cgit v1.2.3 From 4d5c7a7b514c7f4f71b2950f051b64c3e3df3008 Mon Sep 17 00:00:00 2001 From: Aylur Date: Sat, 14 Sep 2024 09:55:29 +0000 Subject: docs: lib examples consistency --- docs/libraries/bluetooth.md | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) (limited to 'docs/libraries/bluetooth.md') diff --git a/docs/libraries/bluetooth.md b/docs/libraries/bluetooth.md index e37593f..04d9db2 100644 --- a/docs/libraries/bluetooth.md +++ b/docs/libraries/bluetooth.md @@ -69,34 +69,31 @@ bluetoothctl --help :::code-group ```js [ JavaScript] -import Bluetooth from "gi://AstalBluetooth"; +import Bluetooth from "gi://AstalBluetooth" -const bluetooth = Bluetooth.get_default(); +const bluetooth = Bluetooth.get_default() -console.log(bluetooth.get_devices().map((d) => d.name)); +for (const device of bluetooth.get_devices()) { + print(device.name) +} ``` ```py [ Python] -import gi +from gi.repository import AstalBluetooth as Bluetooth -gi.require_version("AstalBluetooth", "0.1") +bluetooth = Bluetooth.get_default() -from gi.repository import AstalBluetooth - -bluetooth = AstalBluetooth.get_default() - -print("\n".join(d.get_name() for d in bluetooth.get_devices())) +for device in bluetooth.get_devices(): + print(device.get_name()) ``` ```lua [ Lua] -local lgi = require("lgi") - -local AstalBluetooth = lgi.require("AstalBluetooth", "0.1") +local Bluetooth = require("lgi").require("AstalBluetooth") -local bluetooth = AstalBluetooth.get_default() +local bluetooth = Bluetooth.get_default() for _, d in ipairs(bluetooth.devices) do - print(d.name) + print(d.name) end ``` -- cgit v1.2.3