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_r350387342
 
 

 ##########
 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);
+        JCommander obj = jcommander.getCommands().get(module);
 
 Review comment:
   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);
   }
   ```

----------------------------------------------------------------
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