-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[Pulsar Client Tools]Support generate documentation of pulsar admin cli automatically #5738
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
[Pulsar Client Tools]Support generate documentation of pulsar admin cli automatically #5738
Conversation
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.
Great contribution to automate the documentation generation for admin CLI!
I have one suggestion to current change.
I don't think it is a good idea to add another flag --generate-doc
in existing commands. Ideally the doc generator should be done in a separate tool. because you anyway create a PulsarAdminTool
in the generateDocument
method.
A better approach would be:
- create a separate tool for generating documentation.
- move
generateDocument
to the new tool. - in generateDocument, you can get all the commands from
commandMap
. - looping through the commands in
commandMap
and generate documentation for each command.
In this way, you don't change any existing commands and you are able to capture all the commands in the command map.
sb.append("`$" + module + "`\n\n"); | ||
sb.append("------------\n\n"); | ||
setupCommands(adminFactory); | ||
JCommander obj = jcommander.getCommands().get(module); |
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.
You can move the logic below into a method called generateDocument(JCommander command)
. Then you can iterate over the commands to generate the documentation for all the commands.
for (JCommander obj : jcommander.getCommands().values()) {
generateDocument(obj);
}
sb.append("### Usage\n\n"); | ||
sb.append("`$" + module + "`\n\n"); | ||
sb.append("------------\n\n"); | ||
setupCommands(adminFactory); |
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.
when a user is generating documentation, he/she should NOT be required to create a Pulsar admin. So we should provide a mock implementation of adminFactory
to return a mock implementation of PulsarAdmin.
removed the milestone for now. If we can make it before releasing 2.5.0, we can mark it for 2.5.0. |
Thank you for your suggestion. The situation you mentioned is my initial implementation plan. However, when I tested it, I found that different command objects PulsarAdminTool: All the child commands were inherited from the class |
The jcommand in PulsarrAdminTool is the root command.The jcommand in CmdBase is for a command group.
You can get the command groups from the commandMap of PulsarAdminTool. Then you can iterate the command group. For each command group, you can get its sub commandMap. |
run java8 tests |
run integration tests |
run java8 tests |
@sijie PTAL |
### Motivation After implementing this tool #5738, we need to use this tool to automatically generate the documentation of pulsar-admin. ### Modifications * Add a script to automatically generate document pages of pulsar-admin * Add em tag for markdown file of pulsar-admin ### Verifying this change 
### Motivation After completing this pull request #5738, it seems that the document was not copied to the correct place to fix the problem. ### Modifications * Copy the document to the correct place
…li automatically (apache#5738) ### Motivation Currently, the commands on the page http://pulsar.apache.org/docs/en/pulsar-admin/ are all manually added. when the document changes, there are often wrong contents. in order to solve this problem, we expect the commands on this page to be automatically generated. this pr is the first step. If it passes, we will add a new page on the website to show the automatically generated commands later.
### Motivation After implementing this tool apache#5738, we need to use this tool to automatically generate the documentation of pulsar-admin. ### Modifications * Add a script to automatically generate document pages of pulsar-admin * Add em tag for markdown file of pulsar-admin ### Verifying this change 
### Motivation After completing this pull request apache#5738, it seems that the document was not copied to the correct place to fix the problem. ### Modifications * Copy the document to the correct place
Motivation
Currently, the commands on the page http://pulsar.apache.org/docs/en/pulsar-admin/ are all manually added. when the document changes, there are often wrong contents. in order to solve this problem, we expect the commands on this page to be automatically generated. this pr is the first step. If it passes, we will add a new page on the website to show the automatically generated commands later.
Modifications
--generate-doc
to automatically generate command line documentsUsage
The following is what we expect:

Verifying this change
Integration test pass