Skip to content

Commit

Permalink
initial docgen commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Pzixel committed Jun 7, 2021
1 parent 42e542f commit 4c8b258
Show file tree
Hide file tree
Showing 8 changed files with 32,895 additions and 6,697 deletions.
13 changes: 1 addition & 12 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,8 @@ indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true

[*.yml]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

[*.yaml]
charset = utf-8
indent_style = space
[*.{json,yml,xml,yaml}]
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
max_line_length = off
Expand Down
4 changes: 4 additions & 0 deletions .gitbook.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
root: ./docgen/docs

​structure:
readme: README.md
3 changes: 3 additions & 0 deletions docgen/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# 1inch limit order protocol

https://github.com/1inch/limit-order-protocol
45 changes: 45 additions & 0 deletions docgen/contract.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# {{{name}}}

{{{title}}}
{{{natspec.userdoc}}}
{{{natspec.devdoc}}}

{{#if ownFunctions}}
## Functions
{{/if}}

{{#ownFunctions}}
### `{{name}}({{args}}){{#if outputs}}{{outputs}}{{/if}}`
{{#if natspec.devdoc}}{{natspec.devdoc}}{{else}}{{#if natspec.userdoc}}{{natspec.userdoc}}{{else}}No description{{/if}}{{/if}}

{{#if natspec.params}}
#### Parameters:
{{#natspec.params}}
- `{{param}}`: {{description}}
{{/natspec.params}}
{{/if}}
{{#if natspec.returns}}
#### Return Values:
{{#natspec.returns}}
- {{param}} {{description}}
{{/natspec.returns}}
{{/if}}

{{/ownFunctions}}


{{#if ownEvents}}
## Events
{{/if}}

{{#ownEvents}}
### `{{name}}({{args}})`
{{#if natspec.devdoc}}{{natspec.devdoc}}{{else}}No description{{/if}}

{{#if natspec.params}}
#### Parameters:
{{#natspec.params}}
- `{{param}}`: {{description}}
{{/natspec.params}}
{{/if}}
{{/ownEvents}}
36 changes: 36 additions & 0 deletions docify.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const INPUT_DIR = "contracts";
const BASE_DIR = "docgen";
const OUTPUT_DIR = "docgen/docs";
const SOLC_NPM_NAME = "solc";

const fs = require("fs");
const path = require("path");
const spawn = require('cross-spawn')

function runProcess(name, args) {
console.log(`running ${name} with args ${JSON.stringify(args)}`);
const result = spawn.sync(name, args, {stdio: ["inherit", "inherit", "pipe"]});
if (result.stderr.length > 0)
throw new Error(result.stderr);
}

function generateGitbookFiles() {
fs.copyFileSync(path.join(BASE_DIR, "README.md"), path.join(OUTPUT_DIR, "README.md"))
}

const solidityDocgenArgs = [
"solidity-docgen",
"-i",
INPUT_DIR,
"-o",
OUTPUT_DIR,
"--solc-module",
SOLC_NPM_NAME,
"--solc-settings",
JSON.stringify({optimizer: {enabled: false}}),
"--templates",
BASE_DIR
];

runProcess("npx", solidityDocgenArgs);
generateGitbookFiles();
Loading

0 comments on commit 4c8b258

Please sign in to comment.