Skip to content

Commit

Permalink
Merge PR cosmos#4787: Updated docs build process
Browse files Browse the repository at this point in the history
  • Loading branch information
mircea-c authored and alexanderbez committed Aug 26, 2019
1 parent d3aa9fe commit 450c8ce
Show file tree
Hide file tree
Showing 92 changed files with 17,880 additions and 144 deletions.
29 changes: 29 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,17 @@ commands:
make << parameters.target >>
jobs:
build_docs:
executor: docs
steps:
- checkout
- run:
Name : "Build docs"
command: make build-docs
- run:
name: "Upload docs to S3"
command: make sync-docs

setup_dependencies:
executor: golang
steps:
Expand Down Expand Up @@ -199,3 +210,21 @@ workflows:
- upload_coverage:
requires:
- test_cover
- build_docs:
context: docs-deployment-master
filters:
branches:
only:
- /.*/
tags:
ignore:
- /^v.*/
- build_docs:
context: docs-deployment-release
filters:
branches:
ignore:
- /.*/
tags:
only:
- /v.*/
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ tools/bin/*
examples/build/*
docs/_build
docs/tutorial
docs/node_modules
dist
tools-stamp

Expand Down
17 changes: 17 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,23 @@ godocs:
@echo "--> Wait a few seconds and visit http://localhost:6060/pkg/github.com/cosmos/cosmos-sdk/types"
godoc -http=:6060

build-docs:
@cd docs && \
while read p; do \
(git checkout $${p} && npm install && VUEPRESS_BASE="/$${p}/" npm run build) ; \
mkdir -p ~/output/$${p} ; \
cp -r .vuepress/dist/* ~/output/$${p}/ ; \
echo "<a href='$${p}'>$${p}</a>" >> ~/output/index.html ; \
done < versions ;

sync-docs:
cd ~/output && \
echo "role_arn = ${DEPLOYMENT_ROLE_ARN}" >> /root/.aws/config ; \
echo "CI job = ${CIRCLE_BUILD_URL}" >> version.html ; \
aws s3 sync . s3://${WEBSITE_BUCKET} --profile terraform --delete ; \
aws cloudfront create-invalidation --distribution-id ${CF_DISTRIBUTION_ID} --profile terraform --path "/*" ;
.PHONY: sync_docs

########################################
### Testing

Expand Down
18 changes: 18 additions & 0 deletions docs/.vuepress/components/PageHistory.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<template>
<div>
{{url}}
</div>
</template>

<script>
export default {
computed: {
url() {
const c = this.$themeConfig
if (c && c.repo && c.docsDir && c.docsBranch) {
return `https://github.com/${c.repo}/tree/${c.docsBranch}/${c.docsDir}/${this.$page.relativePath}`
}
},
},
}
</script>
153 changes: 85 additions & 68 deletions docs/.vuepress/config.js
Original file line number Diff line number Diff line change
@@ -1,78 +1,95 @@
const glob = require("glob");
const markdownIt = require("markdown-it");
const meta = require("markdown-it-meta");
const fs = require("fs");
const _ = require("lodash");

const sidebar = (directory, array) => {
return array.map(i => {
const children = _.sortBy(
glob
.sync(`./${directory}/${i[1]}/*.md`)
.map(path => {
const md = new markdownIt();
const file = fs.readFileSync(path, "utf8");
md.use(meta);
md.render(file);
const order = md.meta.order;
return { path, order };
})
.filter(f => f.order !== false),
["order", "path"]
)
.map(f => f.path)
.filter(f => !f.match("readme"));
return {
title: i[0],
children
};
});
};

module.exports = {
title: "Cosmos SDK Documentation",
description: "Documentation for the Cosmos SDK and Gaia.",
ga: "UA-51029217-2",
dest: "./dist/docs",
base: "/docs/",
markdown: {
lineNumbers: true
title: "Cosmos SDK",
base: process.env.VUEPRESS_BASE || "/",
locales: {
"/": {
lang: "en-US"
},
"/ru/": {
lang: "ru"
},
},
themeConfig: {
repo: "cosmos/cosmos-sdk",
editLinks: true,
docsDir: "docs",
editLinks: true,
docsBranch: "master",
editLinkText: "Edit this page on Github",
lastUpdated: true,
algolia: {
apiKey: "a6e2f64347bb826b732e118c1366819a",
indexName: "cosmos_network",
debug: false
},
nav: [
{ text: "Back to Cosmos", link: "https://cosmos.network" },
{ text: "RPC", link: "https://cosmos.network/rpc/" }
],
sidebar: [
{
title: "Overview",
collapsable: true,
children: [
"/intro/",
"/intro/why-app-specific",
"/intro/sdk-app-architecture",
"/intro/sdk-design"
]
locales: {
"/": {
label: "English",
sidebar: sidebar("", [
["Intro", "intro"],
["Basics", "basics"],
["SDK Core", "core"],
["About Modules", "modules"],
["Using the SDK", "sdk"],
["Interfaces", "interfaces"]
])
},
"/ru/": {
label: "Русский",
sidebar: sidebar("ru", [
["Введение", "intro"],
["Основы", "basics"],
["SDK Core", "core"],
["Модули", "modules"],
["Используем SDK", "sdk"],
["Интерфейсы", "interfaces"]
])
},
'/kr/': {
label: '한국어',
sidebar: sidebar('kr', [
['소개', 'intro'],
['기초', 'basics'],
['SDK Core', 'core'],
['모듈들', 'modules'],
['프로그램 사용', 'sdk'],
['인터페이스', 'interfaces'],
]),
},
{
title: "Tutorial",
collapsable: true,
children: [
"/tutorial/",
"/tutorial/app-design",
"/tutorial/app-init",
"/tutorial/types",
"/tutorial/key",
"/tutorial/keeper",
"/tutorial/msgs-handlers",
"/tutorial/set-name",
"/tutorial/buy-name",
"/tutorial/queriers",
"/tutorial/alias",
"/tutorial/codec",
"/tutorial/cli",
"/tutorial/rest",
"/tutorial/module",
"/tutorial/genesis",
"/tutorial/app-complete",
"/tutorial/entrypoint",
"/tutorial/gomod",
"/tutorial/build-run",
"/tutorial/run-rest"
]
'/cn/': {
label: '中文',
sidebar: sidebar('cn', [
['介绍', 'intro'],
['基本', 'basics'],
['SDK Core', 'core'],
['模块', 'modules'],
['使用该程序', 'sdk'],
['接口', 'interfaces'],
]),
},
{
title: "Interfaces",
collapsable: true,
children: [
"/interfaces/",
"/interfaces/cli",
"/interfaces/service-providers",
"/interfaces/lite/", // this renders the readme
"/interfaces/lite/getting_started",
"/interfaces/lite/specification"
]
}
]
}
}
};
11 changes: 8 additions & 3 deletions docs/.vuepress/enhanceApp.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
export default ({ router }) => {
router.addRoutes([{ path: "/testnet/", redirect: "/" }])
}
import axios from 'axios'
import Vue from 'vue'

Vue.use({
install (Vue) {
Vue.prototype.$axios = axios.create()
}
})
4 changes: 0 additions & 4 deletions docs/.vuepress/override.styl

This file was deleted.

File renamed without changes.
2 changes: 1 addition & 1 deletion docs/architecture/adr-002-docs-structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,4 @@ Accepted

- https://github.com/cosmos/cosmos-sdk/issues/1460
- https://github.com/cosmos/cosmos-sdk/pull/2695
- https://github.com/cosmos/cosmos-sdk/issues/2611
- https://github.com/cosmos/cosmos-sdk/issues/2611
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@

## References

- {reference link}
- {reference link}
2 changes: 1 addition & 1 deletion docs/basics/app-anatomy.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ See an example of an application's main command-line file [here](https://github.

## Dependencies and Makefile

This section is optional, as developers are free to choose their depencency manager and project building method. That said, the current most used framework for versioning control is [`go.mod`](https://github.com/golang/go/wiki/Modules). It ensures each of the libraries used throughout the application are imported with the correct version. An example can be found [here](https://github.com/cosmos/sdk-application-tutorial/blob/master/go.mod).
This section is optional, as developers are free to choose their dependency manager and project building method. That said, the current most used framework for versioning control is [`go.mod`](https://github.com/golang/go/wiki/Modules). It ensures each of the libraries used throughout the application are imported with the correct version. An example can be found [here](https://github.com/cosmos/sdk-application-tutorial/blob/master/go.mod).

For building the application, a [Makefile](https://en.wikipedia.org/wiki/Makefile) is generally used. The Makefile primarily ensures that the `go.mod` is run before building the two entrypoints to the application, [`appd`](#node-client) and [`appcli`](#application-interface). An example of Makefile can be found [here](https://github.com/cosmos/sdk-application-tutorial/blob/master/Makefile).

Expand Down
File renamed without changes.
34 changes: 34 additions & 0 deletions docs/building-modules/modules-manager.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Module Manager and `AppModule` Interface

## Pre-requisite Reading

- [Introduction to SDK Modules](./intro.md)

## Synopsis

Cosmos SDK modules need to implement the [`AppModule` interfaces](#application-module-interfaces), in order to be managed by the application's [module manager](#module-manager). The module manager plays an important role in [`message` and `query` routing](../core/baseapp.md#routing), and allows the application developer to set the order of execution of a variety of functions like [`BeginBlocker` and `EndBlocker`](../basics/app-anatomy.md#begingblocker-and-endblocker).

## Application Module Interfaces

[Application module interfaces](https://github.com/cosmos/cosmos-sdk/blob/master/types/module/module.go) exist to facilitate the composition of modules together to form a functional SDK application. There are 3 main application module interfaces:

- [`AppModuleBasic`](#appmodulebasic) for independent module functionalities.
- [`AppModule`](#appmodule) for inter-dependent module functionalities (except genesis-related functionalities).
- [`AppModuleGenesis`](#appmodulegenesis) for inter-dependent genesis-related module functionalities.

The `AppModuleBasic` interface exists to define independent methods of the module, i.e. those that do not depend on other modules in the application. This allows for the construction of the basic application structure early in the application definition, generally in the `init()` function of the [main application file](../basics/app-antomy.md#core-application-file).

The `AppModule` interface exists to define inter-dependent module methods. Many modules need to interact with other modules, typically through [`keeper`s](./keeper.md), which means there is a need for an interface where modules list their `keeper`s and other methods that require a reference to another module's object. `AppModule` interface also enables the module manager to set the order of execution between module's methods like `BeginBlock` and `EndBlock`, which is important in cases where the order of execution between modules matters in the context of the application.

Lastly the interface for genesis functionality `AppModuleGenesis` is separated out from full module functionality `AppModule` so that modules which
are only used for genesis can take advantage of the `Module` patterns without having to define many placeholder functions.

### `AppModuleBasic`

### `AppModule`

### `AppModuleGenesis`

### Implementing the Application Module Interfaces

## Module Manager
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Cosmos SDK 轻节点(Gaia-lite)分为两个独立的组件。 第一个组

想要为 Cosmos Hub(或任何其他 zone)构建第三方客户端应用程序的应用程序开发人员,应根据其规范 API 构建。 该API 是多个部分的组合。 所有 zone 都必须暴露ICS0(TendermintAPI)。 除此之外,任何 zone 都可以自由选择模块 API的任意组合,具体取决于状态机使用的模块。 Cosmos Hub最初将支持[ICS0](https://cosmos.network/rpc/#/ICS0) (TendermintAPI)、 [ICS1](https://cosmos.network/rpc/#/ICS1) (KeyAPI)、 [ICS20](https://cosmos.network/rpc/#/ICS20) (TokenAPI)、 [ICS21](https://cosmos.network/rpc/#/ICS21) (StakingAPI)、 [ICS22](https://cosmos.network/rpc/#/ICS22) (GovernanceAPI) 和 [ICS23](https://cosmos.network/rpc/#/ICS23) (SlashingAPI)。

![high-level](../../../../clients/lite/pics/high-level.png)
![high-level](../../../kr/clients/lite/pics/high-level.png)

预计所有应用程序仅依赖于 Gaia-lite 运行。 Gaia-lite 是唯一一款围绕 zone API 提供稳定性保证的软件。

Expand Down Expand Up @@ -49,12 +49,12 @@ Gaia-lite的基本设计理念遵循两个规则:

原始的可信验证人集应该预先放置到其信任库中,通常这个验证人集来自 genesis 文件。 在运行时期间,如果 Gaia-lite 检测到不同的验证人集,它将验证它并将可信的验证人集保存到信任库中。

![validator-set-change](../../../../clients/lite/pics/validatorSetChange.png)
![validator-set-change](../../../kr/clients/lite/pics/validatorSetChange.png)

### 信任传播

从上面的小节中,我们了解了如何获得可信验证器集以及 LCD 如何跟踪验证人集演化。 验证人集是信任的基础,信任可以传播到其他区块链数据,例如块和交易。 传播架构如下所示:

![change-process](../../../../clients/lite/pics/trustPropagate.png)
![change-process](../../../kr/clients/lite/pics/trustPropagate.png)

通常,通过可信验证人集,轻客户端可以验证包含所有预提交数据和块头数据的每个提交块。 此时块哈希、数据哈希和应用哈希是可信的。 基于此和默克尔证明,所有交易数据和 ABCI 状态也可以被验证。
File renamed without changes.
Loading

0 comments on commit 450c8ce

Please sign in to comment.