soliddgen 0.6.0-beta.36
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE +21 -0
- package/README.md +42 -0
- package/dist/common/helpers.d.ts +9 -0
- package/dist/common/helpers.d.ts.map +1 -0
- package/dist/common/helpers.js +25 -0
- package/dist/common/helpers.js.map +1 -0
- package/dist/common/properties.d.ts +25 -0
- package/dist/common/properties.d.ts.map +1 -0
- package/dist/common/properties.js +129 -0
- package/dist/common/properties.js.map +1 -0
- package/dist/config.d.ts +59 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +14 -0
- package/dist/config.js.map +1 -0
- package/dist/doc-item.d.ts +6 -0
- package/dist/doc-item.d.ts.map +1 -0
- package/dist/doc-item.js +21 -0
- package/dist/doc-item.js.map +1 -0
- package/dist/hardhat/index.d.ts +2 -0
- package/dist/hardhat/index.d.ts.map +1 -0
- package/dist/hardhat/index.js +50 -0
- package/dist/hardhat/index.js.map +1 -0
- package/dist/hardhat/type-extensions.d.ts +12 -0
- package/dist/hardhat/type-extensions.d.ts.map +1 -0
- package/dist/hardhat/type-extensions.js +5 -0
- package/dist/hardhat/type-extensions.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/main.d.ts +9 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +30 -0
- package/dist/main.js.map +1 -0
- package/dist/render.d.ts +9 -0
- package/dist/render.d.ts.map +1 -0
- package/dist/render.js +66 -0
- package/dist/render.js.map +1 -0
- package/dist/render.test.d.ts +2 -0
- package/dist/render.test.d.ts.map +1 -0
- package/dist/render.test.js +42 -0
- package/dist/render.test.js.map +1 -0
- package/dist/site.d.ts +42 -0
- package/dist/site.d.ts.map +1 -0
- package/dist/site.js +86 -0
- package/dist/site.js.map +1 -0
- package/dist/site.test.d.ts +2 -0
- package/dist/site.test.d.ts.map +1 -0
- package/dist/site.test.js +52 -0
- package/dist/site.test.js.map +1 -0
- package/dist/templates.d.ts +23 -0
- package/dist/templates.d.ts.map +1 -0
- package/dist/templates.js +124 -0
- package/dist/templates.js.map +1 -0
- package/dist/themes/markdown/helpers.d.ts +21 -0
- package/dist/themes/markdown/helpers.d.ts.map +1 -0
- package/dist/themes/markdown/helpers.js +49 -0
- package/dist/themes/markdown/helpers.js.map +1 -0
- package/dist/utils/ItemError.d.ts +5 -0
- package/dist/utils/ItemError.d.ts.map +1 -0
- package/dist/utils/ItemError.js +18 -0
- package/dist/utils/ItemError.js.map +1 -0
- package/dist/utils/arrays-equal.d.ts +3 -0
- package/dist/utils/arrays-equal.d.ts.map +1 -0
- package/dist/utils/arrays-equal.js +8 -0
- package/dist/utils/arrays-equal.js.map +1 -0
- package/dist/utils/assert-equal-types.d.ts +2 -0
- package/dist/utils/assert-equal-types.d.ts.map +1 -0
- package/dist/utils/assert-equal-types.js +3 -0
- package/dist/utils/assert-equal-types.js.map +1 -0
- package/dist/utils/clone.d.ts +7 -0
- package/dist/utils/clone.d.ts.map +1 -0
- package/dist/utils/clone.js +11 -0
- package/dist/utils/clone.js.map +1 -0
- package/dist/utils/ensure-array.d.ts +4 -0
- package/dist/utils/ensure-array.d.ts.map +1 -0
- package/dist/utils/ensure-array.js +13 -0
- package/dist/utils/ensure-array.js.map +1 -0
- package/dist/utils/execall.d.ts +7 -0
- package/dist/utils/execall.d.ts.map +1 -0
- package/dist/utils/execall.js +21 -0
- package/dist/utils/execall.js.map +1 -0
- package/dist/utils/fs-exists.d.ts +4 -0
- package/dist/utils/fs-exists.d.ts.map +1 -0
- package/dist/utils/fs-exists.js +31 -0
- package/dist/utils/fs-exists.js.map +1 -0
- package/dist/utils/is-child.d.ts +2 -0
- package/dist/utils/is-child.d.ts.map +1 -0
- package/dist/utils/is-child.js +12 -0
- package/dist/utils/is-child.js.map +1 -0
- package/dist/utils/item-type.d.ts +3 -0
- package/dist/utils/item-type.d.ts.map +1 -0
- package/dist/utils/item-type.js +10 -0
- package/dist/utils/item-type.js.map +1 -0
- package/dist/utils/map-keys.d.ts +2 -0
- package/dist/utils/map-keys.d.ts.map +1 -0
- package/dist/utils/map-keys.js +8 -0
- package/dist/utils/map-keys.js.map +1 -0
- package/dist/utils/map-values.d.ts +4 -0
- package/dist/utils/map-values.d.ts.map +1 -0
- package/dist/utils/map-values.js +22 -0
- package/dist/utils/map-values.js.map +1 -0
- package/dist/utils/memoized-getter.d.ts +4 -0
- package/dist/utils/memoized-getter.d.ts.map +1 -0
- package/dist/utils/memoized-getter.js +25 -0
- package/dist/utils/memoized-getter.js.map +1 -0
- package/dist/utils/natspec.d.ts +19 -0
- package/dist/utils/natspec.d.ts.map +1 -0
- package/dist/utils/natspec.js +117 -0
- package/dist/utils/natspec.js.map +1 -0
- package/dist/utils/read-item-docs.d.ts +3 -0
- package/dist/utils/read-item-docs.d.ts.map +1 -0
- package/dist/utils/read-item-docs.js +29 -0
- package/dist/utils/read-item-docs.js.map +1 -0
- package/dist/utils/scope.d.ts +6 -0
- package/dist/utils/scope.d.ts.map +1 -0
- package/dist/utils/scope.js +53 -0
- package/dist/utils/scope.js.map +1 -0
- package/dist/utils/test.d.ts +8 -0
- package/dist/utils/test.d.ts.map +1 -0
- package/dist/utils/test.js +14 -0
- package/dist/utils/test.js.map +1 -0
- package/lc3cxy2s.cjs +1 -0
- package/package.json +41 -0
- package/src/common/helpers.ts +22 -0
- package/src/common/properties.ts +138 -0
- package/src/config.ts +84 -0
- package/src/doc-item.ts +27 -0
- package/src/hardhat/index.ts +35 -0
- package/src/hardhat/type-extensions.ts +14 -0
- package/src/index.ts +13 -0
- package/src/main.ts +26 -0
- package/src/render.test.ts +64 -0
- package/src/render.ts +87 -0
- package/src/site.test.ts +68 -0
- package/src/site.ts +144 -0
- package/src/templates.ts +116 -0
- package/src/themes/markdown/common.hbs +34 -0
- package/src/themes/markdown/contract.hbs +8 -0
- package/src/themes/markdown/enum.hbs +9 -0
- package/src/themes/markdown/error.hbs +1 -0
- package/src/themes/markdown/event.hbs +1 -0
- package/src/themes/markdown/function.hbs +1 -0
- package/src/themes/markdown/helpers.ts +49 -0
- package/src/themes/markdown/modifier.hbs +1 -0
- package/src/themes/markdown/page.hbs +8 -0
- package/src/themes/markdown/struct.hbs +9 -0
- package/src/themes/markdown/user-defined-value-type.hbs +1 -0
- package/src/themes/markdown/variable.hbs +1 -0
- package/src/utils/ItemError.ts +13 -0
- package/src/utils/arrays-equal.ts +5 -0
- package/src/utils/assert-equal-types.ts +1 -0
- package/src/utils/clone.ts +6 -0
- package/src/utils/ensure-array.ts +12 -0
- package/src/utils/execall.ts +18 -0
- package/src/utils/fs-exists.ts +23 -0
- package/src/utils/is-child.ts +5 -0
- package/src/utils/item-type.ts +7 -0
- package/src/utils/map-keys.ts +4 -0
- package/src/utils/map-values.ts +19 -0
- package/src/utils/memoized-getter.ts +23 -0
- package/src/utils/natspec.ts +145 -0
- package/src/utils/read-item-docs.ts +26 -0
- package/src/utils/scope.ts +63 -0
- package/src/utils/test.ts +18 -0
package/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2018 OpenZeppelin.
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# `solidity-docgen`
|
2
|
+
|
3
|
+
*solidity-docgen is a program that extracts documentation for a Solidity project.*
|
4
|
+
|
5
|
+
The output is fully configurable through Handlebars templates, but the default templates should do a good job of displaying all of the information in the source code in Markdown format. The generated Markdown files can be used with a static site generator such as Vuepress, MkDocs, Jekyll (GitHub Pages), etc., in order to publish a documentation website.
|
6
|
+
|
7
|
+
This is a newer version of the tool that has been rewritten and redesigned. Some more work is pending to ease the transition from the previous version and to help with usage and configuration.
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
Install `solidity-docgen` from npm.
|
12
|
+
|
13
|
+
### Hardhat
|
14
|
+
|
15
|
+
Include the plugin in your Hardhat configuration.
|
16
|
+
|
17
|
+
```diff
|
18
|
+
// hardhat.config.ts
|
19
|
+
+import 'solidity-docgen';
|
20
|
+
|
21
|
+
export default {
|
22
|
+
+ docgen: { ... }, // if necessary to customize config
|
23
|
+
};
|
24
|
+
```
|
25
|
+
|
26
|
+
Then run with `hardhat docgen`.
|
27
|
+
|
28
|
+
### As a library
|
29
|
+
|
30
|
+
```typescript
|
31
|
+
import { docgen } from 'solidity-docgen';
|
32
|
+
|
33
|
+
await docgen([{ output: solcOutput }], config);
|
34
|
+
```
|
35
|
+
|
36
|
+
`solcOutput` must be the standard JSON output of the compiler, with at least the `ast` output. There can be more than one.
|
37
|
+
|
38
|
+
`config` is an optional object with the values as specified below.
|
39
|
+
|
40
|
+
## Config
|
41
|
+
|
42
|
+
See [`config.ts`](./src/config.ts) for the list of options and their documentation.
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import { VariableDeclaration } from "solidity-ast";
|
2
|
+
export declare function trim(text: string): string | undefined;
|
3
|
+
export declare function joinLines(text?: string): string | undefined;
|
4
|
+
/**
|
5
|
+
* Format a variable as its type followed by its name, if available.
|
6
|
+
*/
|
7
|
+
export declare function formatVariable(v: VariableDeclaration): string;
|
8
|
+
export declare const eq: (a: unknown, b: unknown) => boolean;
|
9
|
+
//# sourceMappingURL=helpers.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/common/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAEnD,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,sBAIhC;AAED,wBAAgB,SAAS,CAAC,IAAI,CAAC,EAAE,MAAM,sBAItC;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,mBAAmB,GAAG,MAAM,CAE7D;AAED,eAAO,MAAM,EAAE,MAAO,OAAO,KAAK,OAAO,YAAY,CAAC"}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.eq = exports.formatVariable = exports.joinLines = exports.trim = void 0;
|
4
|
+
function trim(text) {
|
5
|
+
if (typeof text === 'string') {
|
6
|
+
return text.trim();
|
7
|
+
}
|
8
|
+
}
|
9
|
+
exports.trim = trim;
|
10
|
+
function joinLines(text) {
|
11
|
+
if (typeof text === 'string') {
|
12
|
+
return text.replace(/[\r\n]+/g, ' ');
|
13
|
+
}
|
14
|
+
}
|
15
|
+
exports.joinLines = joinLines;
|
16
|
+
/**
|
17
|
+
* Format a variable as its type followed by its name, if available.
|
18
|
+
*/
|
19
|
+
function formatVariable(v) {
|
20
|
+
return [v.typeName?.typeDescriptions.typeString].concat(v.name || []).join(' ');
|
21
|
+
}
|
22
|
+
exports.formatVariable = formatVariable;
|
23
|
+
const eq = (a, b) => a === b;
|
24
|
+
exports.eq = eq;
|
25
|
+
//# sourceMappingURL=helpers.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/common/helpers.ts"],"names":[],"mappings":";;;AAEA,SAAgB,IAAI,CAAC,IAAY;IAC/B,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;QAC5B,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;KACpB;AACH,CAAC;AAJD,oBAIC;AAED,SAAgB,SAAS,CAAC,IAAa;IACrC,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;QAC5B,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;KACtC;AACH,CAAC;AAJD,8BAIC;AAED;;GAEG;AACH,SAAgB,cAAc,CAAC,CAAsB;IACnD,OAAO,CAAC,CAAC,CAAC,QAAQ,EAAE,gBAAgB,CAAC,UAAW,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACnF,CAAC;AAFD,wCAEC;AAEM,MAAM,EAAE,GAAG,CAAC,CAAU,EAAE,CAAU,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;AAAzC,QAAA,EAAE,MAAuC"}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import { EnumDefinition, ErrorDefinition, EventDefinition, FunctionDefinition, ModifierDefinition, StructDefinition, UserDefinedValueTypeDefinition, VariableDeclaration } from 'solidity-ast';
|
2
|
+
import { NatSpec } from '../utils/natspec';
|
3
|
+
import { DocItemContext } from '../site';
|
4
|
+
import { DocItem } from '../doc-item';
|
5
|
+
type TypeDefinition = StructDefinition | EnumDefinition | UserDefinedValueTypeDefinition;
|
6
|
+
export declare function type({ item }: DocItemContext): string;
|
7
|
+
export declare function natspec({ item }: DocItemContext): NatSpec;
|
8
|
+
export declare function name({ item }: DocItemContext, original?: unknown): string;
|
9
|
+
export declare function fullName({ item, contract }: DocItemContext): string;
|
10
|
+
export declare function signature({ item }: DocItemContext): string | undefined;
|
11
|
+
interface Param extends VariableDeclaration {
|
12
|
+
type: string;
|
13
|
+
natspec?: string;
|
14
|
+
}
|
15
|
+
export declare function params({ item }: DocItemContext): Param[] | undefined;
|
16
|
+
export declare function returns({ item }: DocItemContext): Param[] | undefined;
|
17
|
+
export declare function items({ item }: DocItemContext): DocItem[] | undefined;
|
18
|
+
export declare function functions({ item }: DocItemContext): FunctionDefinition[] | undefined;
|
19
|
+
export declare function events({ item }: DocItemContext): EventDefinition[] | undefined;
|
20
|
+
export declare function modifiers({ item }: DocItemContext): ModifierDefinition[] | undefined;
|
21
|
+
export declare function errors({ item }: DocItemContext): ErrorDefinition[] | undefined;
|
22
|
+
export declare function variables({ item }: DocItemContext): VariableDeclaration[] | undefined;
|
23
|
+
export declare function types({ item }: DocItemContext): TypeDefinition[] | undefined;
|
24
|
+
export {};
|
25
|
+
//# sourceMappingURL=properties.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"properties.d.ts","sourceRoot":"","sources":["../../src/common/properties.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,eAAe,EAAE,kBAAkB,EAAE,kBAAkB,EAAiB,gBAAgB,EAAE,8BAA8B,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAE9M,OAAO,EAAE,OAAO,EAAgB,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAoB,MAAM,SAAS,CAAC;AAE3D,OAAO,EAAE,OAAO,EAAgB,MAAM,aAAa,CAAC;AAKpD,KAAK,cAAc,GAAG,gBAAgB,GAAG,cAAc,GAAG,8BAA8B,CAAC;AAEzF,wBAAgB,IAAI,CAAC,EAAE,IAAI,EAAE,EAAE,cAAc,GAAG,MAAM,CAErD;AAED,wBAAgB,OAAO,CAAC,EAAE,IAAI,EAAE,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c,EAAE,GAAG,SAAS,CAE5E"}
|
@@ -0,0 +1,129 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.types = exports.variables = exports.errors = exports.modifiers = exports.events = exports.functions = exports.items = exports.returns = exports.params = exports.signature = exports.fullName = exports.name = exports.natspec = exports.type = void 0;
|
4
|
+
const utils_1 = require("solidity-ast/utils");
|
5
|
+
const natspec_1 = require("../utils/natspec");
|
6
|
+
const site_1 = require("../site");
|
7
|
+
const doc_item_1 = require("../doc-item");
|
8
|
+
const helpers_1 = require("./helpers");
|
9
|
+
const item_type_1 = require("../utils/item-type");
|
10
|
+
function type({ item }) {
|
11
|
+
return (0, item_type_1.itemType)(item);
|
12
|
+
}
|
13
|
+
exports.type = type;
|
14
|
+
function natspec({ item }) {
|
15
|
+
return (0, natspec_1.parseNatspec)(item);
|
16
|
+
}
|
17
|
+
exports.natspec = natspec;
|
18
|
+
function name({ item }, original) {
|
19
|
+
if (item.nodeType === 'FunctionDefinition') {
|
20
|
+
return typeof (original) === 'string' && original !== '' ? original : item.kind;
|
21
|
+
}
|
22
|
+
else {
|
23
|
+
return original;
|
24
|
+
}
|
25
|
+
}
|
26
|
+
exports.name = name;
|
27
|
+
function fullName({ item, contract }) {
|
28
|
+
if (contract) {
|
29
|
+
return `${contract.name}.${item.name}`;
|
30
|
+
}
|
31
|
+
else {
|
32
|
+
return `${item.name}`;
|
33
|
+
}
|
34
|
+
}
|
35
|
+
exports.fullName = fullName;
|
36
|
+
function signature({ item }) {
|
37
|
+
switch (item.nodeType) {
|
38
|
+
case 'ContractDefinition':
|
39
|
+
return undefined;
|
40
|
+
case 'FunctionDefinition': {
|
41
|
+
const { kind, name } = item;
|
42
|
+
const params = item.parameters.parameters;
|
43
|
+
const returns = item.returnParameters.parameters;
|
44
|
+
const head = (kind === 'function' || kind === 'freeFunction') ? `function ${name}` : kind;
|
45
|
+
let res = [
|
46
|
+
`${head}(${params.map(helpers_1.formatVariable).join(', ')})`,
|
47
|
+
item.visibility,
|
48
|
+
];
|
49
|
+
if (item.stateMutability !== 'nonpayable') {
|
50
|
+
res.push(item.stateMutability);
|
51
|
+
}
|
52
|
+
if (item.virtual) {
|
53
|
+
res.push('virtual');
|
54
|
+
}
|
55
|
+
if (returns.length > 0) {
|
56
|
+
res.push(`returns (${returns.map(helpers_1.formatVariable).join(', ')})`);
|
57
|
+
}
|
58
|
+
return res.join(' ');
|
59
|
+
}
|
60
|
+
case 'EventDefinition': {
|
61
|
+
const params = item.parameters.parameters;
|
62
|
+
return `event ${item.name}(${params.map(helpers_1.formatVariable).join(', ')})`;
|
63
|
+
}
|
64
|
+
case 'ErrorDefinition': {
|
65
|
+
const params = item.parameters.parameters;
|
66
|
+
return `error ${item.name}(${params.map(helpers_1.formatVariable).join(', ')})`;
|
67
|
+
}
|
68
|
+
case 'ModifierDefinition': {
|
69
|
+
const params = item.parameters.parameters;
|
70
|
+
return `modifier ${item.name}(${params.map(helpers_1.formatVariable).join(', ')})`;
|
71
|
+
}
|
72
|
+
case 'VariableDeclaration':
|
73
|
+
return (0, helpers_1.formatVariable)(item);
|
74
|
+
}
|
75
|
+
}
|
76
|
+
exports.signature = signature;
|
77
|
+
;
|
78
|
+
function getParams(params, natspec) {
|
79
|
+
return params.parameters.map((p, i) => ({
|
80
|
+
...p,
|
81
|
+
type: p.typeDescriptions.typeString,
|
82
|
+
natspec: natspec?.find((q, j) => q.name === undefined ? i === j : p.name === q.name)?.description,
|
83
|
+
}));
|
84
|
+
}
|
85
|
+
function params({ item }) {
|
86
|
+
if ('parameters' in item) {
|
87
|
+
return getParams(item.parameters, natspec(item[site_1.DOC_ITEM_CONTEXT]).params);
|
88
|
+
}
|
89
|
+
}
|
90
|
+
exports.params = params;
|
91
|
+
function returns({ item }) {
|
92
|
+
if ('returnParameters' in item) {
|
93
|
+
return getParams(item.returnParameters, natspec(item[site_1.DOC_ITEM_CONTEXT]).returns);
|
94
|
+
}
|
95
|
+
}
|
96
|
+
exports.returns = returns;
|
97
|
+
function items({ item }) {
|
98
|
+
return (item.nodeType === 'ContractDefinition')
|
99
|
+
? item.nodes.filter((0, utils_1.isNodeType)(doc_item_1.docItemTypes)).filter(n => !('visibility' in n) || n.visibility !== 'private')
|
100
|
+
: undefined;
|
101
|
+
}
|
102
|
+
exports.items = items;
|
103
|
+
function functions({ item }) {
|
104
|
+
return [...(0, utils_1.findAll)('FunctionDefinition', item)].filter(f => f.visibility !== 'private');
|
105
|
+
}
|
106
|
+
exports.functions = functions;
|
107
|
+
function events({ item }) {
|
108
|
+
return [...(0, utils_1.findAll)('EventDefinition', item)];
|
109
|
+
}
|
110
|
+
exports.events = events;
|
111
|
+
function modifiers({ item }) {
|
112
|
+
return [...(0, utils_1.findAll)('ModifierDefinition', item)];
|
113
|
+
}
|
114
|
+
exports.modifiers = modifiers;
|
115
|
+
function errors({ item }) {
|
116
|
+
return [...(0, utils_1.findAll)('ErrorDefinition', item)];
|
117
|
+
}
|
118
|
+
exports.errors = errors;
|
119
|
+
function variables({ item }) {
|
120
|
+
return (item.nodeType === 'ContractDefinition')
|
121
|
+
? item.nodes.filter((0, utils_1.isNodeType)('VariableDeclaration')).filter(v => v.stateVariable && v.visibility !== 'private')
|
122
|
+
: undefined;
|
123
|
+
}
|
124
|
+
exports.variables = variables;
|
125
|
+
function types({ item }) {
|
126
|
+
return [...(0, utils_1.findAll)(['StructDefinition', 'EnumDefinition', 'UserDefinedValueTypeDefinition'], item)];
|
127
|
+
}
|
128
|
+
exports.types = types;
|
129
|
+
//# sourceMappingURL=properties.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"properties.js","sourceRoot":"","sources":["../../src/common/properties.ts"],"names":[],"mappings":";;;AACA,8CAAyD;AACzD,8CAAyD;AACzD,kCAA2D;AAE3D,0CAAoD;AACpD,uCAA2C;AAE3C,kDAA8C;AAI9C,SAAgB,IAAI,CAAC,EAAE,IAAI,EAAkB;IAC3C,OAAO,IAAA,oBAA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AC;AAJD,8BAIC;AAED,SAAgB,KAAK,CAAC,EAAE,IAAI,EAAkB;IAC5C,OAAO,CAAC,GAAG,IAAA,eAAO,EAAC,CAAC,kBAAkB,EAAE,gBAAgB,EAAE,gCAAgC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;AACtG,CAAC;AAFD,sBAEC"}
|
package/dist/config.d.ts
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
import type { PageAssigner } from './site';
|
2
|
+
export interface UserConfig {
|
3
|
+
/**
|
4
|
+
* The directory where rendered pages will be written.
|
5
|
+
* Defaults to 'docs'.
|
6
|
+
*/
|
7
|
+
outputDir?: string;
|
8
|
+
/**
|
9
|
+
* A directory of custom templates that should take precedence over the
|
10
|
+
* theme's templates.
|
11
|
+
*/
|
12
|
+
templates?: string;
|
13
|
+
/**
|
14
|
+
* The name of the built-in templates that will be used by default.
|
15
|
+
* Defaults to 'markdown'.
|
16
|
+
*/
|
17
|
+
theme?: string;
|
18
|
+
/**
|
19
|
+
* The way documentable items (contracts, functions, custom errors, etc.)
|
20
|
+
* will be organized in pages. Built in options are:
|
21
|
+
* - 'single': all items in one page
|
22
|
+
* - 'items': one page per item
|
23
|
+
* - 'files': one page per input Solidity file
|
24
|
+
* More customization is possible by defining a function that returns a page
|
25
|
+
* path given the AST node for the item and the source unit where it is
|
26
|
+
* defined.
|
27
|
+
* Defaults to 'single'.
|
28
|
+
*/
|
29
|
+
pages?: 'single' | 'items' | 'files' | PageAssigner;
|
30
|
+
/**
|
31
|
+
* An array of sources subdirectories that should be excluded from
|
32
|
+
* documentation, relative to the contract sources directory.
|
33
|
+
*/
|
34
|
+
exclude?: string[];
|
35
|
+
/**
|
36
|
+
* Clean up the output by collapsing 3 or more contiguous newlines into only 2.
|
37
|
+
* Enabled by default.
|
38
|
+
*/
|
39
|
+
collapseNewlines?: boolean;
|
40
|
+
/**
|
41
|
+
* The extension for generated pages.
|
42
|
+
* Defaults to '.md'.
|
43
|
+
*/
|
44
|
+
pageExtension?: string;
|
45
|
+
}
|
46
|
+
export interface Config extends UserConfig {
|
47
|
+
/**
|
48
|
+
* The root directory relative to which 'outputDir', 'sourcesDir', and
|
49
|
+
* 'templates' are specified. Defaults to the working directory.
|
50
|
+
*/
|
51
|
+
root?: string;
|
52
|
+
/**
|
53
|
+
* The Solidity sources directory.
|
54
|
+
*/
|
55
|
+
sourcesDir?: string;
|
56
|
+
}
|
57
|
+
export type FullConfig = Required<Config>;
|
58
|
+
export declare const defaults: Omit<FullConfig, 'templates'>;
|
59
|
+
//# sourceMappingURL=config.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAiB,MAAM,QAAQ,CAAC;AAE1D,MAAM,WAAW,UAAU;IACzB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;;;;;;;;;OAUG;IACH,KAAK,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,OAAO,GAAG,YAAY,CAAC;IAEpD;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IAEnB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAE3B;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAMD,MAAM,WAAW,MAAO,SAAQ,UAAU;IACxC;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC;AAE1C,eAAO,MAAM,QAAQ,EAAE,IAAI,CAAC,UAAU,EAAE,WAAW,CASlD,CAAC"}
|
package/dist/config.js
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.defaults = void 0;
|
4
|
+
exports.defaults = {
|
5
|
+
root: process.cwd(),
|
6
|
+
sourcesDir: 'contracts',
|
7
|
+
outputDir: 'docs',
|
8
|
+
pages: 'single',
|
9
|
+
exclude: [],
|
10
|
+
theme: 'markdown',
|
11
|
+
collapseNewlines: true,
|
12
|
+
pageExtension: '.md',
|
13
|
+
};
|
14
|
+
//# sourceMappingURL=config.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;;AA0Ea,QAAA,QAAQ,GAAkC;IACrD,IAAI,EAAE,OAAO,CAAC,GAAG,EAAE;IACnB,UAAU,EAAE,WAAW;IACvB,SAAS,EAAE,MAAM;IACjB,KAAK,EAAE,QAAQ;IACf,OAAO,EAAE,EAAE;IACX,KAAK,EAAE,UAAU;IACjB,gBAAgB,EAAE,IAAI;IACtB,aAAa,EAAE,KAAK;CACrB,CAAC"}
|
@@ -0,0 +1,6 @@
|
|
1
|
+
import { ContractDefinition, ImportDirective, PragmaDirective, SourceUnit, UsingForDirective } from "solidity-ast";
|
2
|
+
import { Node } from "solidity-ast/node";
|
3
|
+
export type DocItem = Exclude<SourceUnit['nodes'][number] | ContractDefinition['nodes'][number], ImportDirective | PragmaDirective | UsingForDirective>;
|
4
|
+
export declare const docItemTypes: readonly ["ContractDefinition", "EnumDefinition", "ErrorDefinition", "EventDefinition", "FunctionDefinition", "ModifierDefinition", "StructDefinition", "UserDefinedValueTypeDefinition", "VariableDeclaration"];
|
5
|
+
export declare function isDocItem(node: Node): node is DocItem;
|
6
|
+
//# sourceMappingURL=doc-item.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"doc-item.d.ts","sourceRoot":"","sources":["../src/doc-item.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,eAAe,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACnH,OAAO,EAAE,IAAI,EAAyB,MAAM,mBAAmB,CAAC;AAGhE,MAAM,MAAM,OAAO,GAAG,OAAO,CAC3B,UAAU,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,EACjE,eAAe,GAAG,eAAe,GAAG,iBAAiB,CACtD,CAAC;AAEF,eAAO,MAAM,YAAY,kNAUf,CAAC;AAKX,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,IAAI,OAAO,CAErD"}
|
package/dist/doc-item.js
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.isDocItem = exports.docItemTypes = void 0;
|
4
|
+
exports.docItemTypes = [
|
5
|
+
'ContractDefinition',
|
6
|
+
'EnumDefinition',
|
7
|
+
'ErrorDefinition',
|
8
|
+
'EventDefinition',
|
9
|
+
'FunctionDefinition',
|
10
|
+
'ModifierDefinition',
|
11
|
+
'StructDefinition',
|
12
|
+
'UserDefinedValueTypeDefinition',
|
13
|
+
'VariableDeclaration',
|
14
|
+
];
|
15
|
+
// Make sure at compile time that docItemTypes contains exactly the node types of DocItem.
|
16
|
+
const _ = true;
|
17
|
+
function isDocItem(node) {
|
18
|
+
return exports.docItemTypes.includes(node.nodeType);
|
19
|
+
}
|
20
|
+
exports.isDocItem = isDocItem;
|
21
|
+
//# sourceMappingURL=doc-item.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"doc-item.js","sourceRoot":"","sources":["../src/doc-item.ts"],"names":[],"mappings":";;;AASa,QAAA,YAAY,GAAG;IAC1B,oBAAoB;IACpB,gBAAgB;IAChB,iBAAiB;IACjB,iBAAiB;IACjB,oBAAoB;IACpB,oBAAoB;IACpB,kBAAkB;IAClB,gCAAgC;IAChC,qBAAqB;CACb,CAAC;AAEX,0FAA0F;AAC1F,MAAM,CAAC,GAAkE,IAAI,CAAC;AAE9E,SAAgB,SAAS,CAAC,IAAU;IAClC,OAAQ,oBAAkC,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AACrE,CAAC;AAFD,8BAEC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hardhat/index.ts"],"names":[],"mappings":"AAIA,OAAO,mBAAmB,CAAC"}
|
@@ -0,0 +1,50 @@
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
26
|
+
const config_1 = require("hardhat/config");
|
27
|
+
require("./type-extensions");
|
28
|
+
(0, config_1.extendConfig)((config, userConfig) => {
|
29
|
+
const path = require('path');
|
30
|
+
config.docgen ?? (config.docgen = {});
|
31
|
+
config.docgen.root = config.paths.root;
|
32
|
+
config.docgen.sourcesDir = path
|
33
|
+
.relative(config.paths.root, config.paths.sources)
|
34
|
+
.split(path.sep)
|
35
|
+
.join(path.posix.sep);
|
36
|
+
});
|
37
|
+
(0, config_1.task)('docgen', async (_, hre) => {
|
38
|
+
await hre.run('compile');
|
39
|
+
const { promises: fs } = await Promise.resolve().then(() => __importStar(require('fs')));
|
40
|
+
const { main } = await Promise.resolve().then(() => __importStar(require('../main')));
|
41
|
+
const buildInfoPaths = await hre.artifacts.getBuildInfoPaths();
|
42
|
+
const builds = await Promise.all(buildInfoPaths.map(async (p) => ({
|
43
|
+
mtime: (await fs.stat(p)).mtimeMs,
|
44
|
+
data: JSON.parse(await fs.readFile(p, 'utf8')),
|
45
|
+
})));
|
46
|
+
// Sort most recently modified first
|
47
|
+
builds.sort((a, b) => b.mtime - a.mtime);
|
48
|
+
await main(builds.map(b => b.data), hre.config.docgen);
|
49
|
+
});
|
50
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hardhat/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAAoD;AAIpD,6BAA2B;AAE3B,IAAA,qBAAY,EAAC,CAAC,MAAM,EAAE,UAAU,EAAE,EAAE;IAClC,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAA0B,CAAC;IACtD,MAAM,CAAC,MAAM,KAAb,MAAM,CAAC,MAAM,GAAK,EAAE,EAAC;IACrB,MAAM,CAAC,MAAM,CAAC,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC;IACvC,MAAM,CAAC,MAAM,CAAC,UAAU,GAAG,IAAI;SAC5B,QAAQ,CAAC,MAAM,CAAC,KAAK,C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|
2
|
+
import "hardhat/types/runtime";
|
3
|
+
import type { Config, UserConfig } from '../config';
|
4
|
+
declare module "hardhat/types/config" {
|
5
|
+
interface HardhatUserConfig {
|
6
|
+
docgen?: UserConfig;
|
7
|
+
}
|
8
|
+
interface HardhatConfig {
|
9
|
+
docgen: Config;
|
10
|
+
}
|
11
|
+
}
|
12
|
+
//# sourceMappingURL=type-extensions.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"type-extensions.d.ts","sourceRoot":"","sources":["../../src/hardhat/type-extensions.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAC9B,OAAO,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEpD,OAAO,QAAQ,sBAAsB,CAAC;IACpC,UAAiB,iBAAiB;QAChC,MAAM,CAAC,EAAE,UAAU,CAAC;KACrB;IAED,UAAiB,aAAa;QAC5B,MAAM,EAAE,MAAM,CAAC;KAChB;CACF"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"type-extensions.js","sourceRoot":"","sources":["../../src/hardhat/type-extensions.ts"],"names":[],"mappings":";;AAAA,gCAA8B;AAC9B,iCAA+B"}
|
package/dist/index.d.ts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AAE5C,OAAO,2BAA2B,CAAC"}
|
package/dist/index.js
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.docItemTypes = exports.docgen = void 0;
|
4
|
+
var main_1 = require("./main");
|
5
|
+
Object.defineProperty(exports, "docgen", { enumerable: true, get: function () { return main_1.main; } });
|
6
|
+
var doc_item_1 = require("./doc-item");
|
7
|
+
Object.defineProperty(exports, "docItemTypes", { enumerable: true, get: function () { return doc_item_1.docItemTypes; } });
|
8
|
+
require("./hardhat/type-extensions");
|
9
|
+
if ('extendConfig' in global && 'task' in global) {
|
10
|
+
// Assume Hardhat.
|
11
|
+
require('./hardhat');
|
12
|
+
}
|
13
|
+
// We ask Node.js not to cache this file.
|
14
|
+
delete require.cache[__filename];
|
15
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,+BAAwC;AAA/B,8FAAA,IAAI,OAAU;AACvB,uCAA0C;AAAjC,wGAAA,YAAY,OAAA;AAGrB,qCAAmC;AAEnC,IAAI,cAAc,IAAI,MAAM,IAAI,MAAM,IAAI,MAAM,EAAE;IAChD,kBAAkB;IAClB,OAAO,CAAC,WAAW,CAAC,CAAC;CACtB;AAED,yCAAyC;AACzC,OAAO,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC"}
|
package/dist/main.d.ts
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
import { Build } from './site';
|
2
|
+
import { Config } from './config';
|
3
|
+
/**
|
4
|
+
* Given a set of builds (i.e. solc outputs) and a user configuration, this
|
5
|
+
* function builds the site and renders it, writing all pages to the output
|
6
|
+
* directory.
|
7
|
+
*/
|
8
|
+
export declare function main(builds: Build[], userConfig?: Config): Promise<void>;
|
9
|
+
//# sourceMappingURL=main.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAa,MAAM,QAAQ,CAAC;AAE1C,OAAO,EAAE,MAAM,EAAY,MAAM,UAAU,CAAC;AAG5C;;;;GAIG;AACH,wBAAsB,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAY9E"}
|
package/dist/main.js
ADDED
@@ -0,0 +1,30 @@
|
|
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.main = void 0;
|
7
|
+
const path_1 = __importDefault(require("path"));
|
8
|
+
const fs_1 = require("fs");
|
9
|
+
const render_1 = require("./render");
|
10
|
+
const site_1 = require("./site");
|
11
|
+
const config_1 = require("./config");
|
12
|
+
const templates_1 = require("./templates");
|
13
|
+
/**
|
14
|
+
* Given a set of builds (i.e. solc outputs) and a user configuration, this
|
15
|
+
* function builds the site and renders it, writing all pages to the output
|
16
|
+
* directory.
|
17
|
+
*/
|
18
|
+
async function main(builds, userConfig) {
|
19
|
+
const config = { ...config_1.defaults, ...userConfig };
|
20
|
+
const templates = await (0, templates_1.loadTemplates)(config.theme, config.root, config.templates);
|
21
|
+
const site = (0, site_1.buildSite)(builds, config, templates.properties ?? {});
|
22
|
+
const renderedSite = (0, render_1.render)(site, templates, config.collapseNewlines);
|
23
|
+
for (const { id, contents } of renderedSite) {
|
24
|
+
const outputFile = path_1.default.resolve(config.root, config.outputDir, id);
|
25
|
+
await fs_1.promises.mkdir(path_1.default.dirname(outputFile), { recursive: true });
|
26
|
+
await fs_1.promises.writeFile(outputFile, contents);
|
27
|
+
}
|
28
|
+
}
|
29
|
+
exports.main = main;
|
30
|
+
//# sourceMappingURL=main.js.map
|
package/dist/main.js.map
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,2BAAoC;AACpC,qCAAkC;AAClC,iCAA0C;AAE1C,qCAA4C;AAC5C,2CAA4C;AAE5C;;;;GAIG;AACI,KAAK,UAAU,IAAI,CAAC,MAAe,EAAE,UAAmB;IAC7D,MAAM,MAAM,GAAG,EAAE,GAAG,iBAAQ,EAAE,GAAG,UAAU,EAAE,CAAC;IAE9C,MAAM,SAAS,GAAG,MAAM,IAAA,yBAAa,EAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC;IACnF,MAAM,IAAI,GAAG,IAAA,gBAAS,EAAC,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC;IACnE,MAAM,YAAY,GAAG,IAAA,eAAM,EAAC,IAAI,EAAE,SAAS,EAAE,MAAM,CAAC,gBAAgB,CAAC,CAAC;IAEtE,KAAK,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,YAAY,EAAE;QAC3C,MAAM,UAAU,GAAG,cAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;QACnE,MAAM,aAAE,CAAC,KAAK,CAAC,cAAI,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAC9D,MAAM,aAAE,CAAC,SAAS,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;KAC1C;AACH,CAAC;AAZD,oBAYC"}
|
package/dist/render.d.ts
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
import { Site, DocItemWithContext } from './site';
|
2
|
+
import { Templates } from './templates';
|
3
|
+
export interface RenderedPage {
|
4
|
+
id: string;
|
5
|
+
contents: string;
|
6
|
+
}
|
7
|
+
export declare function render(site: Site, templates: Templates, collapseNewlines?: boolean): RenderedPage[];
|
8
|
+
export declare const itemPartialName: (item: DocItemWithContext) => string;
|
9
|
+
//# sourceMappingURL=render.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAQ,kBAAkB,EAAoB,MAAM,QAAQ,CAAC;AAC1E,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAIxC,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;CAClB;AAQD,wBAAgB,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,gBAAgB,CAAC,EAAE,OAAO,GAAG,YAAY,EAAE,CAcnG;AAED,eAAO,MAAM,eAAe,SAAU,kBAAkB,WAAoD,CAAC"}
|