From cd167ee63e75c3c2690d67d716dd72a5725f3885 Mon Sep 17 00:00:00 2001 From: Evan Welsh Date: Wed, 7 Jun 2023 23:22:00 -0700 Subject: [PATCH] docs: Update miscellaneous in-code documentation for modules Part-of: --- HACKING.md | 16 ++++++++-------- src/st/st-scrollable.c | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/HACKING.md b/HACKING.md index 03e113463..e32b18c86 100644 --- a/HACKING.md +++ b/HACKING.md @@ -66,7 +66,7 @@ library. These headers are not installed, distributed or introspected. Use UpperCamelCase when importing modules to distinguish them from ordinary variables, e.g. ```javascript - const GLib = imports.gi.GLib; + import GLib from 'gi://GLib'; ``` Imports should be categorized into one of two places. The top-most import block should contain only "environment imports". These are either modules from @@ -120,7 +120,7 @@ See [What's new in JavaScript 1.7](https://developer.mozilla.org/en/JavaScript/N There are many approaches to classes in JavaScript. We use standard ES6 classes whenever possible, that is when not inheriting from GObjects. ```javascript - var IconLabelMenuItem = class extends PopupMenu.PopupMenuBaseItem { + export class IconLabelMenuItem extends PopupMenu.PopupMenuBaseItem { constructor(icon, label) { super({ reactive: false }); this.actor.add_child(icon); @@ -136,7 +136,7 @@ whenever possible, that is when not inheriting from GObjects. For GObject inheritance, we use the GObject.registerClass() function provided by gjs. ```javascript - var MyActor = GObject.registerClass( + export const MyActor = GObject.registerClass( class MyActor extends Clutter.Actor { _init(params) { super._init(params); @@ -152,7 +152,7 @@ GObject Introspection is a powerful feature that allows us to have native bindings for almost any library built around GObject. If a library requires you to inherit from a type to use it, you can do so: ```javascript - var MyClutterActor = GObject.registerClass( + export const MyClutterActor = GObject.registerClass( class MyClutterActor extends Clutter.Actor { vfunc_get_preferred_width(forHeight) { @@ -203,7 +203,7 @@ wrapper class the "delegate". We sometimes use expando properties to set a property called `_delegate` on the actor itself: ```javascript - var MyActor = GObject.registerClass( + export const MyActor = GObject.registerClass( class MyActor extends Clutter.Actor { _init(params) { super._init(params); @@ -214,7 +214,7 @@ the actor itself: Or using the deprecated `actor`: ```javascript - var MyClass = class { + export class MyClass { constructor() { this.actor = new St.Button({ text: "This is a button" }); this.actor._delegate = this; @@ -261,8 +261,8 @@ prototype: ```javascript const FnorbLib = imports.fborbLib; - var MyClass = class { - _init() { + export class MyClass { + constructor() { let fnorb = new FnorbLib.Fnorb(); fnorb.connect('frobate', this._onFnorbFrobate.bind(this)); } diff --git a/src/st/st-scrollable.c b/src/st/st-scrollable.c index 3a77052db..a553c8b40 100644 --- a/src/st/st-scrollable.c +++ b/src/st/st-scrollable.c @@ -97,7 +97,7 @@ st_scrollable_default_init (StScrollableInterface *g_iface) * JavaScript code may override this as demonstrated below: * * |[ - * var MyScrollable = GObject.registerClass({ + * export const MyScrollable = GObject.registerClass({ * Properties: { * 'hadjustment': GObject.ParamSpec.override( * 'hadjustment',