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:
parent
64aa871a8a
commit
cd167ee63e
16
HACKING.md
16
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));
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ st_scrollable_default_init (StScrollableInterface *g_iface)
|
||||
* JavaScript code may override this as demonstrated below:
|
||||
*
|
||||
* |[<!-- language="JavaScript" -->
|
||||
* var MyScrollable = GObject.registerClass({
|
||||
* export const MyScrollable = GObject.registerClass({
|
||||
* Properties: {
|
||||
* 'hadjustment': GObject.ParamSpec.override(
|
||||
* 'hadjustment',
|
||||
|
Loading…
x
Reference in New Issue
Block a user