Skip to content

Commit

Permalink
docs: intial implementation based on rustdoc and mermaid (#966)
Browse files Browse the repository at this point in the history
Co-authored-by: TaniaSaleem <[email protected]>
Co-authored-by: Metadata Update Bot <[email protected]>
Co-authored-by: penumbra23 <[email protected]>
  • Loading branch information
4 people authored Jun 29, 2024
1 parent 5790ba1 commit 7f035fc
Show file tree
Hide file tree
Showing 31 changed files with 1,306 additions and 44 deletions.
14 changes: 14 additions & 0 deletions .github/actions/rust-init/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: "Init Rust"
description: "Install Rust version with Timechain dependencies"

inputs: {}

runs:
using: "composite"
steps:
- name: Install dependencies
shell: bash
run: sudo apt-get update && sudo apt-get install -y protobuf-compiler
- name: Install rust toolchain
shell: bash
run : rustup show
30 changes: 30 additions & 0 deletions .github/workflows/build-docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Generate docs

on:
pull_request:
paths-ignore:
- 'docker/**'
- 'infra/**'
- 'js/**'
- 'scripts/**'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build-docs:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Initialize Rust
uses: ./.github/actions/rust-init
- name: Build docs
run: cargo doc --no-deps --document-private-items --workspace
- name: Upload docs
uses: actions/upload-artifact@v4
with:
name: docs
if-no-files-found: error
path: target/doc
1 change: 1 addition & 0 deletions .github/workflows/build-runtime.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ jobs:
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
submodules: recursive
- name: Download and update Testnet Metadata
id: download-testnet-default-metadata
uses: actions/download-artifact@v4
Expand Down
33 changes: 33 additions & 0 deletions .github/workflows/deploy-docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Generate docs
on:
push:
paths-ignore:
- 'docker/**'
- 'infra/**'
- 'js/**'
- 'scripts/**'
branches:
- 'development'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
deploy-docs:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Initialize Rust
uses: ./.github/actions/rust-init
- name: Build docs
run: cargo doc --no-deps --document-private-items --workspace
- name: Assemble structure
env:
DOCS_HIDEOUT: an8ohgahmoot6ro8ieReib9micau0Oow
run: |
cp -r target/doc target/docs/$DOCS_HIDEOUT
cp docs/robots.txt target/docs/$DOCS_HIDEOUT
- name: Deploy docs
uses: actions/upload-pages-artifact@v4
with:
path: target/docs
44 changes: 31 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ edition = "2021"
version = "0.6.0"
homepage = "https://analog.one/"
license = "GPL-3.0-only"
license-file = "LICENSE"
readme = "README.md"
repository = "https://github.com/Analog-Labs/timechain"

[workspace]
resolver = "2"
members = [
"chronicle",
"docs",
"node",
"pallets/elections",
"pallets/members",
Expand Down Expand Up @@ -57,6 +57,8 @@ rosetta-client = { git = "https://github.com/analog-labs/chain-connectors" }
rosetta-core = { git = "https://github.com/analog-labs/chain-connectors" }
rosetta-config-ethereum = { git = "https://github.com/analog-labs/chain-connectors" }

simple-mermaid = "0.1"

[profile.release]
# Runtime requires unwinding.
panic = "unwind"
Expand Down
2 changes: 1 addition & 1 deletion analog-gmp
Binary file modified config/subxt/testnet.default.scale
Binary file not shown.
Binary file modified config/subxt/testnet.development.scale
Binary file not shown.
18 changes: 18 additions & 0 deletions docs/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[package]
name = "analog-docs"
version = "0.1.0"
edition = "2021"

[dependencies]
timechain-node = { path = "../node" }

timechain-runtime = { path = "../runtime" }

pallet-elections = { path = "../pallets/elections" }
pallet-members = { path = "../pallets/members" }
pallet-networks = { path = "../pallets/networks" }
pallet-shards = { path = "../pallets/shards" }
pallet-tasks = { path = "../pallets/tasks" }
pallet-timegraph = { path = "../pallets/timegraph" }

chronicle = { path = "../chronicle" }
2 changes: 2 additions & 0 deletions docs/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
User-agent: *
Disallow: /
27 changes: 27 additions & 0 deletions docs/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//! # Analog Timechain Documentation
//!
//! This crate is a *minimal* but *always-accurate* documentation
//! of the Timechain protocol.
//!
//! ## The Timechain Protocol
//!
//! The Analog Timechain is a substrate based solochain. It utilizes
//! Babe and Grandpa to power its [`timechain_node`] and [`timechain_runtime`].
//!
//! On top of that it runs the Timechain protocol to attest and relay data
//! between various chains. This protocol is executed by shards of [`chronicle`] nodes.
//!
//! ## Custom pallets
//!
//! - [`pallet_elections`]
//! - [`pallet_members`]
//! - [`pallet_networks`]
//! - [`pallet_shards`]
//! - [`pallet_tasks`]
//! - [`pallet_timegraph`]
//!
#![warn(rustdoc::broken_intra_doc_links)]
#![warn(rustdoc::private_intra_doc_links)]
#![doc(html_favicon_url = "https://www.analog.one/images/favicon.ico")]
#![doc(html_logo_url = "https://www.analog.one/images/logo.svg")]
#![doc(issue_tracker_base_url = "https://github.com/Analog-Labs/timechain/issues")]
1 change: 0 additions & 1 deletion node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ authors.workspace = true
edition.workspace = true
homepage.workspace = true
license.workspace = true
license-file.workspace = true
repository.workspace = true
readme.workspace = true

Expand Down
2 changes: 1 addition & 1 deletion node/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub struct Cli {

#[cfg(feature = "chronicle")]
#[derive(Debug, clap::Parser)]
/// workaround for https://github.com/clap-rs/clap/issues/5092
/// workaround for <https://github.com/clap-rs/clap/issues/5092>
#[group(requires_all = ["network_id", "target_url", "target_keyfile", "timechain_keyfile"], multiple = true)]
pub struct ChronicleArgs {
/// The network to be used from Analog Connector.
Expand Down
2 changes: 2 additions & 0 deletions pallets/members/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ sp-std = { git = "https://github.com/analog-labs/polkadot-sdk", tag = "v1.13.0-p

time-primitives = { path = "../../primitives", default-features = false }

simple-mermaid.workspace = true

[dev-dependencies]
env_logger.workspace = true
lazy_static = "1.4.0"
Expand Down
Loading

0 comments on commit 7f035fc

Please sign in to comment.