flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (FLINK-5781) Generation HTML from ConfigOption
Date Thu, 06 Apr 2017 21:21:41 GMT

    [ https://issues.apache.org/jira/browse/FLINK-5781?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15959777#comment-15959777

ASF GitHub Bot commented on FLINK-5781:

Github user zentol commented on the issue:

    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:
    					<java classname="org.apache.flink.configuration.ConfigGroup" fork="true">
    						<classpath refid="maven.compile.classpath" />
    						<arg value="${rootDir}/${generated.docs.dir}/" />
    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()) {
    				StringBuilder sb = new StringBuilder();
    				for (int x = 0; x < parts.size() - 1; x++) {
    				String generatedDocFilePath = basePath + sb;
    				String fullClassPath = "org.apache.flink.configuration." + className;
    				String doc = create(Class.forName(fullClassPath)).toHTMLTable(false);
    				File f = new File(generatedDocFilePath);
    				try (FileWriter fw = new FileWriter(f)) {
    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.

> Generation HTML from ConfigOption
> ---------------------------------
>                 Key: FLINK-5781
>                 URL: https://issues.apache.org/jira/browse/FLINK-5781
>             Project: Flink
>          Issue Type: Sub-task
>          Components: Documentation
>            Reporter: Ufuk Celebi
>            Assignee: Dawid Wysakowicz
> Use the ConfigOption instances to generate a HTML page that we can use to include in
the docs configuration page.

This message was sent by Atlassian JIRA

View raw message