-
Notifications
You must be signed in to change notification settings - Fork 38.7k
Rpc help helper class #14502
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
Rpc help helper class #14502
Conversation
|
This is a nice change, and I think making documentation more structured will make it easier to maintain. I do think it'd be good to replace |
|
That's a good point. I used "Table" and "Row", since there are few more different table types, and also "Arguments" and "Results" tables are basically the same thing (Arguments have the numbers next to some rows, but only some of them) The possible table types, by just grepping the source code:
All the Result subtypes are.... yeah basically the same thing, could be treated in some way. |
|
Of course another level would be to somehow match the actual RPC arguments to the arguments in the table, and to the arguments in the short example in the first line, but that is ... just too complex. :) Good first step would be to replace |
|
Finally fixed |
|
Concept ACK. The functional tests do seem to be passing for me when I try them locally. |
|
Concept ACK |
kallewoof
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK
src/rpc/mining.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need the , "" part? It looks like it does not require it:
(this applies to multiple files/places)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just forgot I made the constructor with just one argument. :)
src/rpc/doc.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The initialisation here is redundant.
src/rpc/doc.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be const reference?
src/rpc/doc.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
emplace_back instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have to admit, I don't really understand the difference between emplace_back and push_back
What good does it bring here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...but online wisdom seems to be that emplace_back is faster, because it doesn't create temporary objects, so... ok :)
src/rpc/doc.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
emplace_back instead?
src/rpc/doc.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
emplace_back instead?
src/rpc/doc.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
emplace_back instead?
src/rpc/doc.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
emplace_back instead?
src/rpc/mining.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RPCDoc should be derived from std::exception?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, not sure if I like it... I like how explicit it is now, so you can either have a RPCDoc object (which could later be used somewhere else too) and then explicitly make exception out of it
Also I think that right now when you throw different exception than runtime_error, bitcoind crashes instead of bitcoin-cli writing out the help. I will look once more to be sure
src/rpc/doc.h
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be explicit?
src/rpc/doc.h
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be explicit?
src/rpc/doc.h
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be explicit?
src/rpc/doc.h
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be explicit?
src/rpc/doc.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be const references?
src/rpc/doc.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be const reference?
src/rpc/doc.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is never used?
Reviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
|
Concept ACK. However, this seems to be a large change that is probably impossible to review without splitting it up in smaller chunks and/or making it a scripted diff. While the change seems to touch every help text, it doesn't yet make it meaningfully easier to actually produce the help text machine-generated. You split out the rpc method name, but then pass all arguments as a single string and then each of them again as a " Ideally we'd either merge some exhaustive fix similar to #14459 and then a pure scripted-diff to make it auto-generated (and check that the resulting documentation does not differ after the scripted-diff) or we do the auto-generation without the scripted diff and check that the resulting diff in the documentation looks similar to #14459. I have quickly hacked up a first step of how I think here: #14530 |
|
Thanks for feedback. ad script-diff: I can probably make it script-diffed, it will need some constistency fixed first so the text is parseable, but that can be done as a separate commit. (It is mostly whitespace, missing ad other notes: Yes, this PR lets most of the arguments/"rows" be as-is, as the various styles seemed too different to me to make consistent, so I gave up and just let it be; I focused mainly on getting rid of the "space-formatting" and making it automatically consistent. If the goal is indeed to make generation of, for example, the first-line argument etc more automatic, that can be done, but will take more time :) but sure, it will be a nicer code If I got it correctly. Let's say, walletfundedpsbt https://bitcoincore.org/en/doc/0.17.0/rpc/wallet/walletcreatefundedpsbt/ The current RPC, at least start, is Should the "subcodes" in inputs/outputs arguments, and their help, be also generated from some object (that seems to be m_inner in your example)? Including all the ",...." ? Should the first line stay like it is, or should it instead be I am just saying it will be pretty hard to do this, that's why I opted for "just" adding but if the goal is indeed to make all the doc even more uniform, it's probably better than this "naive" approach that just formats the spaces edit: I look more closely at your #14530 and it indeed produces all the "pseudo-objects" on the left. OK |
|
#14530 looks great, I will try to work on top of that |
| Needs rebase |
|
Closing this, in support of approach similar to #14530 It will be harder to rewrite current source code to that, but ultimately will be more helpful. |
Inspired by some discussions about RPC documentations ( #14399, #14378 ) I have decided to create a RPC help helper class, that automatically formats the RPC help.
This should be helpful in few respects:
The new classes are in rpc/doc.cpp and they are added in the first commit
The second commit is the actual doc rewrite. The process of rewriting current docs to what is in the PR was semi-automatic - unfortunately, not automatic enough to make it a scripted diff. What I did:
It's still a huge chunk of code, even when it is just RPC help.
(Third commit is then removing the unused helper function.)
I think it does the same what @achow101 has been trying (by adding what I have in RPCDoc to UniValue instead) here https://github.com/achow101/bitcoin/tree/rpc-help-univ ; I did not use that because I did not fully understand how it was supposed to be working