docs: add internal types in apidoc (#734)

* docs: add internal types in apidoc

* chore: downgrade package-lock version for NodeJS 14

* test: test case when performance uses Date.now
This commit is contained in:
Jun Yang
2024-08-17 00:55:24 +08:00
committed by GitHub
parent 4548c11406
commit e941378535
13 changed files with 662 additions and 612 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
rm -rf docs/source/api
typedoc ./src --gitRevision master --out docs/source/api
typedoc --plugin typedoc-plugin-missing-exports ./src --gitRevision master --out docs/source/api
+3 -1
View File
@@ -19,7 +19,9 @@ pretty_urls:
trailing_html: false
theme: navy
skip_render: "api/**/*"
skip_render: "api/**"
ignore: "api/**"
include: "api/**"
highlight:
enable: false
prismjs:
+535 -494
View File
File diff suppressed because it is too large Load Diff
+3 -3
View File
@@ -3,7 +3,7 @@
"version": "0.0.0",
"private": true,
"hexo": {
"version": "5.4.0"
"version": "7.3.0"
},
"scripts": {
"build": "hexo generate",
@@ -13,7 +13,7 @@
},
"dependencies": {
"cheerio": "^0.22.0",
"hexo": "^5.4.0",
"hexo": "^7.3.0",
"hexo-algolia": "^1.3.1",
"hexo-clean-css": "^1.0.0",
"hexo-filter-nofollow": "^2.0.2",
@@ -34,4 +34,4 @@
"engines": {
"node": ">=8.10.0"
}
}
}
+1 -1
View File
@@ -7,7 +7,7 @@ const { readFileSync } = require('fs')
const cheerio = require('cheerio')
const fullUrlFor = hexo.extend.helper.get('full_url_for').bind(hexo)
const localizedPath = ['tutorials', 'filters', 'tags', 'playground', 'api']
const localizedPath = ['tutorials', 'filters', 'tags', 'playground']
hexo.extend.helper.register('page_nav', function () {
const type = this.page.canonical_path.split('/')[0]
-50
View File
@@ -128,53 +128,3 @@ tags:
tablerow: tablerow.html
unless: unless.html
when: case.html
api:
quick_entry:
Liquid: "../classes/liquid_.liquid.html"
LiquidOptions: "../interfaces/liquid_options_.liquidoptions.html"
FS: "../interfaces/fs_fs_.fs.html"
Cache: "../interfaces/cache_cache_.cache.html"
classes:
BlankDrop: "../classes/drop_blank_drop_.blankdrop.html"
Context: "../classes/context_context_.context.html"
DelimitedToken: "../classes/tokens_delimited_token_.delimitedtoken.html"
Drop: "../classes/drop_drop_.drop.html"
EmptyDrop: "../classes/drop_empty_drop_.emptydrop.html"
Expression: "../classes/render_expression_.expression.html"
FilterToken: "../classes/tokens_filter_token_.filtertoken.html"
ForloopDrop: "../classes/drop_forloop_drop_.forloopdrop.html"
HTMLToken: "../classes/tokens_html_token_.htmltoken.html"
HashToken: "../classes/tokens_hash_token_.hashtoken.html"
LRU: "../classes/cache_lru_.lru.html"
Liquid: "../classes/liquid_.liquid.html"
LiteralToken: "../classes/tokens_literal_token_.literaltoken.html"
NullDrop: "../classes/drop_null_drop_.nulldrop.html"
NumberToken: "../classes/tokens_number_token_.numbertoken.html"
OperatorToken: "../classes/tokens_operator_token_.operatortoken.html"
OutputToken: "../classes/tokens_output_token_.outputtoken.html"
ParseError: "../classes/util_error_.parseerror.html"
ParseStream: "../classes/parser_parse_stream_.parsestream.html"
Parser: "../classes/parser_parser_.parser.html"
PropertyaccessToken: "../classes/tokens_property_access_token_.propertyaccesstoken.html"
QuotedToken: "../classes/tokens_quoted_token_.quotedtoken.html"
RangeToken: "../classes/tokens_range_token_.rangetoken.html"
Render: "../classes/render_render_.render.html"
RenderError: "../classes/util_error_.rendererror.html"
TablerowloopDrop: "../classes/drop_tablerowloop_drop_.tablerowloopdrop.html"
TagToken: "../classes/tokens_tag_token_.tagtoken.html"
Token: "../classes/tokens_token_.token.html"
TokenizationError: "../classes/util_error_.tokenizationerror.html"
Tokenizer: "../classes/parser_tokenizer_.tokenizer.html"
WordToken: "../classes/tokens_word_token_.wordtoken.html"
enums:
BlockMode: "../enums/context_block_mode_.blockmode.html"
TokenKind: "../enums/parser_token_kind_.tokenkind.html"
interfaces:
Cache: "../interfaces/cache_cache_.cache.html"
FilterImplOptions: "../interfaces/template_filter_filter_impl_options_.filterimploptions.html"
FS: "../interfaces/fs_fs_.fs.html"
LiquidOptions: "../interfaces/liquid_options_.liquidoptions.html"
NormalizedFullOptions: "../interfaces/liquid_options_.normalizedfulloptions.html"
PlainObject: "../interfaces/context_scope_.plainobject.html"
TagImplOptions: "../interfaces/template_tag_tag_impl_options_.tagimploptions.html"
+1 -1
View File
@@ -68,7 +68,7 @@ Here's a demo for browsers: [demo/browser](https://github.com/harttle/liquidjs/t
## Abstract File System
LiquidJS defines an abstract file system interface in [src/fs/fs.ts][ifs] and the default implementation is [src/fs/fs-impl.ts][fs-node] for Node.js and [src/build/fs-impl-browser.ts][fs-browser] for the browser bundle.
LiquidJS defines an [abstract file system interface][ifs] and the default implementation is [src/fs/fs-impl.ts][fs-node] for Node.js and [src/build/fs-impl-browser.ts][fs-browser] for the browser bundle.
The `Liquid` constructor provides a [fs][fs] option to specify the file system implementation. It's supposed to be used to define customized template fetching logic, i.e. fetch template from a database table, like:
+1 -1
View File
@@ -74,7 +74,7 @@ var engine = new Liquid({
## 文件系统接口
LiquidJS 定义了一个文件系统接口[src/fs/ifs.ts][ifs],在 Node.js 下的默认实现是 [src/fs/node.ts][fs-node],在浏览器打包文件中的默认实现是 [src/fs/browser.ts][fs-browser]。
LiquidJS 定义了一个[文件系统接口][ifs],在 Node.js 下的默认实现是 [src/fs/node.ts][fs-node],在浏览器打包文件中的默认实现是 [src/fs/browser.ts][fs-browser]。
你可以通过创建 `Liquid` 时的 [fs][fs] 参数来指定一个自定义实现来指定如何读取模板文件。比如从数据库里读取:
```javascript
-5
View File
@@ -62,10 +62,5 @@ sidebar:
overview: Overview
tags:
overview: Overview
api:
quick_entry: Quick Entry
classes: Classes
enums: Enums
interfaces: Interfaces
footer:
license: 'Documentation licensed under <a href="https://creativecommons.org/licenses/by/4.0/" target="_blank">CC BY 4.0</a>.'
-5
View File
@@ -62,11 +62,6 @@ sidebar:
overview: 概述
tags:
overview: 概述
api:
quick_entry: 快速入口
classes:
enums: 枚举
interfaces: 接口
footer:
license: '本文档通过 <a href="http://creativecommons.org/licenses/by/4.0/" target="_blank">CC BY 4.0</a> 授权。'
+106 -40
View File
@@ -1421,6 +1421,15 @@
"read-pkg-up": "^7.0.0"
}
},
"@shikijs/core": {
"version": "1.13.0",
"resolved": "https://registry.npmjs.org/@shikijs/core/-/core-1.13.0.tgz",
"integrity": "sha512-Mj5NVfbAXcD1GnwOTSPl8hBn/T8UDpfFQTptp+p41n/CbUcJtOq98WaRD7Lz3hCglYotUTHUWtzu3JhK6XlkAA==",
"dev": true,
"requires": {
"@types/hast": "^3.0.4"
}
},
"@sinclair/typebox": {
"version": "0.25.24",
"resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.25.24.tgz",
@@ -1578,6 +1587,15 @@
"@types/node": "*"
}
},
"@types/hast": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/@types/hast/-/hast-3.0.4.tgz",
"integrity": "sha512-WPs+bbQw5aCj+x6laNGWLH3wviHtoCv/P3+otBhbOhJgG8qtpdAMlTCxLtsTWA7LH1Oh/bFCHsBn0TPS5m30EQ==",
"dev": true,
"requires": {
"@types/unist": "*"
}
},
"@types/istanbul-lib-coverage": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.4.tgz",
@@ -1754,6 +1772,12 @@
"integrity": "sha512-Q5vtl1W5ue16D+nIaW8JWebSSraJVlK+EthKn7e7UcD4KWsaSJ8BqGPXNaPghgtcn/fhvrN17Tv8ksUsQpiplw==",
"dev": true
},
"@types/unist": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.3.tgz",
"integrity": "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==",
"dev": true
},
"@types/yargs": {
"version": "17.0.22",
"resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.22.tgz",
@@ -2112,12 +2136,6 @@
"integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==",
"dev": true
},
"ansi-sequence-parser": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/ansi-sequence-parser/-/ansi-sequence-parser-1.1.0.tgz",
"integrity": "sha512-lEm8mt52to2fT8GhciPCGeCXACSz2UwIN4X2e2LJSnZ5uAbn2/dsYdOmUXq0AtWS5cpAupysIneExOgH0Vd2TQ==",
"dev": true
},
"ansi-styles": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
@@ -3321,6 +3339,12 @@
"ansi-colors": "^4.1.1"
}
},
"entities": {
"version": "4.5.0",
"resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz",
"integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==",
"dev": true
},
"env-ci": {
"version": "5.5.0",
"resolved": "https://registry.npmjs.org/env-ci/-/env-ci-5.5.0.tgz",
@@ -5905,12 +5929,6 @@
"minimist": "^1.2.0"
}
},
"jsonc-parser": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.2.0.tgz",
"integrity": "sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w==",
"dev": true
},
"jsonfile": {
"version": "6.1.0",
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz",
@@ -5985,6 +6003,15 @@
"integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==",
"dev": true
},
"linkify-it": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-5.0.0.tgz",
"integrity": "sha512-5aHCbzQRADcdP+ATqnDuhhJ/MRIqDkZX5pyjFHRRysS8vZ5AbqGEoFIb6pYHPZ+L/OC2Lc+xT8uHVVR5CAK/wQ==",
"dev": true,
"requires": {
"uc.micro": "^2.0.0"
}
},
"load-json-file": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-4.0.0.tgz",
@@ -6158,6 +6185,28 @@
"integrity": "sha512-hdN1wVrZbb29eBGiGjJbeP8JbKjq1urkHJ/LIP/NY48MZ1QVXUsQBV1G1zvYFHn1XE06cwjBsOI2K3Ulnj1YXQ==",
"dev": true
},
"markdown-it": {
"version": "14.1.0",
"resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-14.1.0.tgz",
"integrity": "sha512-a54IwgWPaeBCAAsv13YgmALOF1elABB08FxO9i+r4VFk5Vl4pKokRPeX8u5TCgSsPi6ec1otfLjdOpVcgbpshg==",
"dev": true,
"requires": {
"argparse": "^2.0.1",
"entities": "^4.4.0",
"linkify-it": "^5.0.0",
"mdurl": "^2.0.0",
"punycode.js": "^2.3.1",
"uc.micro": "^2.1.0"
},
"dependencies": {
"argparse": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
"integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==",
"dev": true
}
}
},
"marked": {
"version": "4.2.12",
"resolved": "https://registry.npmjs.org/marked/-/marked-4.2.12.tgz",
@@ -6201,6 +6250,12 @@
}
}
},
"mdurl": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/mdurl/-/mdurl-2.0.0.tgz",
"integrity": "sha512-Lf+9+2r+Tdp5wXDXC4PcIBjTDtq4UKjCPMQhKIuzpJNW0b96kVqSwW0bT7FhRSfmAiFYgP+SCRvdrDozfh0U5w==",
"dev": true
},
"media-typer": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
@@ -8755,6 +8810,12 @@
"integrity": "sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA==",
"dev": true
},
"punycode.js": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/punycode.js/-/punycode.js-2.3.1.tgz",
"integrity": "sha512-uxFIHU0YlHYhDQtV4R9J6a52SLx28BCjT+4ieh7IGbgwVJWO+km431c4yRlREUAsAmt/uMjQUyQHNEPf0M39CA==",
"dev": true
},
"pure-rand": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/pure-rand/-/pure-rand-6.0.1.tgz",
@@ -9427,15 +9488,13 @@
"dev": true
},
"shiki": {
"version": "0.14.1",
"resolved": "https://registry.npmjs.org/shiki/-/shiki-0.14.1.tgz",
"integrity": "sha512-+Jz4nBkCBe0mEDqo1eKRcCdjRtrCjozmcbTUjbPTX7OOJfEbTZzlUWlZtGe3Gb5oV1/jnojhG//YZc3rs9zSEw==",
"version": "1.13.0",
"resolved": "https://registry.npmjs.org/shiki/-/shiki-1.13.0.tgz",
"integrity": "sha512-e0dWfnONbEv6xl7FJy3XIhsVHQ/65XHDZl92+6H9+4xWjfdo7pmkqG7Kg47KWtDiEtzM5Z+oEfb4vtRvoZ/X9w==",
"dev": true,
"requires": {
"ansi-sequence-parser": "^1.1.0",
"jsonc-parser": "^3.2.0",
"vscode-oniguruma": "^1.7.0",
"vscode-textmate": "^8.0.0"
"@shikijs/core": "1.13.0",
"@types/hast": "^3.0.4"
}
},
"side-channel": {
@@ -10225,15 +10284,16 @@
}
},
"typedoc": {
"version": "0.23.27",
"resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.23.27.tgz",
"integrity": "sha512-YKjlxX3LEhYbMCkemjlpNh1OKDiFa+ynqP0VRPsH28bEugrMTGI6l8DC6oX5kzFcUKKlYWKpZDSGWszuO/FR3g==",
"version": "0.26.5",
"resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.26.5.tgz",
"integrity": "sha512-Vn9YKdjKtDZqSk+by7beZ+xzkkr8T8CYoiasqyt4TTRFy5+UHzL/mF/o4wGBjRF+rlWQHDb0t6xCpA3JNL5phg==",
"dev": true,
"requires": {
"lunr": "^2.3.9",
"marked": "^4.2.12",
"minimatch": "^7.1.3",
"shiki": "^0.14.1"
"markdown-it": "^14.1.0",
"minimatch": "^9.0.5",
"shiki": "^1.9.1",
"yaml": "^2.4.5"
},
"dependencies": {
"brace-expansion": {
@@ -10246,22 +10306,40 @@
}
},
"minimatch": {
"version": "7.4.2",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-7.4.2.tgz",
"integrity": "sha512-xy4q7wou3vUoC9k1xGTXc+awNdGaGVHtFUaey8tiX4H1QRc04DZ/rmDFwNm2EBsuYEhAZ6SgMmYf3InGY6OauA==",
"version": "9.0.5",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz",
"integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==",
"dev": true,
"requires": {
"brace-expansion": "^2.0.1"
}
},
"yaml": {
"version": "2.5.0",
"resolved": "https://registry.npmjs.org/yaml/-/yaml-2.5.0.tgz",
"integrity": "sha512-2wWLbGbYDiSqqIKoPjar3MPgB94ErzCtrNE1FdqGuaO0pi2JGjmE8aW8TDZwzU7vuxcGRdL/4gPQwQ7hD5AMSw==",
"dev": true
}
}
},
"typedoc-plugin-missing-exports": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/typedoc-plugin-missing-exports/-/typedoc-plugin-missing-exports-3.0.0.tgz",
"integrity": "sha512-R7D8fYrK34mBFZSlF1EqJxfqiUSlQSmyrCiQgTQD52nNm6+kUtqwiaqaNkuJ2rA2wBgWFecUA8JzHT7x2r7ePg==",
"dev": true
},
"typescript": {
"version": "4.9.5",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz",
"integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==",
"dev": true
},
"uc.micro": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-2.1.0.tgz",
"integrity": "sha512-ARDJmphmdvUk6Glw7y9DQ2bFkKBHwQHLi2lsaH6PPmz/Ka9sFOBsBluozhDltWmnv9u/cF6Rt87znRTPV+yp/A==",
"dev": true
},
"uglify-js": {
"version": "3.17.4",
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.17.4.tgz",
@@ -10438,18 +10516,6 @@
}
}
},
"vscode-oniguruma": {
"version": "1.7.0",
"resolved": "https://registry.npmjs.org/vscode-oniguruma/-/vscode-oniguruma-1.7.0.tgz",
"integrity": "sha512-L9WMGRfrjOhgHSdOYgCt/yRMsXzLDJSL7BPrOZt73gU0iWO4mpqzqQzOz5srxqTvMBaR0XZTSrVWo4j55Rc6cA==",
"dev": true
},
"vscode-textmate": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/vscode-textmate/-/vscode-textmate-8.0.0.tgz",
"integrity": "sha512-AFbieoL7a5LMqcnOF04ji+rpXadgOXnZsxQr//r83kLPr7biP7am3g9zbaZIaBGwBRWeSvoMD4mgPdX3e4NWBg==",
"dev": true
},
"w3c-hr-time": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/w3c-hr-time/-/w3c-hr-time-1.0.2.tgz",
+3 -2
View File
@@ -70,9 +70,9 @@
"@semantic-release/release-notes-generator": "^10.0.3",
"@types/benchmark": "^1.0.31",
"@types/express": "^4.17.2",
"@types/node": "^22.3.0",
"@types/jest": "^29.4.0",
"@types/jsdom": "^12.2.2",
"@types/node": "^22.3.0",
"@types/sinon": "^10.0.13",
"@types/supertest": "^2.0.7",
"@typescript-eslint/eslint-plugin": "^5.6.0",
@@ -103,7 +103,8 @@
"supertest": "^3.4.2",
"ts-jest": "^29.0.5",
"tslib": "^2.3.1",
"typedoc": "^0.23.26",
"typedoc": "^0.26.5",
"typedoc-plugin-missing-exports": "^3.0.0",
"typescript": "^4.5.3"
},
"dependencies": {
+8 -8
View File
@@ -25,19 +25,19 @@ describe('DoS related', function () {
})
describe('#renderLimit', () => {
it('should throw when rendering too many templates', async () => {
const src = '{% for i in (1..5) %}{{i}},{% endfor %}'
const src = '{% for i in (1..1000) %}{{i}},{% endfor %}'
const noLimit = new Liquid()
const limit10 = new Liquid({ renderLimit: 0.01 })
const limit20 = new Liquid({ renderLimit: 1000 })
await expect(noLimit.parseAndRender(src)).resolves.toBe('1,2,3,4,5,')
await expect(limit10.parseAndRender(src)).rejects.toThrow('template render limit exceeded')
await expect(limit20.parseAndRender(src)).resolves.toBe('1,2,3,4,5,')
const limitSmall = new Liquid({ renderLimit: 0.01 })
const limitLarge = new Liquid({ renderLimit: 2e4 })
await expect(noLimit.parseAndRender(src)).resolves.toMatch(/^1,2,3,4,5,.*,999,1000,$/)
await expect(limitSmall.parseAndRender(src)).rejects.toThrow('template render limit exceeded')
await expect(limitLarge.parseAndRender(src)).resolves.toMatch(/^1,2,3,4,5,.*,999,1000,$/)
})
it('should support reset when calling render', async () => {
const src = '{% for i in (1..5) %}{{i}},{% endfor %}'
const src = '{% for i in (1..1000) %}{{i}},{% endfor %}'
const liquid = new Liquid({ renderLimit: 0.01 })
await expect(liquid.parseAndRender(src)).rejects.toThrow('template render limit exceeded')
await expect(liquid.parseAndRender(src, {}, { renderLimit: 1e6 })).resolves.toBe('1,2,3,4,5,')
await expect(liquid.parseAndRender(src, {}, { renderLimit: 1e6 })).resolves.toMatch(/^1,2,3,4,5,.*,999,1000,$/)
})
it('should take partials into account', async () => {
mock({