Skip to content

Commit

Permalink
api docs
Browse files Browse the repository at this point in the history
  • Loading branch information
retorquere committed May 15, 2024
1 parent 5484b24 commit 750d008
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
18 changes: 18 additions & 0 deletions setup/api-extractor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,20 @@ const CreatorType = {
type: 'string',
enum: [...creatorTypes].sort(),
}
const CreatorTypeArray = {
type: 'array',
items: CreatorType,
}
const CreatorTypeCollection = {
type: 'array',
items: {
type: 'array',
items: {
type: 'string',
enum: [...creatorTypes, '*'].sort()
}
}
}

function assert(cond, msg) {
if (cond) return
Expand Down Expand Up @@ -280,6 +294,10 @@ export class API {

case 'CreatorType':
return CreatorType
case 'CreatorTypeArray':
return CreatorTypeArray
case 'CreatorTypeCollection':
return CreatorTypeCollection

case 'Record':
assert(typeref.typeArguments.length === 2, `expected 2 types, found ${typeref.typeArguments.length}`)
Expand Down
2 changes: 1 addition & 1 deletion site/data/citekeyformatters/functions.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"<code>authorsAlpha</code>": "\n <details class=\"details\"><summary class=\"summary\">parameters:</summary>\n <table>\n <thead><tr><th>parameter</th><th>type</th><th>description</th><th>default</th></tr></thead>\n <tbody>\n <tr><td><code>creator</code></td><td><code>author</code> / <code>editor</code> / <code>translator</code> / <code>collaborator</code> / <code>*</code></td><td><p>kind of creator to select, <code>*</code> selects <code>author</code> first, and if not present, <code>editor</code>, <code>translator</code> or <code>collaborator</code>, in that order.</p></td><td><code>\"*\"</code> </td></tr>\n<tr><td><code>initials</code></td><td><i>boolean</i></td><td><p>add author initials</p></td><td><code>false</code> </td></tr>\n<tr><td><code>sep</code></td><td><i>string</i></td><td><p>use this character between authors</p></td><td><code>\" \"</code> </td></tr>\n </tbody>\n </table>\n </details>\n <p>Corresponds to the BibTeX style \"alpha\". One author: First three letters of the last name. Two to four authors: First letters of last names concatenated. More than four authors: First letters of last names of first three authors concatenated. \"+\" at the end. </p>",
"<code>authorsn</code>": "\n <details class=\"details\"><summary class=\"summary\">parameters:</summary>\n <table>\n <thead><tr><th>parameter</th><th>type</th><th>description</th><th>default</th></tr></thead>\n <tbody>\n <tr><td><code>n</code></td><td><i>number</i></td><td><p>the number of characters to take from the name, 0 = all</p></td><td><code>0</code> </td></tr>\n<tr><td><code>creator</code></td><td><code>author</code> / <code>editor</code> / <code>translator</code> / <code>collaborator</code> / <code>*</code></td><td><p>kind of creator to select, <code>*</code> selects <code>author</code> first, and if not present, <code>editor</code>, <code>translator</code> or <code>collaborator</code>, in that order.</p></td><td><code>\"*\"</code> </td></tr>\n<tr><td><code>initials</code></td><td><i>boolean</i></td><td><p>add author initials</p></td><td><code>false</code> </td></tr>\n<tr><td><code>sep</code></td><td><i>string</i></td><td><p>use this character between authors</p></td><td><code>\" \"</code> </td></tr>\n </tbody>\n </table>\n </details>\n <p>The last names of the first <code>n</code> (default: all) authors. </p>",
"<code>authshort</code>": "\n <details class=\"details\"><summary class=\"summary\">parameters:</summary>\n <table>\n <thead><tr><th>parameter</th><th>type</th><th>description</th><th>default</th></tr></thead>\n <tbody>\n <tr><td><code>creator</code></td><td><code>author</code> / <code>editor</code> / <code>translator</code> / <code>collaborator</code> / <code>*</code></td><td><p>kind of creator to select, <code>*</code> selects <code>author</code> first, and if not present, <code>editor</code>, <code>translator</code> or <code>collaborator</code>, in that order.</p></td><td><code>\"*\"</code> </td></tr>\n<tr><td><code>initials</code></td><td><i>boolean</i></td><td><p>add author initials</p></td><td><code>false</code> </td></tr>\n<tr><td><code>sep</code></td><td><i>string</i></td><td><p>use this character between authors</p></td><td><code>\".\"</code> </td></tr>\n </tbody>\n </table>\n </details>\n <p>The last name if one author/editor is given; the first character of up to three authors' last names if more than one author is given. A plus character is added, if there are more than three authors. </p>",
"<code>creators</code>": "\n <details class=\"details\"><summary class=\"summary\">parameters:</summary>\n <table>\n <thead><tr><th>parameter</th><th>type</th><th>description</th><th>default</th></tr></thead>\n <tbody>\n <tr><td><code>n</code></td><td><i>number</i> / [<i>number</i>, <i>number</i>]</td><td><p>select the first <code>n</code> creators (when passing a number) or the authors in this range (inclusive, when passing two values); negative numbers mean \"from the end\", default = 0 = all</p></td><td><code>0</code> </td></tr>\n<tr><td><code>type</code></td><td><code>*</code> / <code>artist</code> / <code>attorneyAgent</code> / <code>author</code> / <code>bookAuthor</code> / <code>cartographer</code> / <code>castMember</code> / <code>commenter</code> / <code>composer</code> / <code>contributor</code> / <code>cosponsor</code> / <code>counsel</code> / <code>director</code> / <code>editor</code> / <code>guest</code> / <code>interviewee</code> / <code>interviewer</code> / <code>inventor</code> / <code>performer</code> / <code>podcaster</code> / <code>presenter</code> / <code>producer</code> / <code>programmer</code> / <code>recipient</code> / <code>reviewedAuthor</code> / <code>scriptwriter</code> / <code>seriesEditor</code> / <code>sponsor</code> / <code>testimonyBy</code> / <code>translator</code> / <code>wordsBy</code> / <code>artist</code> / <code>attorneyAgent</code> / <code>author</code> / <code>bookAuthor</code> / <code>cartographer</code> / <code>castMember</code> / <code>commenter</code> / <code>composer</code> / <code>contributor</code> / <code>cosponsor</code> / <code>counsel</code> / <code>director</code> / <code>editor</code> / <code>guest</code> / <code>interviewee</code> / <code>interviewer</code> / <code>inventor</code> / <code>performer</code> / <code>podcaster</code> / <code>presenter</code> / <code>producer</code> / <code>programmer</code> / <code>recipient</code> / <code>reviewedAuthor</code> / <code>scriptwriter</code> / <code>seriesEditor</code> / <code>sponsor</code> / <code>testimonyBy</code> / <code>translator</code> / <code>wordsBy</code> / <code>*</code> / <code>artist</code> / <code>attorneyAgent</code> / <code>author</code> / <code>bookAuthor</code> / <code>cartographer</code> / <code>castMember</code> / <code>commenter</code> / <code>composer</code> / <code>contributor</code> / <code>cosponsor</code> / <code>counsel</code> / <code>director</code> / <code>editor</code> / <code>guest</code> / <code>interviewee</code> / <code>interviewer</code> / <code>inventor</code> / <code>performer</code> / <code>podcaster</code> / <code>presenter</code> / <code>producer</code> / <code>programmer</code> / <code>recipient</code> / <code>reviewedAuthor</code> / <code>scriptwriter</code> / <code>seriesEditor</code> / <code>sponsor</code> / <code>testimonyBy</code> / <code>translator</code> / <code>wordsBy</code></td><td><p>select only creators of given type(s). Default: all</p></td><td><code>[[\"primary\",\"editor\",\"translator\",\"*\"]]</code> </td></tr>\n<tr><td><code>name</code></td><td>a creator sprintf template with one or more of the variables <code>f</code> (family name) / <code>g</code> (given name) / <code>i</code> (first initial) / <code>I</code> (all initials)</td><td><p>sprintf-js template. Available named parameters are: <code>f</code> (family name), <code>g</code> (given name), <code>i</code> (initials)</p></td><td><code>\"%(f)s\"</code> </td></tr>\n<tr><td><code>etal</code></td><td><i>string</i></td><td><p>use this term to replace authors after <code>n</code> authors have been named</p></td><td><code>\"\"</code> </td></tr>\n<tr><td><code>sep</code></td><td><i>string</i></td><td><p>use this character between authors</p></td><td><code>\" \"</code> </td></tr>\n<tr><td><code>min</code></td><td><i>number</i></td><td><p>skip to the next pattern if there are less than <code>min</code> creators, 0 = ignore</p></td><td><code>0</code> </td></tr>\n<tr><td><code>max</code></td><td><i>number</i></td><td><p>skip to the next pattern if there are more than <code>max</code> creators, 0 = ignore</p></td><td><code>0</code> </td></tr>\n </tbody>\n </table>\n </details>\n <p>Author/editor information. </p>",
"<code>creators</code>": "\n <details class=\"details\"><summary class=\"summary\">parameters:</summary>\n <table>\n <thead><tr><th>parameter</th><th>type</th><th>description</th><th>default</th></tr></thead>\n <tbody>\n <tr><td><code>n</code></td><td><i>number</i> / [<i>number</i>, <i>number</i>]</td><td><p>select the first <code>n</code> creators (when passing a number) or the authors in this range (inclusive, when passing two values); negative numbers mean \"from the end\", default = 0 = all</p></td><td><code>0</code> </td></tr>\n<tr><td><code>type</code></td><td><code>artist</code> / <code>attorneyAgent</code> / <code>author</code> / <code>bookAuthor</code> / <code>cartographer</code> / <code>castMember</code> / <code>commenter</code> / <code>composer</code> / <code>contributor</code> / <code>cosponsor</code> / <code>counsel</code> / <code>director</code> / <code>editor</code> / <code>guest</code> / <code>interviewee</code> / <code>interviewer</code> / <code>inventor</code> / <code>performer</code> / <code>podcaster</code> / <code>presenter</code> / <code>producer</code> / <code>programmer</code> / <code>recipient</code> / <code>reviewedAuthor</code> / <code>scriptwriter</code> / <code>seriesEditor</code> / <code>sponsor</code> / <code>testimonyBy</code> / <code>translator</code> / <code>wordsBy</code> / <code>*</code> / <code>artist</code> / <code>attorneyAgent</code> / <code>author</code> / <code>bookAuthor</code> / <code>cartographer</code> / <code>castMember</code> / <code>commenter</code> / <code>composer</code> / <code>contributor</code> / <code>cosponsor</code> / <code>counsel</code> / <code>director</code> / <code>editor</code> / <code>guest</code> / <code>interviewee</code> / <code>interviewer</code> / <code>inventor</code> / <code>performer</code> / <code>podcaster</code> / <code>presenter</code> / <code>producer</code> / <code>programmer</code> / <code>recipient</code> / <code>reviewedAuthor</code> / <code>scriptwriter</code> / <code>seriesEditor</code> / <code>sponsor</code> / <code>testimonyBy</code> / <code>translator</code> / <code>wordsBy</code> / <code>*</code> / <code>artist</code> / <code>attorneyAgent</code> / <code>author</code> / <code>bookAuthor</code> / <code>cartographer</code> / <code>castMember</code> / <code>commenter</code> / <code>composer</code> / <code>contributor</code> / <code>cosponsor</code> / <code>counsel</code> / <code>director</code> / <code>editor</code> / <code>guest</code> / <code>interviewee</code> / <code>interviewer</code> / <code>inventor</code> / <code>performer</code> / <code>podcaster</code> / <code>presenter</code> / <code>producer</code> / <code>programmer</code> / <code>recipient</code> / <code>reviewedAuthor</code> / <code>scriptwriter</code> / <code>seriesEditor</code> / <code>sponsor</code> / <code>testimonyBy</code> / <code>translator</code> / <code>wordsBy</code></td><td><p>select only creators of given type(s). Default: all</p></td><td><code>[[\"primary\",\"editor\",\"translator\",\"*\"]]</code> </td></tr>\n<tr><td><code>name</code></td><td>a creator sprintf template with one or more of the variables <code>f</code> (family name) / <code>g</code> (given name) / <code>i</code> (first initial) / <code>I</code> (all initials)</td><td><p>sprintf-js template. Available named parameters are: <code>f</code> (family name), <code>g</code> (given name), <code>i</code> (initials)</p></td><td><code>\"%(f)s\"</code> </td></tr>\n<tr><td><code>etal</code></td><td><i>string</i></td><td><p>use this term to replace authors after <code>n</code> authors have been named</p></td><td><code>\"\"</code> </td></tr>\n<tr><td><code>sep</code></td><td><i>string</i></td><td><p>use this character between authors</p></td><td><code>\" \"</code> </td></tr>\n<tr><td><code>min</code></td><td><i>number</i></td><td><p>skip to the next pattern if there are less than <code>min</code> creators, 0 = ignore</p></td><td><code>0</code> </td></tr>\n<tr><td><code>max</code></td><td><i>number</i></td><td><p>skip to the next pattern if there are more than <code>max</code> creators, 0 = ignore</p></td><td><code>0</code> </td></tr>\n </tbody>\n </table>\n </details>\n <p>Author/editor information. </p>",
"<code>creatortypes</code>": "\n <details class=\"details\"><summary class=\"summary\">parameters:</summary>\n <table>\n <thead><tr><th>parameter</th><th>type</th><th>description</th><th>default</th></tr></thead>\n <tbody>\n <tr><td><code>match</code></td><td><i>RegExp</i></td><td><p>Regex to test the creator-type list. When passed, and the creator-type list does not match the regex, jump to the next formule. When it matches, return nothing but stay in the current formule. When no regex is passed, output the creator-type list for the item (mainly useful for debugging).</p></td><td></td></tr>\n </tbody>\n </table>\n </details>\n <p>This will return a comma-separated list of creator type information for all creators on the item in the form <code>&lt;1 or 2&gt;&lt;creator-type&gt;</code>, where <code>1</code> or <code>2</code> denotes a 1-part or 2-part creator, and <code>creator-type</code> is one of {{% citekey-formatters/creatortypes %}}, or <code>primary</code> for the primary creator-type of the Zotero item under consideration. The list is prefixed by the item type, so might look like <code>audioRecording:2performer,2performer,1composer</code>. </p>",
"<code>date</code>": "\n <details class=\"details\"><summary class=\"summary\">parameters:</summary>\n <table>\n <thead><tr><th>parameter</th><th>type</th><th>description</th><th>default</th></tr></thead>\n <tbody>\n <tr><td><code>format</code></td><td><i>string</i></td><td><p>sprintf-style format template</p></td><td><code>\"%Y-%m-%d\"</code> </td></tr>\n </tbody>\n </table>\n </details>\n <p>The date of the publication </p>",
"<code>extra</code>": "\n <details class=\"details\"><summary class=\"summary\">parameters:</summary>\n <table>\n <thead><tr><th>parameter</th><th>type</th><th>description</th><th>default</th></tr></thead>\n <tbody>\n <tr><td><code>variable</code></td><td><i>string</i></td><td><p>extra-field line identifier</p></td><td></td></tr>\n </tbody>\n </table>\n </details>\n <p>A pseudo-field from the extra field. eg if you have <code>Original date: 1970</code> in your <code>extra</code> field, you can get it as <code>extra(originalDate)</code>, or <code>tex.shortauthor: APA</code> which you could get with <code>extra('tex.shortauthor')</code>. Any <code>tex.</code> field will be picked up, the other fields can be selected from <a href=\"https://retorque.re/zotero-better-bibtex/exporting/extra-fields/\">this list</a> of key names. </p>",
Expand Down

0 comments on commit 750d008

Please sign in to comment.