Skip to content

Commit

Permalink
flesh out extension description and fix minor details
Browse files Browse the repository at this point in the history
  • Loading branch information
jadeddelta committed Nov 7, 2024
1 parent 96c7092 commit 8d40c44
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
10 changes: 6 additions & 4 deletions docs/developers/extension-development.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ let trial = {
extensions: [
{type: myAwesomeExtension, params: {demo: 'value'}}
]
});
};

//... extension code ...//
class MyAwesomeExtension {
Expand All @@ -91,7 +91,7 @@ let trial = {
extensions: [
{type: myAwesomeExtension, params: {demo: 'value'}}
]
});
};

//... extension code ...//
class MyAwesomeExtension {
Expand Down Expand Up @@ -122,7 +122,7 @@ let trial = {
on_finish: (data) => {
console.log(data.awesome); // will output 'value'.
}
});
};

//... extension code ...//
class MyAwesomeExtension {
Expand Down Expand Up @@ -168,9 +168,11 @@ The `version` field describes the version of the extension used and then durin t

The `data` field is an object containing all of the `data` generated for the plugin. Each 'data' object has a `type` and `default` property. Additionally, this should be only used for data you choose to generate. Any jsdoc (comments included in the /** */ tags) you include will be scraped as metadata if you are choosing to generate metadata. This scraped metadata will also be used to create the JsPsych documentation.

For more information on the various types of parameters one can include in their data field, see [here](./plugin-development.md#parameter-types).

### Optional methods

The extension can also include any additional methods that are necessary for interacting with it. See the [webgazer extension](../extensions/webgazer.md) for an example.
The extension can also include any additional methods that are necessary for interacting with it. See the [WebGazer extension](../extensions/webgazer.md) for an example.

## Advice for writing extensions

Expand Down
12 changes: 3 additions & 9 deletions docs/overview/extensions.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Extensions

Extensions are jsPsych modules that can interface with any plugin to extend the functionality of the plugin. A canonical example of an extension is eye tracking. An eye tracking extension allows a plugin to gather gaze data and add it to the plugin's data object.
In jsPsych, extensions allow one to extend the functionality of various plugins, giving individual plugins the ability to collect more data, display additional stimuli, and more. A canonical example of an extension is [eye tracking](../extensions/webgazer.md), which allow plugins to gather gaze data and add it to the their respective data objects. For a full list of extensions directly included in the jsPsych release, see [here](../extensions/list-of-extensions.md).

## Using an Extension

Expand All @@ -16,7 +16,7 @@ To use an extension in an experiment, you'll load the extension file via a `<scr
```js
initJsPsych({
extensions: [
{type: jsPsychExtensionExample, params: {...} }
{ type: jsPsychExtensionExample, params: {...} }
]
})
```
Expand All @@ -26,17 +26,11 @@ To enable an extension during a trial, add the extension to the `extensions` lis
```js
var trial = {
extensions: [
{type: jsPsychExtensionExample, params: {...} }
{ type: jsPsychExtensionExample, params: {...} }
]
}
```

## List of Extensions

Extension | Description
------ | -----------
[jspsych&#8209;ext&#8209;webgazer.js](../extensions/webgazer.md) | Enables eye tracking using the [WebGazer](https://webgazer.cs.brown.edu/) library.

## Writing an Extension

See our [developer's guide for extensions](../developers/extension-development.md) for information about how to create a new extension.

0 comments on commit 8d40c44

Please sign in to comment.