Skip to content

Commit

Permalink
Merge pull request #4341 from chenyukang/trivial-fix-doc
Browse files Browse the repository at this point in the history
Support RPC duplicate method name  for different modules
  • Loading branch information
chenyukang authored Feb 8, 2024
2 parents d6e9341 + c7315fd commit 1ee9c98
Show file tree
Hide file tree
Showing 7 changed files with 162 additions and 91 deletions.
6 changes: 5 additions & 1 deletion devtools/doc/rpc-gen/src/gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,11 @@ impl RpcModule {
.unwrap()
.replace("##", "######");
desc = strip_prefix_space(&desc);
format!("#### Method `{}`\n{}\n\n{}\n", name, signatures, desc,)
let link = format!("<a id=\"{}-{}\"></a>", capitlized.to_lowercase(), name);
format!(
"{}\n#### Method `{}`\n{}\n\n{}\n",
link, name, signatures, desc,
)
})
.collect::<Vec<_>>();

Expand Down
3 changes: 2 additions & 1 deletion devtools/doc/rpc-gen/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ use std::{fs, path::PathBuf};
fn dump_openrpc_json() -> Result<(), Box<dyn std::error::Error>> {
let json_dir = PathBuf::from(OPENRPC_DIR).join("json");
let version = get_version();
checkout_tag_branch(&version);
let branch = get_current_git_branch();
checkout_openrpc_branch(&branch);
fs::create_dir_all(&json_dir)?;

for (name, mut doc) in all_rpc_docs() {
Expand Down
7 changes: 6 additions & 1 deletion devtools/doc/rpc-gen/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,18 @@ pub(crate) fn get_version() -> String {
version
}

pub(crate) fn get_current_git_branch() -> String {
run_command("git", &["rev-parse", "--abbrev-ref", "HEAD"], None)
.unwrap_or_else(|| "unknown".to_string())
}

pub(crate) fn get_commit_sha() -> String {
let res = run_command("git", &["rev-parse", "HEAD"], Some(OPENRPC_DIR)).unwrap();
eprintln!("commit sha: {:?}", res);
res
}

pub(crate) fn checkout_tag_branch(version: &str) {
pub(crate) fn checkout_openrpc_branch(version: &str) {
let dir = Some(OPENRPC_DIR);
let res = run_command("git", &["checkout", version], dir);
if res.is_none() {
Expand Down
2 changes: 1 addition & 1 deletion devtools/doc/rpc-gen/templates/markdown.tera
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{%- set methods = menu["methods"] %}
* [Module {{ menu["title"] }}](#module-{{ menu["name"] }}) {{ menu["link"] }}
{%- for method in methods %}
* [Method `{{method}}`](#method-{{method}})
* [Method `{{method}}`](#{{ menu["name"] }}-{{method}})
{%- endfor %}
{%- endfor %}
* [RPC Types](#rpc-types)
Expand Down
2 changes: 1 addition & 1 deletion docs/ckb_rpc_openrpc
231 changes: 146 additions & 85 deletions rpc/README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion rpc/src/module/miner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ pub trait MinerRpc {
/// "jsonrpc": "2.0",
/// "method": "submit_block",
/// "params": [
/// "example",
/// "work_id_example",
/// {
/// "header": {
/// "compact_target": "0x1e083126",
Expand Down

0 comments on commit 1ee9c98

Please sign in to comment.