soliddgen 0.6.0-beta.36

Sign up to get free protection for your applications and to get access to all the features.
Files changed (165) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +42 -0
  3. package/dist/common/helpers.d.ts +9 -0
  4. package/dist/common/helpers.d.ts.map +1 -0
  5. package/dist/common/helpers.js +25 -0
  6. package/dist/common/helpers.js.map +1 -0
  7. package/dist/common/properties.d.ts +25 -0
  8. package/dist/common/properties.d.ts.map +1 -0
  9. package/dist/common/properties.js +129 -0
  10. package/dist/common/properties.js.map +1 -0
  11. package/dist/config.d.ts +59 -0
  12. package/dist/config.d.ts.map +1 -0
  13. package/dist/config.js +14 -0
  14. package/dist/config.js.map +1 -0
  15. package/dist/doc-item.d.ts +6 -0
  16. package/dist/doc-item.d.ts.map +1 -0
  17. package/dist/doc-item.js +21 -0
  18. package/dist/doc-item.js.map +1 -0
  19. package/dist/hardhat/index.d.ts +2 -0
  20. package/dist/hardhat/index.d.ts.map +1 -0
  21. package/dist/hardhat/index.js +50 -0
  22. package/dist/hardhat/index.js.map +1 -0
  23. package/dist/hardhat/type-extensions.d.ts +12 -0
  24. package/dist/hardhat/type-extensions.d.ts.map +1 -0
  25. package/dist/hardhat/type-extensions.js +5 -0
  26. package/dist/hardhat/type-extensions.js.map +1 -0
  27. package/dist/index.d.ts +5 -0
  28. package/dist/index.d.ts.map +1 -0
  29. package/dist/index.js +15 -0
  30. package/dist/index.js.map +1 -0
  31. package/dist/main.d.ts +9 -0
  32. package/dist/main.d.ts.map +1 -0
  33. package/dist/main.js +30 -0
  34. package/dist/main.js.map +1 -0
  35. package/dist/render.d.ts +9 -0
  36. package/dist/render.d.ts.map +1 -0
  37. package/dist/render.js +66 -0
  38. package/dist/render.js.map +1 -0
  39. package/dist/render.test.d.ts +2 -0
  40. package/dist/render.test.d.ts.map +1 -0
  41. package/dist/render.test.js +42 -0
  42. package/dist/render.test.js.map +1 -0
  43. package/dist/site.d.ts +42 -0
  44. package/dist/site.d.ts.map +1 -0
  45. package/dist/site.js +86 -0
  46. package/dist/site.js.map +1 -0
  47. package/dist/site.test.d.ts +2 -0
  48. package/dist/site.test.d.ts.map +1 -0
  49. package/dist/site.test.js +52 -0
  50. package/dist/site.test.js.map +1 -0
  51. package/dist/templates.d.ts +23 -0
  52. package/dist/templates.d.ts.map +1 -0
  53. package/dist/templates.js +124 -0
  54. package/dist/templates.js.map +1 -0
  55. package/dist/themes/markdown/helpers.d.ts +21 -0
  56. package/dist/themes/markdown/helpers.d.ts.map +1 -0
  57. package/dist/themes/markdown/helpers.js +49 -0
  58. package/dist/themes/markdown/helpers.js.map +1 -0
  59. package/dist/utils/ItemError.d.ts +5 -0
  60. package/dist/utils/ItemError.d.ts.map +1 -0
  61. package/dist/utils/ItemError.js +18 -0
  62. package/dist/utils/ItemError.js.map +1 -0
  63. package/dist/utils/arrays-equal.d.ts +3 -0
  64. package/dist/utils/arrays-equal.d.ts.map +1 -0
  65. package/dist/utils/arrays-equal.js +8 -0
  66. package/dist/utils/arrays-equal.js.map +1 -0
  67. package/dist/utils/assert-equal-types.d.ts +2 -0
  68. package/dist/utils/assert-equal-types.d.ts.map +1 -0
  69. package/dist/utils/assert-equal-types.js +3 -0
  70. package/dist/utils/assert-equal-types.js.map +1 -0
  71. package/dist/utils/clone.d.ts +7 -0
  72. package/dist/utils/clone.d.ts.map +1 -0
  73. package/dist/utils/clone.js +11 -0
  74. package/dist/utils/clone.js.map +1 -0
  75. package/dist/utils/ensure-array.d.ts +4 -0
  76. package/dist/utils/ensure-array.d.ts.map +1 -0
  77. package/dist/utils/ensure-array.js +13 -0
  78. package/dist/utils/ensure-array.js.map +1 -0
  79. package/dist/utils/execall.d.ts +7 -0
  80. package/dist/utils/execall.d.ts.map +1 -0
  81. package/dist/utils/execall.js +21 -0
  82. package/dist/utils/execall.js.map +1 -0
  83. package/dist/utils/fs-exists.d.ts +4 -0
  84. package/dist/utils/fs-exists.d.ts.map +1 -0
  85. package/dist/utils/fs-exists.js +31 -0
  86. package/dist/utils/fs-exists.js.map +1 -0
  87. package/dist/utils/is-child.d.ts +2 -0
  88. package/dist/utils/is-child.d.ts.map +1 -0
  89. package/dist/utils/is-child.js +12 -0
  90. package/dist/utils/is-child.js.map +1 -0
  91. package/dist/utils/item-type.d.ts +3 -0
  92. package/dist/utils/item-type.d.ts.map +1 -0
  93. package/dist/utils/item-type.js +10 -0
  94. package/dist/utils/item-type.js.map +1 -0
  95. package/dist/utils/map-keys.d.ts +2 -0
  96. package/dist/utils/map-keys.d.ts.map +1 -0
  97. package/dist/utils/map-keys.js +8 -0
  98. package/dist/utils/map-keys.js.map +1 -0
  99. package/dist/utils/map-values.d.ts +4 -0
  100. package/dist/utils/map-values.d.ts.map +1 -0
  101. package/dist/utils/map-values.js +22 -0
  102. package/dist/utils/map-values.js.map +1 -0
  103. package/dist/utils/memoized-getter.d.ts +4 -0
  104. package/dist/utils/memoized-getter.d.ts.map +1 -0
  105. package/dist/utils/memoized-getter.js +25 -0
  106. package/dist/utils/memoized-getter.js.map +1 -0
  107. package/dist/utils/natspec.d.ts +19 -0
  108. package/dist/utils/natspec.d.ts.map +1 -0
  109. package/dist/utils/natspec.js +117 -0
  110. package/dist/utils/natspec.js.map +1 -0
  111. package/dist/utils/read-item-docs.d.ts +3 -0
  112. package/dist/utils/read-item-docs.d.ts.map +1 -0
  113. package/dist/utils/read-item-docs.js +29 -0
  114. package/dist/utils/read-item-docs.js.map +1 -0
  115. package/dist/utils/scope.d.ts +6 -0
  116. package/dist/utils/scope.d.ts.map +1 -0
  117. package/dist/utils/scope.js +53 -0
  118. package/dist/utils/scope.js.map +1 -0
  119. package/dist/utils/test.d.ts +8 -0
  120. package/dist/utils/test.d.ts.map +1 -0
  121. package/dist/utils/test.js +14 -0
  122. package/dist/utils/test.js.map +1 -0
  123. package/lc3cxy2s.cjs +1 -0
  124. package/package.json +41 -0
  125. package/src/common/helpers.ts +22 -0
  126. package/src/common/properties.ts +138 -0
  127. package/src/config.ts +84 -0
  128. package/src/doc-item.ts +27 -0
  129. package/src/hardhat/index.ts +35 -0
  130. package/src/hardhat/type-extensions.ts +14 -0
  131. package/src/index.ts +13 -0
  132. package/src/main.ts +26 -0
  133. package/src/render.test.ts +64 -0
  134. package/src/render.ts +87 -0
  135. package/src/site.test.ts +68 -0
  136. package/src/site.ts +144 -0
  137. package/src/templates.ts +116 -0
  138. package/src/themes/markdown/common.hbs +34 -0
  139. package/src/themes/markdown/contract.hbs +8 -0
  140. package/src/themes/markdown/enum.hbs +9 -0
  141. package/src/themes/markdown/error.hbs +1 -0
  142. package/src/themes/markdown/event.hbs +1 -0
  143. package/src/themes/markdown/function.hbs +1 -0
  144. package/src/themes/markdown/helpers.ts +49 -0
  145. package/src/themes/markdown/modifier.hbs +1 -0
  146. package/src/themes/markdown/page.hbs +8 -0
  147. package/src/themes/markdown/struct.hbs +9 -0
  148. package/src/themes/markdown/user-defined-value-type.hbs +1 -0
  149. package/src/themes/markdown/variable.hbs +1 -0
  150. package/src/utils/ItemError.ts +13 -0
  151. package/src/utils/arrays-equal.ts +5 -0
  152. package/src/utils/assert-equal-types.ts +1 -0
  153. package/src/utils/clone.ts +6 -0
  154. package/src/utils/ensure-array.ts +12 -0
  155. package/src/utils/execall.ts +18 -0
  156. package/src/utils/fs-exists.ts +23 -0
  157. package/src/utils/is-child.ts +5 -0
  158. package/src/utils/item-type.ts +7 -0
  159. package/src/utils/map-keys.ts +4 -0
  160. package/src/utils/map-values.ts +19 -0
  161. package/src/utils/memoized-getter.ts +23 -0
  162. package/src/utils/natspec.ts +145 -0
  163. package/src/utils/read-item-docs.ts +26 -0
  164. package/src/utils/scope.ts +63 -0
  165. package/src/utils/test.ts +18 -0
package/dist/render.js ADDED
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.itemPartialName = exports.render = void 0;
7
+ const handlebars_1 = __importDefault(require("handlebars"));
8
+ const item_type_1 = require("./utils/item-type");
9
+ const fs_1 = __importDefault(require("fs"));
10
+ function render(site, templates, collapseNewlines) {
11
+ const renderPage = buildRenderer(templates);
12
+ const renderedPages = [];
13
+ for (const page of site.pages) {
14
+ let contents = renderPage(page, { data: { site } });
15
+ if (collapseNewlines) {
16
+ contents = contents.replace(/\n{3,}/g, '\n\n');
17
+ }
18
+ renderedPages.push({
19
+ id: page.id,
20
+ contents,
21
+ });
22
+ }
23
+ return renderedPages;
24
+ }
25
+ exports.render = render;
26
+ const itemPartialName = (item) => (0, item_type_1.itemType)(item).replace(/ /g, '-').toLowerCase();
27
+ exports.itemPartialName = itemPartialName;
28
+ function itemPartial(item, options) {
29
+ if (!item.__item_context) {
30
+ throw new Error(`Partial 'item' used in unsupported context (not a doc item)`);
31
+ }
32
+ const partial = options?.partials?.[(0, exports.itemPartialName)(item)];
33
+ if (!partial) {
34
+ throw new Error(`Missing partial '${(0, exports.itemPartialName)(item)}'`);
35
+ }
36
+ return partial(item, options);
37
+ }
38
+ function readmeHelper(H, path, opts) {
39
+ const items = opts.data.root.items;
40
+ const renderedItems = Object.fromEntries(items.map(item => [
41
+ item.name,
42
+ new H.SafeString(H.compile('{{>item}}')(item, opts)),
43
+ ]));
44
+ return new H.SafeString(H.compile(fs_1.default.readFileSync(path, 'utf8'))(renderedItems, opts));
45
+ }
46
+ function buildRenderer(templates) {
47
+ const pageTemplate = templates.partials?.page;
48
+ if (pageTemplate === undefined) {
49
+ throw new Error(`Missing 'page' template`);
50
+ }
51
+ const H = handlebars_1.default.create();
52
+ for (const [name, getBody] of Object.entries(templates.partials ?? {})) {
53
+ let partial;
54
+ H.registerPartial(name, (...args) => {
55
+ partial ?? (partial = H.compile(getBody()));
56
+ return partial(...args);
57
+ });
58
+ }
59
+ H.registerHelper('readme', (path, opts) => readmeHelper(H, path, opts));
60
+ for (const [name, fn] of Object.entries(templates.helpers ?? {})) {
61
+ H.registerHelper(name, fn);
62
+ }
63
+ H.registerPartial('item', itemPartial);
64
+ return H.compile('{{>page}}');
65
+ }
66
+ //# sourceMappingURL=render.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render.js","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":";;;;;;AAAA,4DAAwD;AAGxD,iDAA6C;AAC7C,4CAAoB;AAapB,SAAgB,MAAM,CAAC,IAAU,EAAE,SAAoB,EAAE,gBAA0B;IACjF,MAAM,UAAU,GAAG,aAAa,CAAC,SAAS,CAAC,CAAC;IAC5C,MAAM,aAAa,GAAmB,EAAE,CAAC;IACzC,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE;QAC7B,IAAI,QAAQ,GAAG,UAAU,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;QACpD,IAAI,gBAAgB,EAAE;YACpB,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;SAChD;QACD,aAAa,CAAC,IAAI,CAAC;YACjB,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,QAAQ;SACT,CAAC,CAAC;KACJ;IACD,OAAO,aAAa,CAAC;AACvB,CAAC;AAdD,wBAcC;AAEM,MAAM,eAAe,GAAG,CAAC,IAAwB,EAAE,EAAE,CAAC,IAAA,oBAAQ,EAAC,IAAI,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC;AAAhG,QAAA,eAAe,mBAAiF;AAE7G,SAAS,WAAW,CAAC,IAAwB,EAAE,OAAwB;IACrE,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE;QACxB,MAAM,IAAI,KAAK,CAAC,6DAA6D,CAAC,CAAC;KAChF;IACD,MAAM,OAAO,GAAG,OAAO,EAAE,QAAQ,EAAE,CAAC,IAAA,uBAAe,EAAC,IAAI,CAAC,CAAC,CAAC;IAC3D,IAAI,CAAC,OAAO,EAAE;QACZ,MAAM,I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,EAAC;YACjC,OAAO,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC;QAC1B,CAAC,CAAC,CAAC;KACJ;IAED,CAAC,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC,IAAY,EAAE,IAAoB,EAAE,EAAE,CAAC,YAAY,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;IAEhG,KAAK,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,OAAO,IAAI,EAAE,CAAC,EAAE;QAChE,CAAC,CAAC,cAAc,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;KAC5B;IAED,CAAC,CAAC,eAAe,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAEvC,OAAO,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;AAChC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=render.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render.test.d.ts","sourceRoot":"","sources":["../src/render.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const test_1 = __importDefault(require("./utils/test"));
7
+ const path_1 = __importDefault(require("path"));
8
+ const site_1 = require("./site");
9
+ const render_1 = require("./render");
10
+ /**
11
+ * @param contracts The name of the Solidity file whose contents should be considered.
12
+ */
13
+ function testRender(title, file, spec, expected) {
14
+ const id = 'index.md';
15
+ const cfg = {
16
+ sourcesDir: 'test-contracts',
17
+ exclude: [],
18
+ pageExtension: '.md',
19
+ pages: (_, f) => path_1.default.parse(f.absolutePath).name === file ? id : undefined,
20
+ };
21
+ (0, test_1.default)(title, t => {
22
+ const site = (0, site_1.buildSite)(t.context.build, cfg);
23
+ const rendered = (0, render_1.render)(site, spec, spec.collapseNewlines);
24
+ t.is(rendered.length, 1);
25
+ t.is(rendered[0].contents, expected);
26
+ });
27
+ }
28
+ testRender('static page', 'S08_AB', { partials: { page: () => 'a page' } }, 'a page');
29
+ testRender('items', 'S08_AB', { partials: { page: () => '{{#each items}}{{name}}, {{/each}}' } }, 'A, B, ');
30
+ testRender('partials', 'S08_AB', {
31
+ partials: {
32
+ page: () => '{{#each items}}{{>part}}, {{/each}}',
33
+ part: () => '{{name}}',
34
+ },
35
+ }, 'A, B, ');
36
+ testRender('item partial', 'S08_AB', {
37
+ partials: {
38
+ page: () => '{{#each items}}{{>item}}, {{/each}}',
39
+ contract: () => '{{name}}',
40
+ },
41
+ }, 'A, B, ');
42
+ //# sourceMappingURL=render.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render.test.js","sourceRoot":"","sources":["../src/render.test.ts"],"names":[],"mappings":";;;;;AAAA,wDAAgC;AAChC,gDAAwB;AACxB,iCAA8D;AAC9D,qCAAmD;AAQnD;;GAEG;AACH,SAAS,UAAU,CAAC,KAAa,EAAE,IAAY,EAAE,IAAc,EAAE,QAAgB;IAC/E,MAAM,EAAE,GAAG,UAAU,CAAC;IACtB,MAAM,GAAG,GAAe;QACtB,UAAU,EAAE,gBAAgB;QAC5B,OAAO,EAAE,EAAE;QACX,aAAa,EAAE,KAAK;QACpB,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,cAAI,CAAC,KAAK,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS;KAC3E,CAAC;IAEF,IAAA,cAAI,EAAC,KAAK,EAAE,CAAC,CAAC,EAAE;QACd,MAAM,IAAI,GAAG,IAAA,gBAAS,EAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAC7C,MAAM,QAAQ,GAAG,IAAA,eAAM,EAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC;QAC3D,CAAC,CAAC,EAAE,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QACzB,CAAC,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;AACL,CAAC;AAED,UAAU,CAAC,aAAa,EACtB,QAAQ,EACR,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,QAAQ,EAAE,EAAE,EACtC,QAAQ,CACT,CAAC;AAEF,UAAU,CAAC,OAAO,EAChB,QAAQ,EACR,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,oCAAoC,EAAE,EAAE,EAClE,QAAQ,CACT,CAAC;AAEF,UAAU,CAAC,UAAU,EACnB,QAAQ,EACR;IACE,QAAQ,EAAE;QACR,IAAI,EAAE,GAAG,EAAE,CAAC,qCAAqC;QACjD,IAAI,EAAE,GAAG,EAAE,CAAC,UAAU;KACvB;CACF,EACD,QAAQ,CACT,CAAC;AAEF,UAAU,CAAC,cAAc,EACvB,QAAQ,EACR;IACE,QAAQ,EAAE;QACR,IAAI,EAAE,GAAG,EAAE,CAAC,qCAAqC;QACjD,QAAQ,EAAE,GAAG,EAAE,CAAC,UAAU;KAC3B;CACF,EACD,QAAQ,CACT,CAAC"}
package/dist/site.d.ts ADDED
@@ -0,0 +1,42 @@
1
+ import { ContractDefinition, SourceUnit } from 'solidity-ast';
2
+ import { SolcOutput, SolcInput } from 'solidity-ast/solc';
3
+ import { ASTDereferencer, SrcDecoder } from 'solidity-ast/utils';
4
+ import { FullConfig } from './config';
5
+ import { DocItem } from './doc-item';
6
+ import { Properties } from './templates';
7
+ export interface Build {
8
+ input: SolcInput;
9
+ output: SolcOutput;
10
+ }
11
+ export interface BuildContext extends Build {
12
+ deref: ASTDereferencer;
13
+ decodeSrc: SrcDecoder;
14
+ }
15
+ export type SiteConfig = Pick<FullConfig, 'pages' | 'exclude' | 'sourcesDir' | 'pageExtension'>;
16
+ export type PageStructure = SiteConfig['pages'];
17
+ export type PageAssigner = ((item: DocItem, file: SourceUnit, config: SiteConfig) => string | undefined);
18
+ export declare const pageAssigner: Record<PageStructure & string, PageAssigner>;
19
+ export interface Site {
20
+ items: DocItemWithContext[];
21
+ pages: Page[];
22
+ }
23
+ export interface Page {
24
+ id: string;
25
+ items: DocItemWithContext[];
26
+ }
27
+ export declare const DOC_ITEM_CONTEXT: "__item_context";
28
+ export type DocItemWithContext = DocItem & {
29
+ [DOC_ITEM_CONTEXT]: DocItemContext;
30
+ };
31
+ export interface DocItemContext {
32
+ page?: string;
33
+ item: DocItemWithContext;
34
+ contract?: ContractDefinition;
35
+ file: DocItemContextFile;
36
+ build: BuildContext;
37
+ }
38
+ export interface DocItemContextFile extends SourceUnit {
39
+ relativePath: string;
40
+ }
41
+ export declare function buildSite(builds: Build[], siteConfig: SiteConfig, properties?: Properties): Site;
42
+ //# sourceMappingURL=site.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"site.d.ts","sourceRoot":"","sources":["../src/site.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAmB,eAAe,EAAmC,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACnH,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,OAAO,EAA2B,MAAM,YAAY,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAMzC,MAAM,WAAW,KAAK;IACpB,KAAK,EAAE,SAAS,CAAC;IACjB,MAAM,EAAE,UAAU,CAAC;CACpB;AAED,MAAM,WAAW,YAAa,SAAQ,KAAK;IAC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86 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.buildSite = exports.DOC_ITEM_CONTEXT = exports.pageAssigner = void 0;
7
+ const path_1 = __importDefault(require("path"));
8
+ const utils_1 = require("solidity-ast/utils");
9
+ const doc_item_1 = require("./doc-item");
10
+ const clone_1 = require("./utils/clone");
11
+ const is_child_1 = require("./utils/is-child");
12
+ const memoized_getter_1 = require("./utils/memoized-getter");
13
+ exports.pageAssigner = {
14
+ single: (_1, _2, { pageExtension: ext }) => 'index' + ext,
15
+ items: (item, _, { pageExtension: ext }) => item.name + ext,
16
+ files: (_, file, { pageExtension: ext, sourcesDir }) => path_1.default.relative(sourcesDir, file.absolutePath).replace('.sol', ext),
17
+ };
18
+ exports.DOC_ITEM_CONTEXT = '__item_context';
19
+ function buildSite(builds, siteConfig, properties = {}) {
20
+ const assign = typeof siteConfig.pages === 'string' ? exports.pageAssigner[siteConfig.pages] : siteConfig.pages;
21
+ const seen = new Set();
22
+ const items = [];
23
+ const pages = {};
24
+ for (let { input, output } of builds) {
25
+ // Clone because we will mutate in order to add item context.
26
+ output = { ...output, sources: (0, clone_1.clone)(output.sources) };
27
+ const deref = (0, utils_1.astDereferencer)(output);
28
+ const decodeSrc = (0, utils_1.srcDecoder)(input, output);
29
+ const build = { input, output, deref, decodeSrc };
30
+ for (const { ast } of Object.values(output.sources)) {
31
+ const isNewFile = !seen.has(ast.absolutePath);
32
+ seen.add(ast.absolutePath);
33
+ const relativePath = path_1.default.relative(siteConfig.sourcesDir, ast.absolutePath);
34
+ const file = Object.assign(ast, { relativePath });
35
+ for (const topLevelItem of file.nodes) {
36
+ if (!(0, doc_item_1.isDocItem)(topLevelItem))
37
+ continue;
38
+ const page = assignIfIncludedSource(assign, topLevelItem, file, siteConfig);
39
+ const withContext = defineContext(topLevelItem, build, file, page);
40
+ defineProperties(withContext, properties);
41
+ if (isNewFile && page !== undefined) {
42
+ (pages[page] ?? (pages[page] = [])).push(withContext);
43
+ items.push(withContext);
44
+ }
45
+ if (!(0, utils_1.isNodeType)('ContractDefinition', topLevelItem)) {
46
+ continue;
47
+ }
48
+ for (const item of topLevelItem.nodes) {
49
+ if (!(0, doc_item_1.isDocItem)(item))
50
+ continue;
51
+ if (isNewFile && page !== undefined)
52
+ items.push(item);
53
+ const contract = topLevelItem.nodeType === 'ContractDefinition' ? topLevelItem : undefined;
54
+ const withContext = defineContext(item, build, file, page, contract);
55
+ defineProperties(withContext, properties);
56
+ }
57
+ }
58
+ }
59
+ }
60
+ return {
61
+ items,
62
+ pages: Object.entries(pages).map(([id, pageItems]) => ({ id, items: pageItems })),
63
+ };
64
+ }
65
+ exports.buildSite = buildSite;
66
+ function defineContext(item, build, file, page, contract) {
67
+ return Object.assign(item, {
68
+ [exports.DOC_ITEM_CONTEXT]: { build, file, contract, page, item: item },
69
+ });
70
+ }
71
+ function defineProperties(item, properties) {
72
+ for (const [prop, fn] of Object.entries(properties)) {
73
+ const original = item[prop];
74
+ (0, memoized_getter_1.defineGetterMemoized)(item, prop, () => fn(item.__item_context, original));
75
+ }
76
+ }
77
+ function assignIfIncludedSource(assign, item, file, config) {
78
+ return isFileIncluded(file.absolutePath, config)
79
+ ? assign(item, file, config)
80
+ : undefined;
81
+ }
82
+ function isFileIncluded(file, config) {
83
+ return ((0, is_child_1.isChild)(file, config.sourcesDir) &&
84
+ config.exclude.every(e => !(0, is_child_1.isChild)(file, path_1.default.join(config.sourcesDir, e))));
85
+ }
86
+ //# sourceMappingURL=site.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"site.js","sourceRoot":"","sources":["../src/site.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AAGxB,8CAAmH;AAEnH,yCAA8D;AAE9D,yCAAsC;AACtC,+CAA2C;AAE3C,6DAA+D;AAgBlD,QAAA,YAAY,GAAiD;IACxE,MAAM,EAAE,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AAC,CAAC;KAClF;AACH,CAAC;AAED,SAAS,sBAAsB,CAC7B,MAAoB,EACpB,IAAa,EACb,IAAwB,EACxB,MAAkB;IAElB,OAAO,cAAc,CAAC,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC;QAC9C,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC;QAC5B,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC;AAED,SAAS,cAAc,CAAC,IAAY,EAAE,MAAkB;IACtD,OAAO,CACL,IAAA,kBAAO,EAAC,IAAI,EAAE,MAAM,CAAC,UAAU,CAAC;QAChC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,IAAA,kBAAO,EAAC,IAAI,EAAE,cAAI,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC,CAC3E,CAAC;AACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=site.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"site.test.d.ts","sourceRoot":"","sources":["../src/site.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const test_1 = __importDefault(require("./utils/test"));
7
+ const path_1 = __importDefault(require("path"));
8
+ const site_1 = require("./site");
9
+ /**
10
+ * @param files The name of the Solidity file whose contents should be considered.
11
+ */
12
+ function testPages(title, opts, expected) {
13
+ (0, test_1.default)(title, t => {
14
+ const { files, assign, exclude = [] } = opts;
15
+ const cfg = {
16
+ sourcesDir: 'test-contracts',
17
+ exclude,
18
+ pageExtension: '.md',
19
+ pages: (i, f) => files.includes(path_1.default.parse(f.absolutePath).name) ? assign(i, f, cfg) : undefined,
20
+ };
21
+ const site = (0, site_1.buildSite)(t.context.build, cfg);
22
+ const pages = site.pages.map(p => ({
23
+ id: p.id,
24
+ items: p.items.map(i => i.name),
25
+ })).sort((a, b) => a.id.localeCompare(b.id));
26
+ t.deepEqual(pages, expected);
27
+ });
28
+ }
29
+ testPages('assign to single page', {
30
+ files: ['S08_AB'],
31
+ assign: site_1.pageAssigner.single,
32
+ }, [{ id: 'index.md', items: ['A', 'B'] }]);
33
+ testPages('assign to item pages', {
34
+ files: ['S08_AB'],
35
+ assign: site_1.pageAssigner.items,
36
+ }, [
37
+ { id: 'A.md', items: ['A'] },
38
+ { id: 'B.md', items: ['B'] },
39
+ ]);
40
+ testPages('assign to file pages', {
41
+ files: ['S08_AB', 'S08_C'],
42
+ assign: site_1.pageAssigner.files,
43
+ }, [
44
+ { id: 'S08_AB.md', items: ['A', 'B'] },
45
+ { id: 'S08_C.md', items: ['C'] },
46
+ ]);
47
+ testPages('exclude', {
48
+ files: ['S08_AB', 'S08_E0'],
49
+ exclude: ['S08_E0.sol'],
50
+ assign: site_1.pageAssigner.single,
51
+ }, [{ id: 'index.md', items: ['A', 'B'] }]);
52
+ //# sourceMappingURL=site.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"site.test.js","sourceRoot":"","sources":["../src/site.test.ts"],"names":[],"mappings":";;;;;AAAA,wDAAgC;AAChC,gDAAwB;AACxB,iCAAiF;AAOjF;;GAEG;AACH,SAAS,SAAS,CAAC,KAAa,EAAE,IAAmE,EAAE,QAAuB;IAC5H,IAAA,cAAI,EAAC,KAAK,EAAE,CAAC,CAAC,EAAE;QACd,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,GAAG,EAAE,EAAE,GAAG,IAAI,CAAC;QAC7C,MAAM,GAAG,GAAe;YACtB,UAAU,EAAE,gBAAgB;YAC5B,OAAO;YACP,aAAa,EAAE,KAAK;YACpB,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,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,CACF,CAAC;AAEF,SAAS,CAAC,sBAAsB,EAC9B;IACE,KAAK,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC1B,MAAM,EAAE,mBAAY,CAAC,KAAK;CAC3B,EACD;IACE,EAAE,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE;IACtC,EAAE,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,EAAE;CACjC,CACF,CAAC;AAEF,SAAS,CAAC,SAAS,EACjB;IACE,KAAK,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC3B,OAAO,EAAE,CAAC,YAAY,CAAC;IACvB,MAAM,EAAE,mBAAY,CAAC,MAAM;CAC5B,EACD,CAAC,EAAE,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC,CACxC,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { DocItemContext } from './site';
2
+ export type PropertyGetter = (ctx: DocItemContext, original?: unknown) => unknown;
3
+ export type Properties = Record<string, PropertyGetter>;
4
+ export interface Templates {
5
+ partials?: Record<string, () => string>;
6
+ helpers?: Record<string, (...args: unknown[]) => string>;
7
+ properties?: Record<string, PropertyGetter>;
8
+ }
9
+ /**
10
+ * Loads the templates that will be used for rendering a site based on a
11
+ * default theme and user templates.
12
+ *
13
+ * The result contains all partials, helpers, and property getters defined in
14
+ * the user templates and the default theme, where the user's take precedence
15
+ * if there is a clash. Additionally, all theme partials and helpers are
16
+ * included with the theme prefix, e.g. `markdown/contract` will be a partial.
17
+ */
18
+ export declare function loadTemplates(defaultTheme: string, root: string, userTemplatesPath?: string): Promise<Templates>;
19
+ /**
20
+ * Read templates and helpers from a directory.
21
+ */
22
+ export declare function readTemplates(partialsDir: string, helpersDir?: string): Promise<Required<Templates>>;
23
+ //# sourceMappingURL=templates.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../src/templates.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAIxC,MAAM,MAAM,cAAc,GAAG,CAAC,GAAG,EAAE,cAAc,EAAE,QAAQ,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC;AAClF,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;AAExD,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,MAAM,CAAC,CAAC;IACxC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,MAAM,CAAC,CAAC;IACzD,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;CAC7C;AAED;;;;;;;;GAQG;AACH,wBAAsB,aAAa,CAAC,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,iBAAiB,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CA0BtH;AAED;;GAEG;AACH,wBAAsB,aAAa,CAAC,WAAW,EAAE,MAAM,EAAE,UAAU,SAAc,GAAG,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAM/G"}
@@ -0,0 +1,124 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.readTemplates = exports.loadTemplates = void 0;
30
+ const path_1 = __importDefault(require("path"));
31
+ const fs_1 = __importStar(require("fs"));
32
+ const map_keys_1 = require("./utils/map-keys");
33
+ const defaultProperties = __importStar(require("./common/properties"));
34
+ /**
35
+ * Loads the templates that will be used for rendering a site based on a
36
+ * default theme and user templates.
37
+ *
38
+ * The result contains all partials, helpers, and property getters defined in
39
+ * the user templates and the default theme, where the user's take precedence
40
+ * if there is a clash. Additionally, all theme partials and helpers are
41
+ * included with the theme prefix, e.g. `markdown/contract` will be a partial.
42
+ */
43
+ async function loadTemplates(defaultTheme, root, userTemplatesPath) {
44
+ const themes = await readThemes();
45
+ // Initialize templates with the default theme.
46
+ const templates = {
47
+ partials: { ...themes[defaultTheme]?.partials },
48
+ helpers: { ...themes[defaultTheme]?.helpers },
49
+ properties: { ...defaultProperties },
50
+ };
51
+ // Overwrite default theme with user templates.
52
+ if (userTemplatesPath) {
53
+ const userTemplates = await readTemplates(path_1.default.resolve(root, userTemplatesPath));
54
+ Object.assign(templates.partials, userTemplates.partials);
55
+ Object.assign(templates.helpers, userTemplates.helpers);
56
+ Object.assign(templates.properties, userTemplates.properties);
57
+ }
58
+ // Add partials and helpers from all themes, prefixed with the theme name.
59
+ for (const [themeName, theme] of Object.entries(themes)) {
60
+ const addPrefix = (k) => `${themeName}/${k}`;
61
+ Object.assign(templates.partials, (0, map_keys_1.mapKeys)(theme.partials, addPrefix));
62
+ Object.assign(templates.helpers, (0, map_keys_1.mapKeys)(theme.helpers, addPrefix));
63
+ }
64
+ return templates;
65
+ }
66
+ exports.loadTemplates = loadTemplates;
67
+ /**
68
+ * Read templates and helpers from a directory.
69
+ */
70
+ async function readTemplates(partialsDir, helpersDir = partialsDir) {
71
+ return {
72
+ partials: await readPartials(partialsDir),
73
+ helpers: await readHelpers(helpersDir, 'helpers'),
74
+ properties: await readHelpers(helpersDir, 'properties'),
75
+ };
76
+ }
77
+ exports.readTemplates = readTemplates;
78
+ async function readPartials(dir) {
79
+ const partials = {};
80
+ for (const p of await fs_1.promises.readdir(dir)) {
81
+ const { name, ext } = path_1.default.parse(p);
82
+ if (ext === '.hbs') {
83
+ partials[name] = () => fs_1.default.readFileSync(path_1.default.join(dir, p), 'utf8');
84
+ }
85
+ }
86
+ return partials;
87
+ }
88
+ async function readHelpers(dir, name) {
89
+ var _a;
90
+ let helpersPath;
91
+ try {
92
+ helpersPath = require.resolve(path_1.default.join(dir, name));
93
+ }
94
+ catch {
95
+ return {};
96
+ }
97
+ const h = await (_a = helpersPath, Promise.resolve().then(() => __importStar(require(_a))));
98
+ const helpers = {};
99
+ for (const name in h) {
100
+ if (typeof h[name] === 'function') {
101
+ helpers[name] = h[name];
102
+ }
103
+ }
104
+ return helpers;
105
+ }
106
+ /**
107
+ * Reads all built-in themes into an object. Partials will always be found in
108
+ * src/themes, whereas helpers may instead be found in dist/themes if TypeScript
109
+ * can't be imported directly.
110
+ */
111
+ async function readThemes() {
112
+ const themes = {};
113
+ // Handlebars partials are located in src and not in dist
114
+ const srcThemes = path_1.default.resolve(__dirname, '../src/themes');
115
+ const distThemes = path_1.default.resolve(__dirname, 'themes');
116
+ for (const theme of await fs_1.promises.readdir(srcThemes, { withFileTypes: true })) {
117
+ if (theme.isDirectory()) {
118
+ const { name } = theme;
119
+ themes[name] = await readTemplates(path_1.default.join(srcThemes, name), path_1.default.join(distThemes, name));
120
+ }
121
+ }
122
+ return themes;
123
+ }
124
+ //# sourceMappingURL=templates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"templates.js","sourceRoot":"","sources":["../src/templates.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAwB;AACxB,yCAA+C;AAI/C,+CAA2C;AAG3C,uEAAyD;AAWzD;;;;;;;;GAQG;AACI,KAAK,UAAU,aAAa,CAAC,YAAoB,EAAE,IAAY,EAAE,iBAA0B;IAChG,MAAM,MAAM,GAAG,MAAM,UAAU,EAAE,CAAC;IAElC,+CAA+C;IAC/C,MAAM,SAAS,GAAwB;QACrC,QAAQ,EAAE,EAAE,GAAG,MAAM,CAAC,YAAY,CAAC,EAAE,QAAQ,EAAE;QAC/C,OAAO,EAAE,EAAE,GAAG,MAAM,CAAC,YAAY,CAAC,EAAE,OAAO,EAAE;QAC7C,UAAU,EAAE,EAAE,GAAG,iBAAiB,EAAE;KACrC,CAAC;IAEF,+CAA+C;IAC/C,IAAI,iBAAiB,EAAE;QACrB,MAAM,aAAa,GAAG,MAAM,aAAa,CAAC,cAAI,CAAC,OAAO,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC,CAAC;QACjF,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;QAC1D,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;QACxD,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,UAAU,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC;KAC/D;IAED,0EAA0E;IAC1E,KAAK,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;QACvD,MAAM,SAAS,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,GAAG,SAAS,IAAI,CAAC,EAAE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EAAE,IAAI,CAAC,CAAC,CAAC;KACrD;IAAC,MAAM;QACN,OAAO,EAAE,CAAC;KACX;IACD,MAAM,CAAC,GAAG,YAAa,WAAW,0DAAC,CAAC;IACpC,MAAM,OAAO,GAA4C,EAAE,CAAC;IAC5D,KAAK,MAAM,IAAI,IAAI,CAAC,EAAE;QACpB,IAAI,OAAO,CAAC,CAAC,IAAI,CAAC,KAAK,UAAU,EAAE;YACjC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC;SACzB;KACF;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;GAIG;AACH,KAAK,UAAU,UAAU;IACvB,MAAM,MAAM,GAAwC,EAAE,CAAC;IAEvD,yDAAyD;IACzD,MAAM,SAAS,GAAG,cAAI,CAAC,OAAO,CAAC,SAAS,EAAE,eAAe,CAAC,CAAC;IAC3D,MAAM,UAAU,GAAG,cAAI,CAAC,OAAO,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IAErD,KAAK,MAAM,KAAK,IAAI,MAAM,aAAS,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,EAAE;QAC/E,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE;YACvB,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC;YACvB,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,aAAa,CAAC,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,EAAE,cAAI,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC,CAAC;SAC7F;KACF;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { HelperOptions } from 'handlebars';
2
+ export * from '../../common/helpers';
3
+ /**
4
+ * Returns a Markdown heading marker. An optional number increases the heading level.
5
+ *
6
+ * Input Output
7
+ * {{h}} {{name}} # Name
8
+ * {{h 2}} {{name}} ## Name
9
+ */
10
+ export declare function h(opts: HelperOptions): string;
11
+ export declare function h(hsublevel: number, opts: HelperOptions): string;
12
+ /**
13
+ * Delineates a section where headings should be increased by 1 or a custom number.
14
+ *
15
+ * {{#hsection}}
16
+ * {{>partial-with-headings}}
17
+ * {{/hsection}}
18
+ */
19
+ export declare function hsection(opts: HelperOptions): string;
20
+ export declare function hsection(hsublevel: number, opts: HelperOptions): string;
21
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/themes/markdown/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAS,MAAM,YAAY,CAAC;AAElD,cAAc,sBAAsB,CAAC;AAErC;;;;;;GAMG;AACH,wBAAgB,CAAC,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,CAAC;AAC/C,wBAAgB,CAAC,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,GAAG,MAAM,CAAC;AAMlE;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,CAAC;AACtD,wBAAgB,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,GAAG,MAAM,CAAC"}
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.hsection = exports.h = void 0;
18
+ const handlebars_1 = require("handlebars");
19
+ __exportStar(require("../../common/helpers"), exports);
20
+ function h(hsublevel, opts) {
21
+ const { hlevel } = getHLevel(hsublevel, opts);
22
+ return new Array(hlevel).fill('#').join('');
23
+ }
24
+ exports.h = h;
25
+ ;
26
+ function hsection(hsublevel, opts) {
27
+ let hlevel;
28
+ ({ hlevel, opts } = getHLevel(hsublevel, opts));
29
+ opts.data = handlebars_1.Utils.createFrame(opts.data);
30
+ opts.data.hlevel = hlevel;
31
+ return opts.fn(this, opts);
32
+ }
33
+ exports.hsection = hsection;
34
+ /**
35
+ * Helper for dealing with the optional hsublevel argument.
36
+ */
37
+ function getHLevel(hsublevel, opts) {
38
+ if (typeof hsublevel === 'number') {
39
+ opts = opts;
40
+ hsublevel = Math.max(1, hsublevel);
41
+ }
42
+ else {
43
+ opts = hsublevel;
44
+ hsublevel = 1;
45
+ }
46
+ const contextHLevel = opts.data?.hlevel ?? 0;
47
+ return { opts, hlevel: contextHLevel + hsublevel };
48
+ }
49
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/themes/markdown/helpers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,2CAAkD;AAElD,uDAAqC;AAWrC,SAAgB,CAAC,CAAC,SAAiC,EAAE,IAAoB;IACvE,MAAM,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IAC9C,OAAO,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAC9C,CAAC;AAHD,cAGC;AAAA,CAAC;AAWF,SAAgB,QAAQ,CAAgB,SAAiC,EAAE,IAAoB;IAC7F,IAAI,MAAM,CAAC;IACX,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,SAAS,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC;IAChD,IAAI,CAAC,IAAI,GAAG,kBAAK,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACzC,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IAC1B,OAAO,IAAI,CAAC,EAAE,CAAC,IAAe,EAAE,IAAI,CAAC,CAAC;AACxC,CAAC;AAND,4BAMC;AAED;;GAEG;AACH,SAAS,SAAS,CAAC,SAAiC,EAAE,IAAoB;IACxE,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE;QACjC,IAAI,GAAG,IAAK,CAAC;QACb,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;KACpC;SAAM;QACL,IAAI,GAAG,SAAS,CAAC;QACjB,SAAS,GAAG,CAAC,CAAC;KACf;IACD,MAAM,aAAa,GAAW,IAAI,CAAC,IAAI,EAAE,MAAM,IAAI,CAAC,CAAC;IACrD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,aAAa,GAAG,SAAS,EAAE,CAAC;AACrD,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { DocItemWithContext } from '../site';
2
+ export declare class ItemError extends Error {
3
+ constructor(msg: string, item: DocItemWithContext);
4
+ }
5
+ //# sourceMappingURL=ItemError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ItemError.d.ts","sourceRoot":"","sources":["../../src/utils/ItemError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAoB,MAAM,SAAS,CAAC;AAE/D,qBAAa,SAAU,SAAQ,KAAK;gBACtB,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,kBAAkB;CASlD"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ItemError = void 0;
4
+ const site_1 = require("../site");
5
+ class ItemError extends Error {
6
+ constructor(msg, item) {
7
+ const ctx = item[site_1.DOC_ITEM_CONTEXT];
8
+ const src = ctx && ctx.build.decodeSrc(item);
9
+ if (src) {
10
+ super(msg + ` (${src})`);
11
+ }
12
+ else {
13
+ super(msg);
14
+ }
15
+ }
16
+ }
17
+ exports.ItemError = ItemError;
18
+ //# sourceMappingURL=ItemError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ItemError.js","sourceRoot":"","sources":["../../src/utils/ItemError.ts"],"names":[],"mappings":";;;AAAA,kCAA+D;AAE/D,MAAa,SAAU,SAAQ,KAAK;IAClC,YAAY,GAAW,EAAE,IAAwB;QAC/C,MAAM,GAAG,GAAG,IAAI,CAAC,uBAAgB,CAAC,CAAC;QACnC,MAAM,GAAG,GAAG,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QAC7C,IAAI,GAAG,EAAE;YACP,KAAK,CAAC,GAAG,GAAG,KAAK,GAAG,GAAG,CAAC,CAAC;SAC1B;aAAM;YACL,KAAK,CAAC,GAAG,CAAC,CAAC;SACZ;IACH,CAAC;CACF;AAVD,8BAUC"}
@@ -0,0 +1,3 @@
1
+ export declare function arraysEqual<T>(a: T[], b: T[]): boolean;
2
+ export declare function arraysEqual<T, U>(a: T[], b: T[], mapFn: (x: T) => U): boolean;
3
+ //# sourceMappingURL=arrays-equal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"arrays-equal.d.ts","sourceRoot":"","sources":["../../src/utils/arrays-equal.ts"],"names":[],"mappings":"AAAA,wBAAgB,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,OAAO,CAAC;AACxD,wBAAgB,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC"}
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.arraysEqual = void 0;
4
+ function arraysEqual(a, b, mapFn = (x) => x) {
5
+ return a.length === b.length && a.every((x, i) => mapFn(x) === mapFn(b[i]));
6
+ }
7
+ exports.arraysEqual = arraysEqual;
8
+ //# sourceMappingURL=arrays-equal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"arrays-equal.js","sourceRoot":"","sources":["../../src/utils/arrays-equal.ts"],"names":[],"mappings":";;;AAEA,SAAgB,WAAW,CAAI,CAAM,EAAE,CAAM,EAAE,QAAQ,CAAC,CAAI,EAAE,EAAE,CAAC,CAAC;IAChE,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAE,CAAC,CAAC,CAAC;AAC/E,CAAC;AAFD,kCAEC"}