Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions docs/developers/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,49 @@ To build a local copy of the docs, you will need to install `mkdocs`, `mkdocs-ma

Run the command `poetry install` in the root directory of jsPsych to install `mkdocs`, `mkdocs-material`, and their dependencies.

## Generating plugin documentation

Plugin documentation can be automatically generated from the JSDoc comments in plugin source files and examples in the `/examples` folder. The generator extracts:

- Plugin description from the class JSDoc comment
- Parameter information from the `info.parameters` object
- Data field information from the `info.data` object
- Individual trial configurations from the example files in `/examples`

The generator converts examples into the documentation format with interactive Code/Demo tabs, eliminating the need to maintain separate example sets.

To generate documentation for a single plugin:

```bash
npm run generate-plugin-docs -- html-button-response
```

To generate documentation for all plugins with demo HTML files:

```bash
npm run generate-plugin-docs -- --all --output docs/plugins --demos-output docs/demos
```

To see all available options:

```bash
npm run generate-plugin-docs -- --help
```

Options:

- `--output, -o`: Directory for generated markdown files
- `--demos-output, -d`: Directory for generated demo HTML files
- `--all`: Generate docs for all plugins
- `--list`: List all available plugins

The generated documentation follows the same format as the existing plugin docs, including:

- Parameters tables
- Data generated tables
- Install instructions
- Examples with Code/Demo tabs that embed interactive demos

## Building a local copy of the docs

Run `poetry run mike deploy [version] -u` to build a new version of the documentation or to override an existing version. For example, if you are testing an edit to version `7.2` of the documentation, run `poetry run mike deploy 7.2 -u`.
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"build:archive": "gulp createCoreDistArchive",
"update-unpkg-links": "gulp updateUnpkgLinks",
"update-plugin-versions": "gulp updatePluginVersions",
"generate-plugin-docs": "node packages/config/generatePluginDocs.js",
"prepare": "node -e 'process.exit(+!process.env.CI)' || (husky install && npm run build)",
"tsc": "turbo tsc",
"changeset": "changeset",
Expand Down
Loading