Skip to content

Commit

Permalink
update getCitations() to always print jsPsych + no duplicates; update…
Browse files Browse the repository at this point in the history
… citation tool docs
  • Loading branch information
cherriechang committed Dec 9, 2024
1 parent 1b08438 commit 5e878d3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
8 changes: 4 additions & 4 deletions docs/about/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ This paper is an updated description of jsPsych and includes all current core te
Citations help us demonstrate that this library is used and valued, which allows us to continue working on it.

#### Cite using citation tool
#### Citation tool for third-party plugins/extensions

We also made a command-line citation tool that can be used to cite this library, as well as any plugins/extensions you use in your experiment that are developed by other developers. You can see this tool in action by following these steps:
jsPsych is an open-source, collaborative ecosystem, and many of the plugins/extensions you end up using may be contributed by third-party developers! We want to make sure they get recognition for their good work, so we made a command-line citation tool that you should use to cite this library and the plugins/extensions used in your experiment. You can see this tool in action by following these steps:

1. Launch a jsPsych experiment in your browser
2. Open up the browser console using Ctrl + ⇧ + J (Windows) or ⌘ + ⌥ + J (Mac)
3. Type `jsPsych.getCitations([jsPsychHtmlKeyboardResponse], "apa")`
3. Type `jsPsych.getCitations([], "apa")`

This should print the APA format citation for the `jsPsychHtmlKeyboardResponse` plugin, which you can then copy and paste into your working document. You can type any number of plugins/extensions by name in the array `[ ]` to generate a list of citations. We currently support APA formatting (`"apa"`) and BibTex formatting (`"bibtex"`).
This should print the APA format citation for the jsPsych library, which you can then copy and paste into your working document. You can type any number of plugins/extensions by name in the array `[ ]` to generate a list of citations, e.g. `jsPsych.getCitations([jsPsychHtmlKeyboardResponse, jsPsychMouseTrackingExtension], "apa")`. We currently support APA formatting (`"apa"`) and BibTex formatting (`"bibtex"`).
2 changes: 2 additions & 0 deletions packages/config/generateCitations.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export default function generateCitations() {
const citationCff = (() => {
let rawCff;
try {
// look for CITATION.cff in the current directory
rawCff = fs.readFileSync("./CITATION.cff", "utf-8").toString();
const cffData = yaml.parse(rawCff);
if (cffData["preferred-citation"]) {
Expand All @@ -30,6 +31,7 @@ export default function generateCitations() {
return yaml.stringify(rawCff);
} catch (error) {
try {
// look for CITATION.cff in the root of the repository
rawCff = fs.readFileSync(path.join(appRootPath.path, "CITATION.cff"), "utf-8").toString();
return yaml.stringify(rawCff);
} catch (error) {
Expand Down
8 changes: 7 additions & 1 deletion packages/jspsych/src/JsPsych.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,13 +272,19 @@ export class JsPsych {
}
// Check if array is empty
else if (plugins.length == 0) {
console.warn("No plugins/extensions provided");
console.log(
format == "apa"
? "de Leeuw, J. R., Gilbert, R. A., & Luchterhandt, B. (2023). jsPsych: Enabling an Open-Source Collaborative Ecosystem of Behavioral Experiments. Journal of Open Source Software, 8(85), 5351. https://doi.org/10.21105/joss.05351 "
: '@article{Leeuw2023jsPsych, author = {de Leeuw, Joshua R. and Gilbert, Rebecca A. and Luchterhandt, Bj{\\" o}rn}, journal = {Journal of Open Source Software}, doi = {10.21105/joss.05351}, issn = {2475-9066}, number = {85}, year = {2023}, month = {may 11}, pages = {5351}, publisher = {Open Journals}, title = {jsPsych: Enabling an {Open}-{Source} {Collaborative} {Ecosystem} of {Behavioral} {Experiments}}, url = {https://joss.theoj.org/papers/10.21105/joss.05351}, volume = {8}, } '
);
return;
}
// Check if format is supported
else if (!Object.keys(plugins[0]["info"].citations).includes(format)) {
throw new Error("Unsupported citation format");
} else {
const pluginsSet = new Set(plugins);
plugins = Array.from(pluginsSet);
plugins.map((plugin) => {
let pluginCitations = plugin["info"].citations;
console.log(format == "apa" ? `${pluginCitations.apa}` : `${pluginCitations.bibtex}`);
Expand Down

0 comments on commit 5e878d3

Please sign in to comment.