sijie commented on a change in pull request #5738: [Pulsar Client Tools]Support 
generate documentation of pulsar admin cli automatically
URL: https://github.com/apache/pulsar/pull/5738#discussion_r350389197
 
 

 ##########
 File path: 
pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/PulsarAdminTool.java
 ##########
 @@ -166,13 +172,69 @@ boolean run(String[] args) {
         });
     }
 
+    void generateDocument(Function<PulsarAdminBuilder, ? extends PulsarAdmin> 
adminFactory, String module) {
+        PulsarAdminTool tool;
+        try {
+            tool = new PulsarAdminTool(new Properties());
+        } catch (Exception e) {
+            System.err.println(e.getMessage());
+            System.err.println();
+            setupCommands(adminFactory);
+            jcommander.usage();
+            return;
+        }
+        StringBuilder sb = new StringBuilder();
+        tool.commandMap.get(module);
+        sb.append("------------\n\n");
+        sb.append("# " + module).append("\n\n");
+        sb.append("### Usage\n\n");
+        sb.append("`$" + module + "`\n\n");
+        sb.append("------------\n\n");
+        setupCommands(adminFactory);
 
 Review comment:
   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. 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to