docs: Update miscellaneous in-code documentation for modules

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1499>
This commit is contained in:
Evan Welsh 2023-06-07 23:22:00 -07:00 committed by Florian Müllner
parent 64aa871a8a
commit cd167ee63e
2 changed files with 9 additions and 9 deletions

View File

@ -66,7 +66,7 @@ library. These headers are not installed, distributed or introspected.
Use UpperCamelCase when importing modules to distinguish them from ordinary Use UpperCamelCase when importing modules to distinguish them from ordinary
variables, e.g. variables, e.g.
```javascript ```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 Imports should be categorized into one of two places. The top-most import block
should contain only "environment imports". These are either modules from 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 There are many approaches to classes in JavaScript. We use standard ES6 classes
whenever possible, that is when not inheriting from GObjects. whenever possible, that is when not inheriting from GObjects.
```javascript ```javascript
var IconLabelMenuItem = class extends PopupMenu.PopupMenuBaseItem { export class IconLabelMenuItem extends PopupMenu.PopupMenuBaseItem {
constructor(icon, label) { constructor(icon, label) {
super({ reactive: false }); super({ reactive: false });
this.actor.add_child(icon); 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 For GObject inheritance, we use the GObject.registerClass() function provided
by gjs. by gjs.
```javascript ```javascript
var MyActor = GObject.registerClass( export const MyActor = GObject.registerClass(
class MyActor extends Clutter.Actor { class MyActor extends Clutter.Actor {
_init(params) { _init(params) {
super._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 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: you to inherit from a type to use it, you can do so:
```javascript ```javascript
var MyClutterActor = GObject.registerClass( export const MyClutterActor = GObject.registerClass(
class MyClutterActor extends Clutter.Actor { class MyClutterActor extends Clutter.Actor {
vfunc_get_preferred_width(forHeight) { 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 We sometimes use expando properties to set a property called `_delegate` on
the actor itself: the actor itself:
```javascript ```javascript
var MyActor = GObject.registerClass( export const MyActor = GObject.registerClass(
class MyActor extends Clutter.Actor { class MyActor extends Clutter.Actor {
_init(params) { _init(params) {
super._init(params); super._init(params);
@ -214,7 +214,7 @@ the actor itself:
Or using the deprecated `actor`: Or using the deprecated `actor`:
```javascript ```javascript
var MyClass = class { export class MyClass {
constructor() { constructor() {
this.actor = new St.Button({ text: "This is a button" }); this.actor = new St.Button({ text: "This is a button" });
this.actor._delegate = this; this.actor._delegate = this;
@ -261,8 +261,8 @@ prototype:
```javascript ```javascript
const FnorbLib = imports.fborbLib; const FnorbLib = imports.fborbLib;
var MyClass = class { export class MyClass {
_init() { constructor() {
let fnorb = new FnorbLib.Fnorb(); let fnorb = new FnorbLib.Fnorb();
fnorb.connect('frobate', this._onFnorbFrobate.bind(this)); fnorb.connect('frobate', this._onFnorbFrobate.bind(this));
} }

View File

@ -97,7 +97,7 @@ st_scrollable_default_init (StScrollableInterface *g_iface)
* JavaScript code may override this as demonstrated below: * JavaScript code may override this as demonstrated below:
* *
* |[<!-- language="JavaScript" --> * |[<!-- language="JavaScript" -->
* var MyScrollable = GObject.registerClass({ * export const MyScrollable = GObject.registerClass({
* Properties: { * Properties: {
* 'hadjustment': GObject.ParamSpec.override( * 'hadjustment': GObject.ParamSpec.override(
* 'hadjustment', * 'hadjustment',