mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-01 22:31:14 +00:00
Add some documentation to the Model and ModelPeer
Also in this change: * Make ArrayModel<T> implement Model<T>. * Switch from jsdoc/better-docs to typedoc, which has much better support for type annotations.
This commit is contained in:
parent
45e8c94535
commit
27972145a7
4 changed files with 80 additions and 40 deletions
|
@ -1,33 +0,0 @@
|
||||||
{
|
|
||||||
"plugins": [
|
|
||||||
"plugins/markdown",
|
|
||||||
"node_modules/better-docs/typescript"
|
|
||||||
],
|
|
||||||
"opts": {
|
|
||||||
"template": "node_modules/better-docs",
|
|
||||||
"destination": "./docs"
|
|
||||||
},
|
|
||||||
"templates": {
|
|
||||||
"default": {
|
|
||||||
"outputSourceFiles": false
|
|
||||||
},
|
|
||||||
"better-docs": {
|
|
||||||
"name": "SixtyFPS Node Documentation",
|
|
||||||
"hideGenerator": true,
|
|
||||||
"navLinks": [
|
|
||||||
{
|
|
||||||
"label": "Github",
|
|
||||||
"href": "https://github.com/sixtyfpsui/sixtyfps"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"tags": {
|
|
||||||
"allowUnknownTags": [
|
|
||||||
"optional"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"source": {
|
|
||||||
"includePattern": "\\.(jsx|js|ts|tsx)$"
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -11,6 +11,9 @@ LICENSE END */
|
||||||
// Load the native library with `process.dlopen` instead of with `require`.
|
// Load the native library with `process.dlopen` instead of with `require`.
|
||||||
// This is only done for autotest that do not require nom or neon_cli to
|
// This is only done for autotest that do not require nom or neon_cli to
|
||||||
// copy the lib to its right place
|
// copy the lib to its right place
|
||||||
|
/**
|
||||||
|
* @hidden
|
||||||
|
*/
|
||||||
function load_native_lib() {
|
function load_native_lib() {
|
||||||
const os = require('os');
|
const os = require('os');
|
||||||
(process as any).dlopen(module, process.env.SIXTYFPS_NODE_NATIVE_LIB,
|
(process as any).dlopen(module, process.env.SIXTYFPS_NODE_NATIVE_LIB,
|
||||||
|
@ -18,8 +21,14 @@ function load_native_lib() {
|
||||||
return module.exports;
|
return module.exports;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @hidden
|
||||||
|
*/
|
||||||
let native = !process.env.SIXTYFPS_NODE_NATIVE_LIB ? require('../native/index.node') : load_native_lib();
|
let native = !process.env.SIXTYFPS_NODE_NATIVE_LIB ? require('../native/index.node') : load_native_lib();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @hidden
|
||||||
|
*/
|
||||||
class Component {
|
class Component {
|
||||||
protected comp: any;
|
protected comp: any;
|
||||||
|
|
||||||
|
@ -63,12 +72,68 @@ require.extensions['.60'] =
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ModelPeer is the interface that the run-time implements. An instance is
|
||||||
|
* set on dynamic Model<T> instances and can be used to notify the run-time
|
||||||
|
* of changes in the structure or data of the model.
|
||||||
|
*/
|
||||||
interface ModelPeer {
|
interface ModelPeer {
|
||||||
|
/**
|
||||||
|
* Call this function from our own model to notify that fields of data
|
||||||
|
* in the specified row have changed.
|
||||||
|
* @argument row
|
||||||
|
*/
|
||||||
rowDataChanged(row: number): void;
|
rowDataChanged(row: number): void;
|
||||||
|
/**
|
||||||
|
* Call this function from your own model to notify that one or multiple
|
||||||
|
* rows were added to the model, starting at the specified row.
|
||||||
|
* @param row
|
||||||
|
* @param count
|
||||||
|
*/
|
||||||
rowAdded(row: number, count: number): void;
|
rowAdded(row: number, count: number): void;
|
||||||
|
/**
|
||||||
|
* Call this function from your own model to notify that one or multiple
|
||||||
|
* rows were removed from the model, starting at the specified row.
|
||||||
|
* @param row
|
||||||
|
* @param count
|
||||||
|
*/
|
||||||
rowRemoved(row: number, count: number): void;
|
rowRemoved(row: number, count: number): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Model<T> is the interface for feeding dynamic data into
|
||||||
|
* `.60` views.
|
||||||
|
*
|
||||||
|
* A model is organized like a table with rows of data. The
|
||||||
|
* fields of the data type T behave like columns.
|
||||||
|
*/
|
||||||
|
interface Model<T> {
|
||||||
|
/**
|
||||||
|
* Implementations of this function must return the current number of rows.
|
||||||
|
*/
|
||||||
|
rowCount(): number;
|
||||||
|
/**
|
||||||
|
* Implementations of this function must return the data at the specified row.
|
||||||
|
* @param row
|
||||||
|
*/
|
||||||
|
rowData(row: number): T;
|
||||||
|
/**
|
||||||
|
* Implementations of this function must store the provided data parameter
|
||||||
|
* in the model at the specified row.
|
||||||
|
* @param row
|
||||||
|
* @param data
|
||||||
|
*/
|
||||||
|
setRowData(row: number, data: T): void;
|
||||||
|
/**
|
||||||
|
* This public member is set by the run-time and implementation must use this
|
||||||
|
* to notify the run-time of changes in the model.
|
||||||
|
*/
|
||||||
|
notify: ModelPeer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @hidden
|
||||||
|
*/
|
||||||
class NullPeer implements ModelPeer {
|
class NullPeer implements ModelPeer {
|
||||||
rowDataChanged(row: number): void { }
|
rowDataChanged(row: number): void { }
|
||||||
rowAdded(row: number, count: number): void { }
|
rowAdded(row: number, count: number): void { }
|
||||||
|
@ -78,14 +143,14 @@ class NullPeer implements ModelPeer {
|
||||||
/**
|
/**
|
||||||
* ArrayModel wraps a JavaScript array for use in `.60` views.
|
* ArrayModel wraps a JavaScript array for use in `.60` views.
|
||||||
*/
|
*/
|
||||||
class ArrayModel<T> {
|
class ArrayModel<T> implements Model<T> {
|
||||||
private a: Array<T>
|
private a: Array<T>
|
||||||
private notify: ModelPeer;
|
notify: ModelPeer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @template T
|
* @template T
|
||||||
* Creates a new ArrayModel.
|
* Creates a new ArrayModel.
|
||||||
*
|
*
|
||||||
* @param {Array<T>} arr
|
* @param {Array<T>} arr
|
||||||
*/
|
*/
|
||||||
constructor(arr: Array<T>) {
|
constructor(arr: Array<T>) {
|
||||||
|
@ -105,7 +170,7 @@ class ArrayModel<T> {
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Pushes new values to the array that's backing the model.
|
* Pushes new values to the array that's backing the model.
|
||||||
* @param {T} values
|
* @param {T} values
|
||||||
*/
|
*/
|
||||||
push(...values: T[]) {
|
push(...values: T[]) {
|
||||||
let size = this.a.length;
|
let size = this.a.length;
|
||||||
|
|
|
@ -11,10 +11,9 @@
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"install": "neon build --release && tsc",
|
"install": "neon build --release && tsc",
|
||||||
"build": "tsc",
|
"build": "tsc",
|
||||||
"docs": "jsdoc -c jsdoc.conf.json --readme README.md lib/index.ts"
|
"docs": "typedoc lib/index.ts"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"better-docs": "^2.3.2",
|
"typedoc": "^0.19.2"
|
||||||
"jsdoc": "^3.6.6"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,5 +58,14 @@
|
||||||
/* Advanced Options */
|
/* Advanced Options */
|
||||||
"skipLibCheck": true, /* Skip type checking of declaration files. */
|
"skipLibCheck": true, /* Skip type checking of declaration files. */
|
||||||
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
|
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
|
||||||
|
},
|
||||||
|
"typedocOptions": {
|
||||||
|
"mode": "file",
|
||||||
|
"out": "docs",
|
||||||
|
"readme": "README.md",
|
||||||
|
"disableSources": true,
|
||||||
|
"theme": "minimal",
|
||||||
|
"hideGenerator": true,
|
||||||
|
"name": "SixtyFPS Node"
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue