Skip to content

Commit 4c8b258

Browse files
committed
initial docgen commit
1 parent 42e542f commit 4c8b258

File tree

8 files changed

+32895
-6697
lines changed

8 files changed

+32895
-6697
lines changed

.editorconfig

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,8 @@ indent_size = 4
88
insert_final_newline = true
99
trim_trailing_whitespace = true
1010

11-
[*.yml]
12-
charset = utf-8
13-
indent_style = space
14-
indent_size = 2
15-
insert_final_newline = true
16-
trim_trailing_whitespace = true
17-
18-
[*.yaml]
19-
charset = utf-8
20-
indent_style = space
11+
[*.{json,yml,xml,yaml}]
2112
indent_size = 2
22-
insert_final_newline = true
23-
trim_trailing_whitespace = true
2413

2514
[*.md]
2615
max_line_length = off

.gitbook.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
root: ./docgen/docs
2+
3+
​structure:
4+
readme: README.md

docgen/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# 1inch limit order protocol
2+
3+
https://github.com/1inch/limit-order-protocol

docgen/contract.hbs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# {{{name}}}
2+
3+
{{{title}}}
4+
{{{natspec.userdoc}}}
5+
{{{natspec.devdoc}}}
6+
7+
{{#if ownFunctions}}
8+
## Functions
9+
{{/if}}
10+
11+
{{#ownFunctions}}
12+
### `{{name}}({{args}}){{#if outputs}}{{outputs}}{{/if}}`
13+
{{#if natspec.devdoc}}{{natspec.devdoc}}{{else}}{{#if natspec.userdoc}}{{natspec.userdoc}}{{else}}No description{{/if}}{{/if}}
14+
15+
{{#if natspec.params}}
16+
#### Parameters:
17+
{{#natspec.params}}
18+
- `{{param}}`: {{description}}
19+
{{/natspec.params}}
20+
{{/if}}
21+
{{#if natspec.returns}}
22+
#### Return Values:
23+
{{#natspec.returns}}
24+
- {{param}} {{description}}
25+
{{/natspec.returns}}
26+
{{/if}}
27+
28+
{{/ownFunctions}}
29+
30+
31+
{{#if ownEvents}}
32+
## Events
33+
{{/if}}
34+
35+
{{#ownEvents}}
36+
### `{{name}}({{args}})`
37+
{{#if natspec.devdoc}}{{natspec.devdoc}}{{else}}No description{{/if}}
38+
39+
{{#if natspec.params}}
40+
#### Parameters:
41+
{{#natspec.params}}
42+
- `{{param}}`: {{description}}
43+
{{/natspec.params}}
44+
{{/if}}
45+
{{/ownEvents}}

docify.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
const INPUT_DIR = "contracts";
2+
const BASE_DIR = "docgen";
3+
const OUTPUT_DIR = "docgen/docs";
4+
const SOLC_NPM_NAME = "solc";
5+
6+
const fs = require("fs");
7+
const path = require("path");
8+
const spawn = require('cross-spawn')
9+
10+
function runProcess(name, args) {
11+
console.log(`running ${name} with args ${JSON.stringify(args)}`);
12+
const result = spawn.sync(name, args, {stdio: ["inherit", "inherit", "pipe"]});
13+
if (result.stderr.length > 0)
14+
throw new Error(result.stderr);
15+
}
16+
17+
function generateGitbookFiles() {
18+
fs.copyFileSync(path.join(BASE_DIR, "README.md"), path.join(OUTPUT_DIR, "README.md"))
19+
}
20+
21+
const solidityDocgenArgs = [
22+
"solidity-docgen",
23+
"-i",
24+
INPUT_DIR,
25+
"-o",
26+
OUTPUT_DIR,
27+
"--solc-module",
28+
SOLC_NPM_NAME,
29+
"--solc-settings",
30+
JSON.stringify({optimizer: {enabled: false}}),
31+
"--templates",
32+
BASE_DIR
33+
];
34+
35+
runProcess("npx", solidityDocgenArgs);
36+
generateGitbookFiles();

0 commit comments

Comments
 (0)