Skip to content

Commit

Permalink
Sort RPC methods in docs (#301)
Browse files Browse the repository at this point in the history
The methods that appear in the published docs are not sorted by method
name. This may not matter when looking for a particular method (as you
can use Ctrl-F/Cmd-F in your browser), but not so when using the list as
a whole. In our case, we have a proxy to Ethereum in our project, and we
want to ensure we have proper test coverage for all public Ethereum RPC
methods. This is difficult when the official list of methods is unsorted
because we have to double- and triple-check that we've accounted for all
of them on our side. If the list were sorted then this task would be a
lot easier.
  • Loading branch information
mcmire committed Jul 4, 2023
1 parent fa0580e commit 608001d
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@ import yaml from "js-yaml";
import merger from "json-schema-merge-allof";
import { dereferenceDocument } from "@open-rpc/schema-utils-js";

function sortByMethodName(methods) {
return methods.slice().sort((a, b) => {
if (a['name'] > b['name']) {
return 1;
} else if (a['name'] < b['name']) {
return -1;
} else {
return 0;
}
})
}

console.log("Loading files...\n");

let methods = [];
Expand Down Expand Up @@ -78,7 +90,7 @@ const doc = {
},
version: "0.0.0"
},
methods: methods,
methods: sortByMethodName(methods),
components: {
schemas: schemas
}
Expand Down

0 comments on commit 608001d

Please sign in to comment.