Skip to content

Commit

Permalink
Merge pull request #116 from vzhang03/v8-docs-updates
Browse files Browse the repository at this point in the history
Fixed templates to match v8 version and data parameter standards for …
  • Loading branch information
jodeleeuw authored Jul 22, 2024
2 parents 03ea042 + 93b0d99 commit 774f50e
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 7 deletions.
14 changes: 13 additions & 1 deletion templates/extension-template-js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,24 @@ var _globalName_ = (function (jspsych) {

on_finish(params) {
return {
data_property: "data_value",
data1: 99, // Make sure this type and name matches the information for data1 in the data object contained within the info const.
data2: "hello world!", // Make sure this type and name matches the information for data2 in the data object contained within the info const.
};
}
}
ExtensionNameExtension.info = {
name: "{name}",
version: "1.0.0", // When working in a Javascript environment with no build, you will need to manually put set the version information. This is used for metadata purposes and publishing.
data: {
/** Provide a clear description of the data1 that could be used as documentation. We will eventually use these comments to automatically build documentation and produce metadata. */
data1: {
type: ParameterType.INT,
},
/** Provide a clear description of the data2 that could be used as documentation. We will eventually use these comments to automatically build documentation and produce metadata. */
data2: {
type: ParameterType.STRING,
},
},
};

return ExtensionNameExtension;
Expand Down
18 changes: 16 additions & 2 deletions templates/extension-template-ts/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { JsPsych, JsPsychExtension, JsPsychExtensionInfo } from "jspsych";
import { JsPsych, JsPsychExtension, JsPsychExtensionInfo, ParameterType } from "jspsych";

import { version } from "../package.json";

interface InitializeParameters {}

Expand All @@ -19,6 +21,17 @@ interface OnFinishParameters {}
class ExtensionNameExtension implements JsPsychExtension {
static info: JsPsychExtensionInfo = {
name: "{name}",
version: version,
data: {
/** Provide a clear description of the data1 that could be used as documentation. We will eventually use these comments to automatically build documentation and produce metadata. */
data1: {
type: ParameterType.INT,
},
/** Provide a clear description of the data2 that could be used as documentation. We will eventually use these comments to automatically build documentation and produce metadata. */
data2: {
type: ParameterType.STRING,
},
},
};

constructor(private jsPsych: JsPsych) {}
Expand All @@ -35,7 +48,8 @@ class ExtensionNameExtension implements JsPsychExtension {

on_finish = ({}: OnFinishParameters): { [key: string]: any } => {
return {
data_property: "data_value",
data1: 99, // Make sure this type and name matches the information for data1 in the data object contained within the info const.
data2: "hello world!", // Make sure this type and name matches the information for data2 in the data object contained within the info const.
};
};
}
Expand Down
3 changes: 2 additions & 1 deletion templates/extension-template-ts/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"extends": "@jspsych/config/tsconfig.contrib.json",
"compilerOptions": {
"baseUrl": "."
"baseUrl": ".",
"resolveJsonModule": true
},
"include": ["src"]
}
16 changes: 15 additions & 1 deletion templates/plugin-template-js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,29 @@ var _globalName_ = (function (jspsych) {

const info = {
name: "{name}",
version: "1.0.0", // When working in a Javascript environment with no build, you will need to manually put set the version information. This is used for metadata purposes and publishing.
parameters: {
/** Provide a clear description of the parameter_name that could be used as documentation. We will eventually use these comments to automatically build documentation and produce metadata. */
parameter_name: {
type: jspsych.ParameterType.INT,
default: undefined,
},
/** Provide a clear description of the parameter_name2 that could be used as documentation. We will eventually use these comments to automatically build documentation and produce metadata. */
parameter_name2: {
type: jspsych.ParameterType.IMAGE,
default: undefined,
},
},
data: {
/** Provide a clear description of the data1 that could be used as documentation. We will eventually use these comments to automatically build documentation and produce metadata. */
data1: {
type: ParameterType.INT,
},
/** Provide a clear description of the data2 that could be used as documentation. We will eventually use these comments to automatically build documentation and produce metadata. */
data2: {
type: ParameterType.STRING,
},
},
};

/**
Expand All @@ -30,7 +43,8 @@ var _globalName_ = (function (jspsych) {
trial(display_element, trial) {
// data saving
var trial_data = {
parameter_name: "parameter value",
data1: 99, // Make sure this type and name matches the information for data1 in the data object contained within the info const.
data2: "hello world!", // Make sure this type and name matches the information for data2 in the data object contained within the info const.
};
// end trial
this.jsPsych.finishTrial(trial_data);
Expand Down
18 changes: 17 additions & 1 deletion templates/plugin-template-ts/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,32 @@
import { JsPsych, JsPsychPlugin, ParameterType, TrialType } from "jspsych";

import { version } from "../package.json";

const info = <const>{
name: "{name}",
version: version,
parameters: {
/** Provide a clear description of the parameter_name that could be used as documentation. We will eventually use these comments to automatically build documentation and produce metadata. */
parameter_name: {
type: ParameterType.INT, // BOOL, STRING, INT, FLOAT, FUNCTION, KEY, KEYS, SELECT, HTML_STRING, IMAGE, AUDIO, VIDEO, OBJECT, COMPLEX
default: undefined,
},
/** Provide a clear description of the parameter_name2 that could be used as documentation. We will eventually use these comments to automatically build documentation and produce metadata. */
parameter_name2: {
type: ParameterType.IMAGE,
default: undefined,
},
},
data: {
/** Provide a clear description of the data1 that could be used as documentation. We will eventually use these comments to automatically build documentation and produce metadata. */
data1: {
type: ParameterType.INT,
},
/** Provide a clear description of the data2 that could be used as documentation. We will eventually use these comments to automatically build documentation and produce metadata. */
data2: {
type: ParameterType.STRING,
},
},
};

type Info = typeof info;
Expand All @@ -32,7 +47,8 @@ class PluginNamePlugin implements JsPsychPlugin<Info> {
trial(display_element: HTMLElement, trial: TrialType<Info>) {
// data saving
var trial_data = {
parameter_name: "parameter value",
data1: 99, // Make sure this type and name matches the information for data1 in the data object contained within the info const.
data2: "hello world!", // Make sure this type and name matches the information for data2 in the data object contained within the info const.
};

// end trial
Expand Down
3 changes: 2 additions & 1 deletion templates/plugin-template-ts/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"extends": "@jspsych/config/tsconfig.contrib.json",
"compilerOptions": {
"baseUrl": "."
"baseUrl": ".",
"resolveJsonModule": true
},
"include": ["src"]
}

0 comments on commit 774f50e

Please sign in to comment.