Skip to content

Commit

Permalink
Update custom-version-plugin.js
Browse files Browse the repository at this point in the history
  • Loading branch information
samricotta committed Jun 11, 2023
1 parent 2d1f472 commit c7d8c0d
Show file tree
Hide file tree
Showing 12 changed files with 276 additions and 27 deletions.
18 changes: 10 additions & 8 deletions custom-version-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ const path = require('path');

// Helper function to get all files recursively from a directory
function getAllFiles(dirPath, arrayOfFiles) {
const files = fs.readdirSync(dirPath);

arrayOfFiles = arrayOfFiles || [];
const files = fs.readdirSync(dirPath);

files.forEach(function (file) {
if (fs.statSync(path.join(dirPath, file)).isDirectory()) {
arrayOfFiles = getAllFiles(path.join(dirPath, file), arrayOfFiles);
const filePath = path.join(dirPath, file);
if (fs.statSync(filePath).isDirectory()) {
arrayOfFiles = getAllFiles(filePath, arrayOfFiles);
} else {
arrayOfFiles.push(path.join(dirPath, file));
arrayOfFiles.push(filePath);
}
});

Expand All @@ -29,15 +29,15 @@ module.exports = function (_context, _options) {

async loadContent() {
// Read the versions.json file to get the list of versions
const versionsJsonPath = path.join(_context.siteDir, 'cosmos-sdk-docs', 'versions.json');
const versionsJsonPath = path.join(_context.siteDir, 'versions.json');
const versions = JSON.parse(fs.readFileSync(versionsJsonPath, 'utf8'));

// Read the version config file
const versionConfigPath = path.join(_context.siteDir, 'cosmos-sdk-docs', 'version_config.json');
const versionConfigPath = path.join(_context.siteDir, 'version_config.json');
const versionConfig = JSON.parse(fs.readFileSync(versionConfigPath, 'utf8'));

// Read all the files in the /docs folder
const docsPath = path.join(_context.siteDir, 'cosmos-sdk-docs', 'docs');
const docsPath = path.join(_context.siteDir, 'docs');
const files = getAllFiles(docsPath);

// Iterate through the list of versions
Expand All @@ -54,6 +54,8 @@ module.exports = function (_context, _options) {
// Check if the file exists in the version directory
if (!fs.existsSync(customFilePath) && !shouldExcludeFile(version, relativePath, versionConfig)) {
// If the file doesn't exist and it's not excluded, copy it from the /docs folder
const customFileDir = path.dirname(customFilePath);
fs.mkdirSync(customFileDir, { recursive: true });
fs.copyFileSync(file, customFilePath);
console.log(`Copied file from /docs to version-${version}:`, relativePath);
}
Expand Down
6 changes: 3 additions & 3 deletions docs/develop/_category_.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"label": "Develop",
"position": 0,
"link": null
"label": "Develop",
"position": 0,
"link": null
}
16 changes: 13 additions & 3 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@

const lightCodeTheme = require("prism-react-renderer/themes/github");
const darkCodeTheme = require("prism-react-renderer/themes/dracula");
const customVersionPlugin = require('./custom-version-plugin');


// const lastVersion = "v0.47";
const lastVersion = "current";

/** @type {import('@docusaurus/types').Config} */
Expand Down Expand Up @@ -107,6 +106,18 @@ const config = {
position: "right",
dropdownActiveClassDisabled: true,
// versions not yet migrated to docusaurus
dropdownItemsAfter: [
{
href: "https://docs.cosmos.network/v0.46/",
label: "v0.46",
target: "_self",
},
{
href: "https://docs.cosmos.network/v0.45/",
label: "v0.45",
target: "_self",
},
],
},
],
},
Expand Down Expand Up @@ -207,7 +218,6 @@ const config = {
},
};
},
customVersionPlugin,
[
"@docusaurus/plugin-google-analytics",
{
Expand Down
20 changes: 10 additions & 10 deletions version_config.json
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
{
"0.45": {
"excludedPaths": ["integrate/modules/slashing", "integrate/modules/nft", "integrate/modules/group", "integrate/modules/genutil",
"integrate/modules/consensus", "integrate/modules/circuit", "integrate/building-modules/autocli", "integrate/building-modules/depinject",
"integrate/building-modules/testing", "integrate/building-apps", "integrate/architecture/rfc", "integrate/specs", "interate/architeture/adr-041-in-place-store-migrations", "interate/architeture/adr-042-group-module",
"excludedPaths": ["integrate/modules/slashing", "integrate/modules/nft", "integrate/building-modules/15-depinject.md", "integrate/modules/genutil",
"integrate/modules/consensus", "integrate/modules/circuit", "integrate/building-apps","integrate/building-modules/autocli", "integrate/building-modules/depinject",
"integrate/building-modules/testing", "integrate/building-apps", "integrate/architecture/rfc", "integrate/specs", "integrate/architecture/adr-041-in-place-store-migrations", "integrate/architecture/adr-042-group-module",
"integrate/architecture/adr-043-nft-module", "integrate/architecture/adr-044-protobuf-updates-guidelines", "integrate/architecture/adr-045-check-delivertx-middlewares",
"integrate/architecture/adr-046-module-params", "integrate/architecture/adr-046-module-params", "integrate/architecture/adr-047-extend-upgrade-plan",
"integrate/architecture/adr-048-consensus-fees", "integrate/architecture/adr-049-state-sync-hooks", "integrate/architecture/adr-050-sign-mode-textual",
"integrate/architecture/adr-050-sign-mode-textual-annex1", "integrate/architecture/adr-050-sign-mode-textual-annex2", "integrate/architecture/adr-053-go-module-refactoring","integrate/arcitecture/adr-054-semver-compatible-modules",
"integrate/architecture/adr-050-sign-mode-textual-annex1", "integrate/architecture/adr-050-sign-mode-textual-annex2", "integrate/architecture/adr-053-go-module-refactoring","integrate/architecture/adr-054-semver-compatible-modules",
"integrate/architecture/adr-055-orm", "integrate/architecture/adr-057-app-wiring", "integrate/architecture/adr-058-auto-generated-cli", "integrate/architecture/adr-059-test-scopes",
"integrate/architecture/adr-060-abci-1.0", "integrate/architecture/adr-061-liquid-staking", "integrate/architecture/adr-062-collections-state-layer",
"integrate/architecture/adr-062-collections-state-layer", "integrate/architecture/adr-063-core-module-api", "integrate/architecture/adr-064-abci-2.0",
"integrate/architecture/adr-065-store-v2"]
"integrate/architecture/adr-065-store-v2", "integrate/architecture/README"]
},
"0.46": {
"excludedPaths": ["integrate/modules/genutil", "integrate/modules/consensus", "integrate/modules/circuit", "integrate/architecture/rfc",
"integrate/specs", "integrate/tooling", "integrate/building-modules/depinject", "integrate/architecture/adr-007-specialization-groups",
"excludedPaths": ["integrate/modules/genutil", "integrate/building-modules/15-depinject.md","integrate/modules/consensus", "integrate/modules/circuit", "integrate/architecture/rfc",
"integrate/specs", "integrate/building-apps", "integrate/building-modules/depinject", "integrate/architecture/adr-007-specialization-groups",
"integrate/architecture/adr-008-dCERT-group", "integrate/architecture/adr-014-proportional-slashing",
"integrate/architecture/adr-034-account-rekeying", "interate/architeture/adr-041-in-place-store-migrations", "interate/architeture/adr-042-group-module",
"integrate/architecture/adr-034-account-keying", "integrate/architecture/adr-041-in-place-store-migrations", "integrate/architecture/adr-042-group-module",
"integrate/architecture/adr-043-nft-module", "integrate/architecture/adr-044-protobuf-updates-guidelines", "integrate/architecture/adr-045-check-delivertx-middlewares",
"integrate/architecture/adr-048-consensus-fees", "integrate/architecture/adr-049-state-sync-hooks", "integrate/architecture/adr-050-sign-mode-textual",
"integrate/architecture/adr-050-sign-mode-textual-annex1", "integrate/architecture/adr-050-sign-mode-textual-annex2", "integrate/arcitecture/adr-054-semver-compatible-modules",
"integrate/architecture/adr-050-sign-mode-textual-annex1", "integrate/architecture/adr-050-sign-mode-textual-annex2", "integrate/architecture/adr-054-semver-compatible-modules",
"integrate/architecture/adr-055-orm", "integrate/architecture/adr-057-app-wiring", "integrate/architecture/adr-058-auto-generated-cli", "integrate/architecture/adr-059-test-scopes",
"integrate/architecture/adr-060-abci-1.0", "integrate/architecture/adr-061-liquid-staking", "integrate/architecture/adr-062-collections-state-layer",
"integrate/architecture/adr-062-collections-state-layer", "integrate/architecture/adr-063-core-module-api", "integrate/architecture/adr-064-abci-2.0",
"integrate/architecture/adr-065-store-v2"]
"integrate/architecture/adr-065-store-v2", "integrate/architecture/README"]
},
"0.47": {
"excludedPaths": []
Expand Down
2 changes: 1 addition & 1 deletion versioned_docs/version-0.45/integrate/ibc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ This repository contains reference documentation for the IBC protocol integratio
**NOTE**: The IBC module has been moved to its [own repository](https://github.com/cosmos/ibc-go).

After reading about IBC, head on to the [Building Modules
documentation](../building-modules/README.md) to learn more about the process of building modules.
documentation](../building-modules/) to learn more about the process of building modules.
2 changes: 1 addition & 1 deletion versioned_docs/version-0.45/integrate/ibc/integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func NewApp(...args) *App {
### Module Managers
In order to use IBC, we need to add the new modules to the module `Manager` and to the `SimulationManager` in case your application supports [simulations](./../building-modules/simulator.md).
In order to use IBC, we need to add the new modules to the module `Manager` and to the `SimulationManager` in case your application supports [simulations](../building-modules/simulator).
```go
// app.go
Expand Down
2 changes: 1 addition & 1 deletion versioned_docs/version-0.45/integrate/ibc/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ In IBC, blockchains do not directly pass messages to each other over the network

- The proof format that all implementations must produce and verify is defined in [ICS-23 implementation](https://github.com/confio/ics23).

### [Capabilities](./ocap.md)
### Capabilities

IBC is intended to work in execution environments where modules do not necessarily trust each other. IBC must authenticate module actions on ports and channels so that only modules with the appropriate permissions can use the channels. This security is accomplished using [dynamic capabilities](../architecture/adr-003-dynamic-capability-store.md). Upon binding to a port or creating a channel for a module, IBC returns a dynamic capability that the module must claim to use that port or channel. This binding strategy prevents other modules from using that port or channel since those modules do not own the appropriate capability.

Expand Down
37 changes: 37 additions & 0 deletions versioned_docs/version-0.45/integrate/modules/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
sidebar_position: 0
slug : /modules
---

# Module Summary

Here are some production-grade modules that can be used in Cosmos SDK applications, along with their respective documentation:

* [Auth](auth/README.md) - Authentication of accounts and transactions for Cosmos SDK applications.
* [Authz](authz/README.md) - Authorization for accounts to perform actions on behalf of other accounts.
* [Bank](bank/README.md) - Token transfer functionalities.
* [Crisis](crisis/README.md) - Halting the blockchain under certain circumstances (e.g. if an invariant is broken).
* [Distribution](distribution/README.md) - Fee distribution, and staking token provision distribution.
* [Evidence](evidence/README.md) - Evidence handling for double signing, misbehaviour, etc.
* [Feegrant](feegrant/README.md) - Grant fee allowances for executing transactions.
* [Governance](gov/README.md) - On-chain proposals and voting.
* [Mint](mint/README.md) - Creation of new units of staking token.
* [Params](params/README.md) - Globally available parameter store.
* [Staking](staking/README.md) - Proof-of-Stake layer for public blockchains.
* [Upgrade](upgrade/README.md) - Software upgrades handling and coordination.

To learn more about the process of building modules, visit the [building modules reference documentation](https://docs.cosmos.network/main/building-modules/intro).

## IBC

The IBC module for the SDK is maintained by the IBC Go team in its [own repository](https://github.com/cosmos/ibc-go).

Additionally, the [capability module](https://github.com/cosmos/ibc-go/tree/fdd664698d79864f1e00e147f9879e58497b5ef1/modules/capability) is from v0.48+ maintained by the IBC Go team in its [own repository](https://github.com/cosmos/ibc-go/tree/fdd664698d79864f1e00e147f9879e58497b5ef1/modules/capability).

## CosmWasm

The CosmWasm module enables smart contracts, learn more by going to their [documentation site](https://book.cosmwasm.com/), or visit [the repository](https://github.com/CosmWasm/cosmwasm).

## EVM

Read more about writing smart contracts with solidity at the official [`evm` documentation page](https://docs.evmos.org/modules/evm/).
34 changes: 34 additions & 0 deletions versioned_docs/version-0.45/integrate/rfc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
sidebar_position: 1
---

# Requests for Comments

A Request for Comments (RFC) is a record of discussion on an open-ended topic
related to the design and implementation of the Cosmos SDK, for which no
immediate decision is required.

The purpose of an RFC is to serve as a historical record of a high-level
discussion that might otherwise only be recorded in an ad-hoc way (for example,
via gists or Google docs) that are difficult to discover for someone after the
fact. An RFC _may_ give rise to more specific architectural _decisions_ for
the Cosmos SDK, but those decisions must be recorded separately in
[Architecture Decision Records (ADR)](../architecture).

As a rule of thumb, if you can articulate a specific question that needs to be
answered, write an ADR. If you need to explore the topic and get input from
others to know what questions need to be answered, an RFC may be appropriate.

## RFC Content

An RFC should provide:

* A **changelog**, documenting when and how the RFC has changed.
* An **abstract**, briefly summarizing the topic so the reader can quickly tell
whether it is relevant to their interest.
* Any **background** a reader will need to understand and participate in the
substance of the discussion (links to other documents are fine here).
* The **discussion**, the primary content of the document.

The [rfc-template.md](rfc-template.md) file includes placeholders for these
sections.
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
---
sidebar_position: 1
---

# Recommended Folder Structure

:::note Synopsis
This document outlines the recommended structure of Cosmos SDK modules. These ideas are meant to be applied as suggestions. Application developers are encouraged to improve upon and contribute to module structure and development design.
:::

## Structure

A typical Cosmos SDK module can be structured as follows:

```shell
proto
└── {project_name}
   └── {module_name}
   └── {proto_version}
      ├── {module_name}.proto
      ├── event.proto
      ├── genesis.proto
      ├── query.proto
      └── tx.proto
```

* `{module_name}.proto`: The module's common message type definitions.
* `event.proto`: The module's message type definitions related to events.
* `genesis.proto`: The module's message type definitions related to genesis state.
* `query.proto`: The module's Query service and related message type definitions.
* `tx.proto`: The module's Msg service and related message type definitions.

```shell
x/{module_name}
├── client
│   ├── cli
│   │ ├── query.go
│   │   └── tx.go
│   └── testutil
│   ├── cli_test.go
│   └── suite.go
├── exported
│   └── exported.go
├── keeper
│   ├── genesis.go
│   ├── grpc_query.go
│   ├── hooks.go
│   ├── invariants.go
│   ├── keeper.go
│   ├── keys.go
│   ├── msg_server.go
│   └── querier.go
├── module
│   └── module.go
│   └── abci.go
├── simulation
│   ├── decoder.go
│   ├── genesis.go
│   ├── operations.go
│   └── params.go
├── {module_name}.pb.go
├── codec.go
├── errors.go
├── events.go
├── events.pb.go
├── expected_keepers.go
├── genesis.go
├── genesis.pb.go
├── keys.go
├── msgs.go
├── params.go
├── query.pb.go
├── tx.pb.go
└── 05-depinject.md
```

* `client/`: The module's CLI client functionality implementation and the module's CLI testing suite.
* `exported/`: The module's exported types - typically interface types. If a module relies on keepers from another module, it is expected to receive the keepers as interface contracts through the `expected_keepers.go` file (see below) in order to avoid a direct dependency on the module implementing the keepers. However, these interface contracts can define methods that operate on and/or return types that are specific to the module that is implementing the keepers and this is where `exported/` comes into play. The interface types that are defined in `exported/` use canonical types, allowing for the module to receive the keepers as interface contracts through the `expected_keepers.go` file. This pattern allows for code to remain DRY and also alleviates import cycle chaos.
* `keeper/`: The module's `Keeper` and `MsgServer` implementation.
* `module/`: The module's `AppModule` and `AppModuleBasic` implementation.
* `abci.go`: The module's `BeginBlocker` and `EndBlocker` implementations (this file is only required if `BeginBlocker` and/or `EndBlocker` need to be defined).
* `simulation/`: The module's [simulation](14-simulator.md) package defines functions used by the blockchain simulator application (`simapp`).
* `REAMDE.md`: The module's specification documents outlining important concepts, state storage structure, and message and event type definitions. Learn more how to write module specs in the [spec guidelines](../spec/SPEC_MODULE.md).
* The root directory includes type definitions for messages, events, and genesis state, including the type definitions generated by Protocol Buffers.
* `codec.go`: The module's registry methods for interface types.
* `errors.go`: The module's sentinel errors.
* `events.go`: The module's event types and constructors.
* `expected_keepers.go`: The module's [expected keeper](06-keeper.md#type-definition) interfaces.
* `genesis.go`: The module's genesis state methods and helper functions.
* `keys.go`: The module's store keys and associated helper functions.
* `msgs.go`: The module's message type definitions and associated methods.
* `params.go`: The module's parameter type definitions and associated methods.
* `*.pb.go`: The module's type definitions generated by Protocol Buffers (as defined in the respective `*.proto` files above).
Loading

0 comments on commit c7d8c0d

Please sign in to comment.