Skip to content

Commit

Permalink
fix gen-rpc-doc
Browse files Browse the repository at this point in the history
  • Loading branch information
chenyukang committed Feb 2, 2024
1 parent 3514d09 commit 663f1cc
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 44 deletions.
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,8 @@ doc-deps: ## Build the documentation for the local package and all dependencies.
.PHONY: gen-rpc-doc
gen-rpc-doc: submodule-init ## Generate rpc documentation
cd devtools/doc/rpc-gen && cargo build
cd docs/ckb_rpc_openrpc/ && git reset --hard && git clean -fd
./target/debug/ckb-rpc-gen rpc/README.md
./target/debug/ckb-rpc-gen --json
./target/debug/ckb-rpc-gen rpc/README.md

.PHONY: gen-hashes
gen-hashes: ## Generate docs/hashes.toml
Expand Down
1 change: 0 additions & 1 deletion devtools/doc/rpc-gen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ repository = "https://github.com/nervosnetwork/ckb"

[dependencies]
ckb-rpc ={ path = "../../../rpc", version = "= 0.114.0-pre" }

schemars = { git = "https://github.com/chenyukang/schemars", branch = "fix-derive" }
serde_json = "~1.0"
tera = "1"
28 changes: 16 additions & 12 deletions devtools/doc/rpc-gen/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,22 @@ fn dump_openrpc_json() -> Result<(), Box<dyn std::error::Error>> {
"finished dump openrpc json for version: {:?} at dir: {:?}",
version, json_dir
);
// run git commit all changes before generate rpc readme
run_command("git", &["add", "."], Some(OPENRPC_DIR));
run_command(
"git",
&[
"commit",
"-m",
&format!("update openrpc json for version: {:?}", version),
],
Some(OPENRPC_DIR),
);
run_command("git", &["push"], Some(OPENRPC_DIR));

if is_git_repo_dirty() {
// run git commit all changes before generate rpc readme
eprintln!("commit OpenRPC changes to repo: {}", get_git_remote_url());
run_command("git", &["add", "."], Some(OPENRPC_DIR));
run_command(
"git",
&[
"commit",
"-m",
&format!("update openrpc json for version: {:?}", version),
],
Some(OPENRPC_DIR),
);
run_command("git", &["push"], Some(OPENRPC_DIR));
}
Ok(())
}

Expand Down
14 changes: 14 additions & 0 deletions devtools/doc/rpc-gen/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,17 @@ pub(crate) fn checkout_tag_branch(version: &str) {
run_command("git", &["checkout", "-b", version], dir);
}
}

pub(crate) fn is_git_repo_dirty() -> bool {
let res = run_command("git", &["status", "--porcelain"], Some(OPENRPC_DIR));
res.map(|s| !s.is_empty()).unwrap_or(false)
}

pub(crate) fn get_git_remote_url() -> String {
run_command(
"git",
&["config", "--get", "remote.origin.url"],
Some(OPENRPC_DIR),
)
.map_or("".to_string(), |s| s.trim().to_string())
}
2 changes: 1 addition & 1 deletion docs/ckb_rpc_openrpc
44 changes: 22 additions & 22 deletions rpc/README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion rpc/src/module/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ use std::sync::Arc;
/// ## Chain Reorganization
///
/// Chain Reorganization happens when CKB found a chain that has accumulated more work than the
/// canonical chain. The reorganization reverts the blocks in the current canonical chain if needed,
/// canonical chain. The reorganization revert the blocks in the current canonical chain if needed,
/// and switch the canonical chain to that better chain.
///
/// ## Live Cell
Expand Down
2 changes: 0 additions & 2 deletions util/fixed-hash/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ repository = "https://github.com/nervosnetwork/ckb"
thiserror = "1.0.22"
serde = { version = "1.0", features = ["derive"] }
faster-hex = "0.6"
#schemars = "0.8.12"
schemars = { git = "https://github.com/chenyukang/schemars", branch = "fix-derive"}



[dev-dependencies]
serde_json = "1.0"
2 changes: 0 additions & 2 deletions util/jsonrpc-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ ckb-types = { path = "../types", version = "= 0.114.0-pre" }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
faster-hex = "0.6"

#schemars = "0.8.12"
schemars = { git = "https://github.com/chenyukang/schemars", branch = "fix-derive"}

[dev-dependencies]
Expand Down
1 change: 0 additions & 1 deletion util/launcher/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ ckb-light-client-protocol-server = { path = "../light-client-protocol-server", v
ckb-block-filter = { path = "../../block-filter", version = "= 0.114.0-pre" }



[features]
with_sentry = [ "ckb-sync/with_sentry", "ckb-network/with_sentry", "ckb-app-config/with_sentry" ]
portable = ["ckb-shared/portable"]
Expand Down

0 comments on commit 663f1cc

Please sign in to comment.