summaryrefslogtreecommitdiff
path: root/ext/js/data/anki-note-builder.js
diff options
context:
space:
mode:
authorCashew <52880648+Scrub1492@users.noreply.github.com>2023-12-19 12:44:40 +0900
committerGitHub <noreply@github.com>2023-12-19 03:44:40 +0000
commitc661eafa7d57c32e33e51dd6eb787b97832e97f0 (patch)
tree1a68a563f9f1960d528595d6b33f74cb506bd77e /ext/js/data/anki-note-builder.js
parenteb7bf9542c92ea7937d4b4a699ae2d47270da96b (diff)
Add some JSDoc annotations to describe code functionality. (#355)
* lesen-tan initial commit * update README.md * tidy up code * opt for Map<K, V> instead of Object * Document dev/* * add docs for deinflector.js * update deinflector example * Annotate * Revert "Merge branch 'development' of https://github.com/Scrub1492/lesen-tan into development" This reverts commit b92348f702bc031b36f24462adfa940d17f9ecdd, reversing changes made to 3255e6d963281af3533dcf1e893df39032d29fec. * Lint error fix * Lint error fix
Diffstat (limited to 'ext/js/data/anki-note-builder.js')
-rw-r--r--ext/js/data/anki-note-builder.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/ext/js/data/anki-note-builder.js b/ext/js/data/anki-note-builder.js
index 864bd2d4..80cc210a 100644
--- a/ext/js/data/anki-note-builder.js
+++ b/ext/js/data/anki-note-builder.js
@@ -22,9 +22,16 @@ import {TemplateRendererProxy} from '../templates/template-renderer-proxy.js';
import {yomitan} from '../yomitan.js';
import {AnkiUtil} from './anki-util.js';
+/**
+ * Anki Note Builder Class.
+ */
export class AnkiNoteBuilder {
/**
+ * Initiate an instance of AnkiNoteBuilder.
* @param {{japaneseUtil: import('../language/sandbox/japanese-util.js').JapaneseUtil}} details
+ * @example
+ * const japaneseUtil = new JapaneseUtil(null);
+ * const ankiNoteBuilder = new AnkiNoteBuilder({japaneseUtil});
*/
constructor({japaneseUtil}) {
/** @type {import('../language/sandbox/japanese-util.js').JapaneseUtil} */
@@ -40,8 +47,30 @@ export class AnkiNoteBuilder {
}
/**
+ * Creates an Anki note.
* @param {import('anki-note-builder').CreateNoteDetails} details
* @returns {Promise<import('anki-note-builder').CreateNoteResult>}
+ * @example
+ * const ankiNoteBuilder = new AnkiNoteBuilder({japaneseUtil});
+ * const details = {
+ * dictionaryEntry,
+ * mode: 'test',
+ * context,
+ * template,
+ * deckName: 'deckName',
+ * modelName: 'modelName',
+ * fields,
+ * tags: ['yomitan'],
+ * checkForDuplicates: true,
+ * duplicateScope: 'collection',
+ * duplicateScopeCheckAllModels: false,
+ * resultOutputMode: mode,
+ * glossaryLayoutMode: 'default',
+ * compactTags: false,
+ * requirements: [],
+ * mediaOptions: null
+ * };
+ * const {note: {fields: noteFields}, errors} = await ankiNoteBuilder.createNote(details);
*/
async createNote({
dictionaryEntry,