mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-01 14:21:16 +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`.
|
||||
// This is only done for autotest that do not require nom or neon_cli to
|
||||
// copy the lib to its right place
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
function load_native_lib() {
|
||||
const os = require('os');
|
||||
(process as any).dlopen(module, process.env.SIXTYFPS_NODE_NATIVE_LIB,
|
||||
|
@ -18,8 +21,14 @@ function load_native_lib() {
|
|||
return module.exports;
|
||||
}
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
let native = !process.env.SIXTYFPS_NODE_NATIVE_LIB ? require('../native/index.node') : load_native_lib();
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
class Component {
|
||||
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 {
|
||||
/**
|
||||
* 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;
|
||||
/**
|
||||
* 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;
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 {
|
||||
rowDataChanged(row: number): void { }
|
||||
rowAdded(row: number, count: number): void { }
|
||||
|
@ -78,9 +143,9 @@ class NullPeer implements ModelPeer {
|
|||
/**
|
||||
* ArrayModel wraps a JavaScript array for use in `.60` views.
|
||||
*/
|
||||
class ArrayModel<T> {
|
||||
class ArrayModel<T> implements Model<T> {
|
||||
private a: Array<T>
|
||||
private notify: ModelPeer;
|
||||
notify: ModelPeer;
|
||||
|
||||
/**
|
||||
* @template T
|
||||
|
|
|
@ -11,10 +11,9 @@
|
|||
"scripts": {
|
||||
"install": "neon build --release && tsc",
|
||||
"build": "tsc",
|
||||
"docs": "jsdoc -c jsdoc.conf.json --readme README.md lib/index.ts"
|
||||
"docs": "typedoc lib/index.ts"
|
||||
},
|
||||
"devDependencies": {
|
||||
"better-docs": "^2.3.2",
|
||||
"jsdoc": "^3.6.6"
|
||||
"typedoc": "^0.19.2"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,5 +58,14 @@
|
|||
/* Advanced Options */
|
||||
"skipLibCheck": true, /* Skip type checking of declaration files. */
|
||||
"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