pulsar-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [pulsar] sijie commented on a change in pull request #5738: [Pulsar Client Tools]Support generate documentation of pulsar admin cli automatically
Date Mon, 25 Nov 2019 19:53:24 GMT
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

Mime
View raw message