Skip to content

Commit c13979b

Browse files
committed
Improve JSDoc and types
1 parent 2971184 commit c13979b

File tree

10 files changed

+91
-901
lines changed

10 files changed

+91
-901
lines changed

package-lock.json

Lines changed: 10 additions & 890 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "proper-tags",
33
"description": "A few common utility template tags for ES2015",
4-
"version": "2.0.0-alpha.1",
4+
"version": "2.0.0-alpha.2",
55
"author": "Hexagon <https://github.com/hexagon>",
66
"bugs": {
77
"url": "http://github.com/declandewet/common-tags/issues"

src/commaLists/commaLists.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ import { createTag } from '../createTag/index.js';
22
import { stripIndent } from '../stripIndent/index.js';
33
import { inlineArrayTransformer } from '../inlineArrayTransformer/index.js';
44

5+
/**
6+
* Allows you to inline an array substitution as a comma-separated list.
7+
* @type {TemplateTag}
8+
*/
59
const commaLists = createTag(
610
inlineArrayTransformer({ separator: ',' }),
711
stripIndent,

src/commaListsAnd/commaListsAnd.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ import { createTag } from '../createTag/index.js';
22
import { stripIndent } from '../stripIndent/index.js';
33
import { inlineArrayTransformer } from '../inlineArrayTransformer/index.js';
44

5+
/**
6+
* Allows you to inline an array substitution as a comma-separated list, the last of which is preceded by the word "and".
7+
* @type {TemplateTag}
8+
*/
59
const commaListsAnd = createTag(
610
inlineArrayTransformer({ separator: ',', conjunction: 'and' }),
711
stripIndent,

src/commaListsOr/commaListsOr.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ import { createTag } from '../createTag/index.js';
22
import { stripIndent } from '../stripIndent/index.js';
33
import { inlineArrayTransformer } from '../inlineArrayTransformer/index.js';
44

5+
/**
6+
* Allows you to inline an array substitution as a comma-separated list, the last of which is preceded by the word "or".
7+
* @type {TemplateTag}
8+
*/
59
const commaListsOr = createTag(
610
inlineArrayTransformer({ separator: ',', conjunction: 'or' }),
711
stripIndent,

src/html/html.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ import { inlineArrayTransformer } from '../inlineArrayTransformer/index.js';
44
import { splitStringTransformer } from '../splitStringTransformer/index.js';
55
import { removeNonPrintingValuesTransformer } from '../removeNonPrintingValuesTransformer/index.js';
66

7+
/**
8+
* An HTML tag function that processes a template literal and returns an HTML string.
9+
* @type {TemplateTag}
10+
*/
711
const html = createTag(
812
splitStringTransformer('\n'),
913
removeNonPrintingValuesTransformer(),

src/id/id.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import { createTag } from '../createTag/index.js';
22

3+
/**
4+
* A no-op tag that might come in useful in some scenarios, e.g. mocking.
5+
* @type {TemplateTag}
6+
*/
37
const id = createTag();
48

59
export { id };

src/index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
2+
/**
3+
* JSTag
4+
* A function that takes a template literal and returns a string.
5+
* @typedef {function} JSTag
6+
* @param {TemplateStringsArray} literals - The template literal containing placeholders.
7+
* @param {...*} placeholders - The values to replace the placeholders in the template literal.
8+
* @returns {string} - The result string after processing the template literal.
9+
*/
10+
111
// core
212
export { createTag } from "./createTag/index.js";
313

types/proper-tags.d.cts

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,37 @@ export class TemplateTag {
1212
*/
1313
constructor(...transformers: any[]);
1414
}
15-
export const html: Function;
16-
export const commaLists: Function;
17-
export const commaListsAnd: Function;
18-
export const commaListsOr: Function;
15+
/**
16+
* An HTML tag function that processes a template literal and returns an HTML string.
17+
* @type {TemplateTag}
18+
*/
19+
export const html: TemplateTag;
20+
/**
21+
* Allows you to inline an array substitution as a comma-separated list.
22+
* @type {TemplateTag}
23+
*/
24+
export const commaLists: TemplateTag;
25+
/**
26+
* Allows you to inline an array substitution as a comma-separated list, the last of which is preceded by the word "and".
27+
* @type {TemplateTag}
28+
*/
29+
export const commaListsAnd: TemplateTag;
30+
/**
31+
* Allows you to inline an array substitution as a comma-separated list, the last of which is preceded by the word "or".
32+
* @type {TemplateTag}
33+
*/
34+
export const commaListsOr: TemplateTag;
1935
/**
2036
* Consumes a pipeline of composable transformer plugins and produces a template tag.
2137
* @param {...Object} [...rawTransformers] - An array or arguments list of transformers
2238
* @return {Function} - A template tag
2339
*/
2440
export function createTag(...rawTransformers: any[]): Function;
25-
export const id: Function;
41+
/**
42+
* A no-op tag that might come in useful in some scenarios, e.g. mocking.
43+
* @type {TemplateTag}
44+
*/
45+
export const id: TemplateTag;
2646
/**
2747
* Converts an array substitution to a string containing a list
2848
* @param {String} [opts.separator = ''] - The character that separates each item

types/proper-tags.d.ts

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,37 @@ export class TemplateTag {
1111
*/
1212
constructor(...transformers: any[]);
1313
}
14-
export const html: Function;
15-
export const commaLists: Function;
16-
export const commaListsAnd: Function;
17-
export const commaListsOr: Function;
14+
/**
15+
* An HTML tag function that processes a template literal and returns an HTML string.
16+
* @type {TemplateTag}
17+
*/
18+
export const html: TemplateTag;
19+
/**
20+
* Allows you to inline an array substitution as a comma-separated list.
21+
* @type {TemplateTag}
22+
*/
23+
export const commaLists: TemplateTag;
24+
/**
25+
* Allows you to inline an array substitution as a comma-separated list, the last of which is preceded by the word "and".
26+
* @type {TemplateTag}
27+
*/
28+
export const commaListsAnd: TemplateTag;
29+
/**
30+
* Allows you to inline an array substitution as a comma-separated list, the last of which is preceded by the word "or".
31+
* @type {TemplateTag}
32+
*/
33+
export const commaListsOr: TemplateTag;
1834
/**
1935
* Consumes a pipeline of composable transformer plugins and produces a template tag.
2036
* @param {...Object} [...rawTransformers] - An array or arguments list of transformers
2137
* @return {Function} - A template tag
2238
*/
2339
export function createTag(...rawTransformers: any[]): Function;
24-
export const id: Function;
40+
/**
41+
* A no-op tag that might come in useful in some scenarios, e.g. mocking.
42+
* @type {TemplateTag}
43+
*/
44+
export const id: TemplateTag;
2545
/**
2646
* Converts an array substitution to a string containing a list
2747
* @param {String} [opts.separator = ''] - The character that separates each item

0 commit comments

Comments
 (0)