Github user zentol commented on the issue:

    https://github.com/apache/flink/pull/3495
  
    Alright here's what i came up with. We define a single antrun task which 
does the following:
    
    Since all *Options classes reside in the same directory we just take a look 
in there and filter out the Options classes. We then load the class via 
reflection, generate the html and manually write out the file.
     
    The antrun plugin in flink-core is configured like this:
    ```
    <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <version>1.7</version>
        <executions>
                <execution>
                        <id>high-availability</id>
                        <phase>package</phase>
                        <goals>
                                <goal>run</goal>
                        </goals>
                        <configuration>
                                <target>
                                        <java 
classname="org.apache.flink.configuration.ConfigGroup" fork="true">
                                                <classpath 
refid="maven.compile.classpath" />
                                                <arg 
value="${rootDir}/${generated.docs.dir}/" />
                                        </java>
                                </target>
                        </configuration>
                </execution>
        </executions>
    </plugin>
    ```
    
    While the ConfigGroup has gotten a new main method:
    ``´
    public static void main(String[] args) throws Exception {
        String basePath = args[0];
    
        File path = new 
File("../src/main/java/org/apache/flink/configuration/");
    
        String[] classes = path.list();
    
        Pattern p2 = Pattern.compile("([A-Z][a-z]*)");
        Pattern p = Pattern.compile("([a-zA-Z]*Options).java");
        for (String clazz : classes) {
                Matcher m = p.matcher(clazz);
                if (m.matches()) {
    
                        String className = m.group(1);
                        if (!className.equals("ConfigOptions")) {
                                Matcher m2 = p2.matcher(clazz);
                                List<String> parts = new ArrayList<>();
                                while (m2.find()) {
                                        parts.add(m2.group(1));
                                }
                                StringBuilder sb = new StringBuilder();
                                for (int x = 0; x < parts.size() - 1; x++) {
                                        sb.append(parts.get(x).toLowerCase());
                                        sb.append("_");
                                }
                                sb.append("configuration.html");
    
                                String generatedDocFilePath = basePath + sb;
                                String fullClassPath = 
"org.apache.flink.configuration." + className;
    
                                String doc = 
create(Class.forName(fullClassPath)).toHTMLTable(false);
    
                                File f = new File(generatedDocFilePath);
                                f.getParentFile().mkdirs();
                                f.createNewFile();
    
                                try (FileWriter fw = new FileWriter(f)) {
                                        fw.write(doc);
                                        fw.flush();
                                }
                        }
                }
        }
    }
    ```
    
    Haven't cleaned the code up yet, since it's 11pm after all, but it works. 
Maybe you can refine it a bit.
    
    The result is that the docs will be generated automatically for every new 
*Options class that is placed under org.apache.flink.configuration in 
flink-core, which is a must-have imo.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to