added first spike of a kdoc maven plugin for generating API docs for kotlin projects
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-project</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>apidoc</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>stdlib</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit-version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kdoc-maven-plugin</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<configuration>
|
||||
<sources>
|
||||
<source>${basedir}/../stdlib/src</source>
|
||||
<source>${basedir}/../kunit/src/main/kotlin</source>
|
||||
<source>${basedir}/../kotlin-jdbc/src/main/kotlin</source>
|
||||
<source>${basedir}/../kotlin-swing/src/main/kotlin</source>
|
||||
</sources>
|
||||
<title>Kotlin API (${project.version})</title>
|
||||
<ignorePackages>
|
||||
<ignorePackage>com</ignorePackage>
|
||||
<ignorePackage>sun</ignorePackage>
|
||||
<ignorePackage>java</ignorePackage>
|
||||
<ignorePackage>jet</ignorePackage>
|
||||
<ignorePackage>junit</ignorePackage>
|
||||
<ignorePackage>org</ignorePackage>
|
||||
</ignorePackages>
|
||||
|
||||
</configuration>
|
||||
|
||||
<executions>
|
||||
<execution>
|
||||
<id>apidoc</id>
|
||||
<phase>install</phase>
|
||||
<goals>
|
||||
<goal>apidoc</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@@ -0,0 +1,8 @@
|
||||
## KDoc Maven Plugin
|
||||
|
||||
This Maven plugin allows you to create API Documentation for your Kotlin code (rather like javadoc but more kool :)
|
||||
as it allows embedded [markdown](http://daringfireball.net/projects/markdown/syntax#block) wiki markup.
|
||||
|
||||
For examples check out the [Kotlin API docs](http://jetbrains.github.com/kotlin/versions/snapshot/apidocs/index.html).
|
||||
|
||||
For more details see [how to write code with comments](http://confluence.jetbrains.net/display/Kotlin/Coding+Conventions)
|
||||
@@ -0,0 +1,56 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<properties>
|
||||
<maven-plugin-anno.version>1.4.1</maven-plugin-anno.version>
|
||||
<maven.version>3.0.4</maven.version>
|
||||
</properties>
|
||||
|
||||
<parent>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-project</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>kdoc-maven-plugin</artifactId>
|
||||
<packaging>maven-plugin</packaging>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-maven-plugin</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kdoc</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.pegdown</groupId>
|
||||
<artifactId>pegdown</artifactId>
|
||||
<version>${pegdown.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
<build>
|
||||
<sourceDirectory>src/main/java</sourceDirectory>
|
||||
<testSourceDirectory>src/test/java</testSourceDirectory>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-plugin-plugin</artifactId>
|
||||
<version>2.9</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
+164
@@ -0,0 +1,164 @@
|
||||
/*
|
||||
* Copyright 2010-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.maven.doc;
|
||||
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.jetbrains.jet.cli.CompilerArguments;
|
||||
import org.jetbrains.jet.cli.KotlinCompiler;
|
||||
import org.jetbrains.kotlin.doc.KDocArguments;
|
||||
import org.jetbrains.kotlin.doc.KDocCompiler;
|
||||
import org.jetbrains.kotlin.doc.KDocConfig;
|
||||
import org.jetbrains.kotlin.maven.KotlinCompileMojoBase;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Generates API docs documentation for kotlin sources
|
||||
*
|
||||
* @goal apidoc
|
||||
* @phase site
|
||||
* @requiresDependencyResolution test
|
||||
* @noinspection UnusedDeclaration
|
||||
*/
|
||||
public class KDocMojo extends KotlinCompileMojoBase {
|
||||
|
||||
/**
|
||||
* Project classpath.
|
||||
*
|
||||
* @parameter default-value="${project.compileClasspathElements}"
|
||||
* @required
|
||||
* @readonly
|
||||
*/
|
||||
public List<String> classpath;
|
||||
|
||||
/**
|
||||
* Project test classpath.
|
||||
*
|
||||
* @parameter default-value="${project.testClasspathElements}"
|
||||
* @required
|
||||
* @readonly
|
||||
*/
|
||||
protected List<String> testClasspath;
|
||||
|
||||
/**
|
||||
* The directory for compiled apidoc classes.
|
||||
*
|
||||
* @parameter default-value="${project.build.outputDirectory}"
|
||||
* @required
|
||||
* @readonly
|
||||
*/
|
||||
public String output;
|
||||
|
||||
|
||||
// TODO not sure why default is stopping us passing this value in via a config
|
||||
// default-value="${project.compileSourceRoots}"
|
||||
|
||||
/**
|
||||
* The sources used to compile
|
||||
*
|
||||
* @parameter expression="${sources}"
|
||||
* @required
|
||||
*/
|
||||
private List<String> sources;
|
||||
|
||||
/**
|
||||
* The directory for the generated KDocs
|
||||
*
|
||||
* @parameter expression="${docOutputDir}" default-value="${basedir}/target/site/apidocs"
|
||||
* @required
|
||||
*/
|
||||
private String docOutputDir;
|
||||
|
||||
/**
|
||||
* The module to use for documentation
|
||||
*
|
||||
* @parameter expression="${docModule}"
|
||||
*/
|
||||
private String docModule;
|
||||
|
||||
/**
|
||||
* Package prefixes which are excluded from the kdoc
|
||||
*
|
||||
* @parameter expression="${ignorePackages}"
|
||||
*/
|
||||
protected List<String> ignorePackages;
|
||||
|
||||
/**
|
||||
* Whether protected classes, functions and properties should be included
|
||||
*
|
||||
* @parameter expression="${includeProtected}" default-value="true"
|
||||
*/
|
||||
private boolean includeProtected;
|
||||
|
||||
/**
|
||||
* The title of the documentation
|
||||
*
|
||||
* @parameter expression="${title}" default-value="KDoc for ${project.artifactId}"
|
||||
*/
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* The version of the documentation
|
||||
*
|
||||
* @parameter expression="${version}" default-value="KDoc for ${project.version"
|
||||
*/
|
||||
private String version;
|
||||
|
||||
/**
|
||||
* Whether warnings should be generated if no comments could be found for classes, functions and properties being documented
|
||||
*
|
||||
* @parameter expression="${warnNoComments}" default-value="true"
|
||||
*/
|
||||
private boolean warnNoComments;
|
||||
|
||||
@Override
|
||||
protected KotlinCompiler createCompiler() {
|
||||
return new KDocCompiler();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CompilerArguments createCompilerArguments() {
|
||||
return new KDocArguments();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configureCompilerArguments(CompilerArguments arguments) throws MojoExecutionException {
|
||||
configureBaseCompilerArguments(getLog(), arguments, docModule, sources, classpath, output);
|
||||
|
||||
if (arguments instanceof KDocArguments) {
|
||||
KDocArguments kdoc = (KDocArguments) arguments;
|
||||
KDocConfig docConfig = kdoc.getDocConfig();
|
||||
docConfig.setDocOutputDir(docOutputDir);
|
||||
if (ignorePackages != null) {
|
||||
docConfig.getIgnorePackages().addAll(ignorePackages);
|
||||
}
|
||||
docConfig.setIncludeProtected(includeProtected);
|
||||
docConfig.setTitle(title);
|
||||
docConfig.setVersion(version);
|
||||
docConfig.setWarnNoComments(warnNoComments);
|
||||
getLog().info("API docs output to: " + docConfig.getDocOutputDir());
|
||||
getLog().info("classpath: " + classpath);
|
||||
getLog().info("title: " + title);
|
||||
getLog().info("sources: " + sources);
|
||||
getLog().info("API docs ignore packages: " + ignorePackages);
|
||||
} else {
|
||||
getLog().warn("No KDocArguments available!");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright 2010-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.maven;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class MojoTest {
|
||||
@Test
|
||||
public void dummy() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,6 @@
|
||||
<version>${pegdown.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- TODO Replace with compiler dependency -->
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-maven-plugin</artifactId>
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
<module>kotlin-install</module>
|
||||
<module>runtime</module>
|
||||
<module>kotlin-maven-plugin</module>
|
||||
<module>kdoc-maven-plugin</module>
|
||||
<module>kunit</module>
|
||||
<module>stdlib</module>
|
||||
<module>kdoc</module>
|
||||
@@ -39,6 +40,7 @@
|
||||
<module>kotlin-java</module>
|
||||
<module>kotlin-swing</module>
|
||||
<module>website</module>
|
||||
<module>apidoc</module>
|
||||
<module>examples</module>
|
||||
</modules>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user