You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2019/11/25 19:53:24 UTC

[GitHub] [pulsar] sijie commented on a change in pull request #5738: [Pulsar Client Tools]Support generate documentation of pulsar admin cli automatically

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:
users@infra.apache.org


With regards,
Apache Git Services