Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate RPC endpoint documentation for api.oxen.io #478

Draft
wants to merge 7 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion contrib/onion-request.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ int main(int argc, char** argv) {
if (auto it = aux_keys.find(pk); it != aux_keys.end())
chain.push_back(it->second);
else
std::cerr << pk << " is not an active SN\n";
std::cerr << pk.hex() << " is not an active SN\n";
}
if (chain.size() != pubkeys.size()) throw std::runtime_error{"Missing x25519 pubkeys"};
if (chain.empty()) throw std::runtime_error{"Need at least one SN pubkey"};
Expand Down
1 change: 1 addition & 0 deletions docs/client-rpc/client_rpc_endpoints.h
64 changes: 64 additions & 0 deletions docs/client-rpc/make-docs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/bin/bash

set -e

if [ "$(basename $(pwd))" != "client-rpc" ]; then
echo "Error: you must run this from the docs/client-rpc directory" >&2
exit 1
fi

rm -rf api

docsify init --local api

rm -f api/README.md

if [ -n "$NPM_PACKAGES" ]; then
npm_dir="$NPM_PACKAGES/lib/node_modules"
elif [ -n "$NODE_PATH" ]; then
npm_dir="$NODE_PATH"
elif [ -d "$HOME/node_modules" ]; then
npm_dir="$HOME/node_modules"
elif [ -d "/usr/local/lib/node_modules" ]; then
npm_dir="/usr/local/lib/node_modules"
else
echo "Can't determine your node_modules path; set NPM_PACKAGES or NODE_PATH appropriately" >&2
exit 1
fi

cp $npm_dir/docsify/node_modules/prismjs/components/prism-{json,python,c,cpp}.min.js api/vendor

./rpc-to-markdown.py client_rpc_endpoints.h "$@"

perl -ni -e '
BEGIN { $first = 0; }
if (m{^\s*<script>\s*$} .. m{^\s*</script>\s*$}) {
if (not $first) {
$first = false;
print qq{
<script>
window.\$docsify = {
name: "Oxen Storage Server RPC",
repo: "https://github.com/oxen-io/oxen-storage-server",
loadSidebar: "sidebar.md",
subMaxLevel: 3,
homepage: "index.md",
latex: {
inlineMath : [["\$", "\$"]],
displayMath : [["\$\$", "\$\$"]],
},
}
</script>\n};
}
} else {
s{<title>.*</title>}{<title>Oxen Storage Server RPC</title>};
s{(name="description" content=)"[^"]*"}{$1"Oxen Storage Server RPC endpoint documentation"};
if (m{^\s*</body>}) {
print qq{
<script src="vendor/prism-json.min.js"></script>
<script type="text/javascript" id="MathJax-script" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
<script src="https://cdn.jsdelivr.net/npm/docsify-latex@0"></script>
};
}
print;
}' api/index.html
Loading