Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AsciiDoc documentation and CI/CD workflow #95

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Setup

runs:
using: composite
steps:
- uses: actions/setup-node@v3
with:
node-version: 14.x
- uses: actions/cache@v3
id: cache
with:
path: '**/node_modules'
key: npm-v3-${{ hashFiles('**/package-lock.json') }}
- name: Install dependencies
run: npm ci
shell: bash
if: steps.cache.outputs.cache-hit != 'true'
env:
SKIP_COMPILE: true
19 changes: 19 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Build Docs

on:
push:
branches: [release-v*]

permissions:
contents: write

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up environment
uses: ./.github/actions/setup
- run: bash scripts/git-user-config.sh
- run: node scripts/update-docs-branch.js
- run: git push --all origin
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ tmp/
.vscode/launch.json

etherisc*.tgz

#hardhat
/cache
/artifacts
8 changes: 8 additions & 0 deletions contracts/flows/README.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
= Flows

[.readme-notice]
NOTE: This document is better viewed at https://docs.etherisc.com/contracts/api/flows

== Contracts

{{PolicyDefaultFlow}}
25 changes: 25 additions & 0 deletions contracts/modules/README.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
= Modules

[.readme-notice]
NOTE: This document is better viewed at https://docs.etherisc.com/contracts/api/modules

== Contracts

{{AccessController}}

{{BundleController}}

{{ComponentController}}

{{LicenseController}}

{{PolicyController}}

{{PoolController}}

{{QueryModule}}

{{RegistryController}}

{{TreasuryModule}}

18 changes: 18 additions & 0 deletions contracts/services/README.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
= Services

[.readme-notice]
NOTE: This document is better viewed at https://docs.etherisc.com/contracts/api/services

== Contracts

{{ComponentOwnerService}}

{{InstanceOperatorService}}

{{InstanceService}}

{{OracleService}}

{{ProductService}}

{{RiskpoolService}}
14 changes: 14 additions & 0 deletions contracts/shared/README.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
= Shared

[.readme-notice]
NOTE: This document is better viewed at https://docs.etherisc.com/contracts/api/shared

== Contracts

{{CoreController}}

{{CoreProxy}}

{{TransferHelper}}

{{WithRegistry}}
24 changes: 24 additions & 0 deletions contracts/test/README.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
= Test

[.readme-notice]
NOTE: This document is better viewed at https://docs.etherisc.com/contracts/api/test

== Contracts

{{TestCoin}}

{{TestCoinAlternativeImplementation}}

{{TestCompromisedProduct}}

{{TestOracle}}

{{TestProduct}}

{{TestRegistryCompromisedController}}

{{TestRegistryControllerUpdated}}

{{TestRiskpool}}

{{TestTransferFrom}}
10 changes: 10 additions & 0 deletions contracts/tokens/README.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
= Tokens

[.readme-notice]
NOTE: This document is better viewed at https://docs.etherisc.com/contracts/api/tokens

== Contracts

{{BundleToken}}

{{RiskpoolToken}}
6 changes: 6 additions & 0 deletions docs/antora.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
name: contracts
title: Contracts
version: 2.x
nav:
- modules/ROOT/nav.adoc
- modules/api/nav.adoc
22 changes: 22 additions & 0 deletions docs/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const path = require('path');
const fs = require('fs');

/** @type import('solidity-docgen/dist/config').UserConfig */
module.exports = {
outputDir: 'docs/modules/api/pages',
templates: 'docs/templates',
exclude: ['mocks'],
pageExtension: '.adoc',
pages: (_, file, config) => {
// For each contract file, find the closest README.adoc and return its location as the output page path.
const sourcesDir = path.resolve(config.root, config.sourcesDir);
let dir = path.resolve(config.root, file.absolutePath);
while (dir.startsWith(sourcesDir)) {
dir = path.dirname(dir);
if (fs.existsSync(path.join(dir, 'README.adoc'))) {
const result = path.relative(sourcesDir, dir) + config.pageExtension;
return result;
}
}
},
};
21 changes: 21 additions & 0 deletions docs/modules/ROOT/nav.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
* xref:index.adoc[Overview]
////
* xref:extending-contracts.adoc[Extending Contracts]
* xref:upgradeable.adoc[Using with Upgrades]

* xref:releases-stability.adoc[Releases & Stability]

* xref:access-control.adoc[Access Control]

* xref:tokens.adoc[Tokens]
** xref:erc20.adoc[ERC20]
*** xref:erc20-supply.adoc[Creating Supply]
** xref:erc721.adoc[ERC721]
** xref:erc777.adoc[ERC777]
** xref:erc1155.adoc[ERC1155]

* xref:gsn.adoc[Gas Station Network]
** xref:gsn-strategies.adoc[Strategies]

* xref:utilities.adoc[Utilities]
////
73 changes: 73 additions & 0 deletions docs/modules/ROOT/pages/index.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
= GIF Contracts

*Secure and audited smart contracts to develop decentralized insurance applications.*

* GIF Contracts is a library of smart contracts for decentralized insurance applications.



== Overview

[[install]]
=== Installation

```console
$ npm install @etherisc/gif-contracts
```

Etherisc GIF Contracts features a xref:releases-stability.adoc#api-stability[stable API], which means your contracts won't break unexpectedly when upgrading to a newer minor version.

[[usage]]
=== Usage

Once installed, you can use the contracts in the library by importing them:

[source,solidity]
----
// contracts/MyProduct.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.2;

import "@etherisc/gif-interface/contracts/components/Product.sol";

contract MyProduct is Product {

bytes32 public constant POLICY_FLOW = "PolicyDefaultFlow";

constructor(
bytes32 productName,
address token,
address registry,
uint256 riskpoolId,
)
Product(productName, token, POLICY_FLOW, riskpoolId, registry)
{
}
}
----

TIP: If you're new to smart contract development, head to ...
// TODO: Add resource here
to learn about creating a new project and compiling your contracts.

To keep your system secure, you should **always** use the installed code as-is, and neither copy-paste it from online sources, nor modify it yourself. The library is designed so that only the contracts and functions you use are deployed, so you don't need to worry about it needlessly increasing gas costs.

[[next-steps]]
== Learn More

The guides in the sidebar will teach about different concepts, and how to use the related contracts that GIF Contracts provides:

////
* xref:access-control.adoc[Access Control]: decide who can perform each of the actions on your system.
* xref:tokens.adoc[Tokens]: create tradable assets or collectibles, like the well known xref:erc20.adoc[ERC20] and xref:erc721.adoc[ERC721] standards.
* xref:gsn.adoc[Gas Station Network]: let your users interact with your contracts without having to pay for gas themselves.
* xref:utilities.adoc[Utilities]: generic useful tools, including non-overflowing math, signature verification, and trustless paying systems.

The xref:api:token/ERC20.adoc[full API] is also thoroughly documented, and serves as a great reference when developing your smart contract application. You can also ask for help or follow Contracts' development in the https://forum.openzeppelin.com[community forum].

Finally, you may want to take a look at the https://blog.openzeppelin.com/guides/[guides on our blog], which cover several common use cases and good practices.. The following articles provide great background reading, though please note, some of the referenced tools have changed as the tooling in the ecosystem continues to rapidly evolve.

* https://blog.openzeppelin.com/the-hitchhikers-guide-to-smart-contracts-in-ethereum-848f08001f05[The Hitchhiker’s Guide to Smart Contracts in Ethereum] will help you get an overview of the various tools available for smart contract development, and help you set up your environment.
* https://blog.openzeppelin.com/a-gentle-introduction-to-ethereum-programming-part-1-783cc7796094[A Gentle Introduction to Ethereum Programming, Part 1] provides very useful information on an introductory level, including many basic concepts from the Ethereum platform.
* For a more in-depth dive, you may read the guide https://blog.openzeppelin.com/designing-the-architecture-for-your-ethereum-application-9cec086f8317[Designing the architecture for your Ethereum application], which discusses how to better structure your application and its relationship to the real world.
////
7 changes: 7 additions & 0 deletions docs/modules/api/nav.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.API
* xref:flows.adoc[Flows]
* xref:modules.adoc[Modules]
* xref:services.adoc[Services]
* xref:shared.adoc[Shared]
* xref:test.adoc[Test]
* xref:tokens.adoc[Tokens]
Loading