• Stars
    star
    124
  • Rank 264,254 (Top 6 %)
  • Language
    Scala
  • License
    Apache License 2.0
  • Created over 10 years ago
  • Updated about 1 month ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

sbt plugin to create a unified Scaladoc or Javadoc API document across multiple subprojects.

sbt-unidoc

sbt plugin to unify scaladoc/javadoc across multiple projects.

how to add this plugin

For sbt 1.x (requires sbt 1.5.x and above) add the following to your project/plugins.sbt:

addSbtPlugin("com.github.sbt" % "sbt-unidoc" % "0.5.0")

Note: We changed the organization from "com.eed3si9n" to "com.github.sbt".

For older sbt 1.x and sbt 0.13 add the following to your project/plugins.sbt:

addSbtPlugin("com.eed3si9n" % "sbt-unidoc" % "0.4.3")

how to unify scaladoc

  1. Enable ScalaUnidocPlugin in your root project's settings.

Note: If one of your subprojects is defining def macros, add scalacOptions in (ScalaUnidoc, unidoc) += "-Ymacro-expand:none" to the root project's setting to temporary halt the macro expansion.

Here's an example setup using multi-project build.sbt:

ThisBuild / organization := "com.example"
ThisBuild / version := "0.1-SNAPSHOT"
ThisBuild / scalaVersion := "2.12.15"
ThisBuild / autoAPIMappings := true

val library = (project in file("library"))
  .settings(
    name := "foo-library"
  )

val app = (project in file("app"))
  .dependsOn(library)
  .settings(
    name := "foo-app"
  )

val root = (project in file("."))
  .enablePlugins(ScalaUnidocPlugin)
  .aggregate(library, app)
  .settings(
    name := "foo"
  )

From the root project, run unidoc task:

foo> unidoc
...
[info] Generating Scala API documentation for main sources to /unidoc-sample/target/scala-2.10/unidoc...
[info] Scala API documentation generation successful.
[success] Total time: 10 s, completed May 16, 2013 12:57:10 AM

A Scala unidoc is created under crossTarget / "unidoc" containing entities from all projects under the build.

how to exclude a project

  1. Construct ScalaUnidoc / unidoc / unidocProjectFilter in the root project's settings.
val root = (project in file("."))
  .enablePlugins(ScalaUnidocPlugin)
  .aggregate(library, app)
  .settings(
    name := "foo",
    ScalaUnidoc / unidoc / unidocProjectFilter := inAnyProject -- inProjects(app)
  )

This will skip Scaladoc for the app project.

how to include multiple configurations

  1. Construct ScalaUnidoc / unidoc / unidocConfigurationFilter in the root project's settings.
val root = (project in file("."))
  .enablePlugins(ScalaUnidocPlugin)
  .aggregate(library, app)
  .settings(
    name := "foo",
    TestScalaUnidoc / unidoc / unidocConfigurationFilter := inConfigurations(Compile, Test)
  )

Running test:unidoc will now create unidoc including both Compile and Test configuration.

how to publish Scala unidoc to Github Pages

Add sbt-site and sbt-ghpages to your project/site.sbt:

addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.3.2")

addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.2")

Then in build.sbt import GitKeys,

import com.typesafe.sbt.SbtGit.GitKeys._

Add ScalaUnidoc / packageDoc / mappings to the site's mapping:

val root = (project in file("."))
  .enablePlugins(ScalaUnidocPlugin, GhpagesPlugin)
  .aggregate(library, app)
  .settings(
    name := "foo",
    ScalaUnidoc / siteSubdirName := "latest/api",
    addMappingsToSiteDir(ScalaUnidoc / packageDoc / mappings, ScalaUnidoc / siteSubdirName),
    gitRemoteRepo := "[email protected]:user/foo.git"
  )

Here's how to preview and publish it:

foo> previewSite
foo> ghpagesPushSite

how to unify javadoc

  1. Enable GenJavadocPlugin in child projects.
  2. Enable JavaUnidocPlugin in the root project.
ThisBuild / organization := "com.example"
ThisBuild / version := "0.1-SNAPSHOT"
ThisBuild / scalaVersion := scalaVersion := "2.12.15"
ThisBuild / autoAPIMappings := true

val library = (project in file("library"))
  .enablePlugins(GenJavadocPlugin)
  .settings(
    name := "foo-library"
  )

val app = (project in file("app"))
  .enablePlugins(GenJavadocPlugin)
  .dependsOn(library)
  .settings(
    name := "foo-app"
  )

val root = (project in file("."))
  .enablePlugins(JavaUnidocPlugin)
  .aggregate(library, app)
  .settings(
    name := "foo"
  )

GenJavadocPlugin adds a compiler plugin called genjavadoc, which generates Java source code into target/java from Scala source code, so javadoc can be generated. The main benefits of javadoc are having natural documentation for Java API, IDE support, and Java enum support. However, the genjavadoc does not always generate compilable Java code; if you see misbehavior please open an issue with genjavadoc.

First clean all projects (in the above, root aggreates both children), then run unidoc task from the root project:

foo> clean
[success] Total time: 0 s, completed May 16, 2013 1:13:55 AM
foo> unidoc
[info] Compiling 10 Scala sources ...
[info] Generating Java API documentation for main sources to /unidoc-sample/target/javaunidoc...
[warn] Loading source file /unidoc-sample/app/target/java/foo/App$.java...
....
[info] Java API documentation generation successful.
[success] Total time: 1 s, completed May 16, 2013 1:14:12 AM

Cleaning is necessary since genjavadoc does not track the correspondence between Scala sources and emitted Java files, leading to extraneous Java sources when deleting classes. A Java unidoc is created under target/javaunidoc containing entities from all projects under the build.

how to publish genjavadoc instead of scaladoc

  1. Enable PublishJavadocPlugin in child projects.

This will substitute the Compile / packageDoc with Genjavadoc / packageDoc to use the enhanced Javadoc.

how to unify both Scaladoc and Javadoc

  1. Enable GenJavadocPlugin (or PublishJavadocPlugin) in child projects.
  2. Enable ScalaUnidocPlugin and JavaUnidocPlugin in the root project.

This combines both Scala unidoc settings and Java unidoc settings. Run unidoc from the root project to execute both.

credits

The original implementation of unidoc task was written by Peter Vlugter (@pvlugter) for Akka project. I took Unidoc.scala in akka/akka@ed40dff7d7353c5cb15b7408ec049116081cb1fc and refactored it. sbt-unidoc is Open Source and available under the Apache 2 License.

More Repositories

1

sbt

sbt, the interactive build tool
Scala
4,685
star
2

sbt-native-packager

sbt Native Packager
Scala
1,577
star
3

sbt-dependency-graph

sbt plugin to create a dependency graph for your project
Scala
1,246
star
4

sbt-jmh

"Trust no one, bench everything." - sbt plugin for JMH (Java Microbenchmark Harness)
Scala
774
star
5

sbt-eclipse

Plugin for sbt to create Eclipse project definitions
Scala
721
star
6

sbt-release

A release plugin for sbt
Scala
630
star
7

sbt-buildinfo

I know this because build.sbt knows this.
Scala
541
star
8

sbt-web

Library for building sbt plugins for the web
Scala
365
star
9

sbt-git

A git plugin for sbt
Scala
342
star
10

zinc

Scala incremental compiler library, used by sbt and other build tools
Scala
314
star
11

docker-sbt

Official sbt docker images
Dockerfile
301
star
12

sbt-dynver

An sbt plugin to dynamically set your version from git
Scala
286
star
13

sbt-ci-release

sbt plugin to automate Sonatype releases from GitHub Actions
Scala
270
star
14

sbt-onejar

Packages your project using One-JARβ„’
Scala
268
star
15

sbt-scalariform

sbt plugin adding support for source code formatting using Scalariform
Scala
259
star
16

sbt-fresh

sbt-plugin to create an opinionated fresh sbt project
Scala
235
star
17

sbt-header

sbt-header is an sbt plugin for creating file headers, e.g. copyright headers
Scala
190
star
18

sbt-github-actions

An sbt plugin which makes it easier to build with GitHub Actions
Scala
185
star
19

sbt-bintray

fresh packages delivered from your sbt console
Scala
180
star
20

sbt-site

Site generation for sbt
Scala
176
star
21

sbt-protobuf

sbt plugin for compiling protobuf files
Scala
173
star
22

sbt-start-script

SBT Plugin to create a "start" script to run the program
Scala
144
star
23

sbt-pgp

PGP plugin for sbt
Scala
141
star
24

sbt-groll

sbt plugin to roll the Git history
Scala
134
star
25

junit-interface

Implementation of sbt's test interface for JUnit
Java
132
star
26

sbt-jni

SBT Plugin to ease working with JNI
Scala
122
star
27

sbt-jacoco

an sbt plugin for JaCoCo Code Coverage
Scala
122
star
28

sbt-projectmatrix

Scala
114
star
29

sbt-boilerplate

sbt plugin for generating scala.Tuple/Function related boilerplate code
Scala
110
star
30

sbt-proguard

Proguard sbt plugin
Scala
99
star
31

sbt-atmos

sbt plugin for running Typesafe Console in development
Scala
98
star
32

sbt-launcher-package

Packaging for sbt so you can run it.
Scala
90
star
33

sbt-dirty-money

clean Ivy2 cache
Scala
87
star
34

sbt-license-report

Report on licenses used in an sbt project.
Scala
85
star
35

sbt-doge

sbt plugin to aggregate tasks across subprojects and their crossScalaVersions
Scala
78
star
36

website

The source for scala-sbt.org
Scala
74
star
37

sbt-pom-reader

Translates xml -> awesome. Maven-ish support for sbt.
Scala
74
star
38

sbt-aspectj

AspectJ sbt plugin
Scala
73
star
39

sbt-remote-control

Create and manage sbt process using unicorns and forks
Scala
73
star
40

sbt-scalabuff

SBT plugin which generate case classes and support for serialization from Google Protocol Buffer definitions using ScalaBuff
Scala
72
star
41

contraband

http://www.scala-sbt.org/contraband/
Scala
68
star
42

sbt-s3

sbt-s3 is a simple sbt plugin to manipulate objects on Amazon S3
Scala
62
star
43

sbt-multi-jvm

Multi-JVM testing in sbt
Scala
53
star
44

sbt-javaagent

sbt plugin for adding java agents to projects
Scala
52
star
45

sbt-cpd

Copy & Paste Detector plugin using PMD for sbt.
Scala
49
star
46

sbt-findbugs

FindBugs static analysis plugin for sbt.
Scala
47
star
47

sbt-man

Looks up scaladoc.
Scala
46
star
48

librarymanagement

librarymanagement module for sbt
Scala
46
star
49

sbt-osgi

sbt plugin for creating OSGi bundles
Scala
45
star
50

io

IO module for sbt
Scala
41
star
51

sbt-less

Scala
41
star
52

sbt-js-engine

Support for sbt plugins that use JavaScript
Scala
40
star
53

launcher

The sbt launcher as its own project. Can launch any ivy/maven published project with a main class, with some fancy features.
Scala
40
star
54

ipcsocket

IPC: Unix Domain Socket and Windows Named Pipes for Java
Java
38
star
55

sbt-autoversion

Scala
34
star
56

sbt-digest

sbt-web plugin for checksum files
Scala
30
star
57

sbt-jupiter-interface

Implementation of SBT's test interface for JUnit Jupiter
Java
29
star
58

sbt-slash

unified slash syntax for both shell and build.sbt
Scala
29
star
59

sbt-avro

sbt plugin for compiling Avro schemas, similar to sbt-protobuf
Java
26
star
60

sbt-java-formatter

An sbt plugin for formating Java code
Scala
25
star
61

sbt-unique-version

emulates Maven's uniqueVersion snapshots
Scala
24
star
62

sbt-gzip

sbt-web plugin for gzipping assets
Scala
24
star
63

sbt.github.com

See https://github.com/sbt/website for the source
HTML
22
star
64

sbt-duplicates-finder

Find classes and resources conflicts in your build
Scala
22
star
65

sbt-pull-request-validator

Plugin that optimizes pull request validation to only validate sub projects that have changed
Scala
21
star
66

sbt-autoplugin.g8

giter8 template for sbt 0.13.5+ AutoPlugin
Scala
20
star
67

sbt-cucumber

Cucumber plugin for SBT.
Scala
20
star
68

sbt-jcstress

Trust no-one, and especially not memory visibility.
HTML
19
star
69

sbt-sriracha

Scala
18
star
70

adept

adept helps you find, declare, and download dependencies. http://groups.google.com/group/adept-dev/
18
star
71

sbt-mocha

SBT plugin for running mocha JavaScript unit tests on node
Scala
17
star
72

util

util modules for sbt
Scala
15
star
73

sbt-export-repo

exports your dependency graph to a preloaded local repository
Scala
15
star
74

sbt-xjc

SBT plugin to compile an XML Schema with XJC
Scala
14
star
75

sbt-multi-release-jar

Support for JDK9's Multi Release JAR Files (JEP 238)
Scala
14
star
76

sbt-nocomma

sbt-nocomma reduces commas from your build.sbt.
Scala
13
star
77

serialization

serialization facility for sbt
Scala
13
star
78

sbt-core-next

sbt APIs targeted for eventual inclusion in sbt core
Scala
12
star
79

sbt-houserules

House rules for sbt modules.
Scala
12
star
80

sbt-maven-resolver

An sbt plugin to resolve dependencies using Aether
Scala
11
star
81

sbt-pamflet

sbt plugin to run Pamflet (and Pamflet plugin to run sbt)
Scala
11
star
82

sbt-appbundle

A plugin for the simple-build-tool to create an OS X application bundle.
Scala
10
star
83

sbt-sdlc

Scaladoc link checker for sbt
Scala
10
star
84

bintry

your packages, delivered fresh
Scala
10
star
85

sbt-fmpp

FreeMarker Scala/Java Templating Plugin for SBT
Scala
9
star
86

sbt-ynolub

Scala
9
star
87

sbt-testng

Implementation of the sbt testing interface for TestNG, bundled with an sbt plug-in for convenience.
Scala
9
star
88

sbt-concat

sbt-web plugin for concatenating web assets
Scala
8
star
89

sbt-ant

SBT plug-in to call Ant targets from within SBT builds
Scala
7
star
90

sbt-community-plugins

All community plugins that opt into an uber-build
Scala
6
star
91

helloworld-one

An example build for sbt 1.0.0.
Scala
5
star
92

sbtn-dist

Shell
5
star
93

sbt-giter8-resolver

Scala
5
star
94

sbt-vimquit

an sbt plugin that adds :q command.
Scala
4
star
95

sbt-sequential

adds sequential tasks to sbt
Scala
4
star
96

sbt-scalashim

generates sys.error.
Scala
4
star
97

sbt-experimental

Experimental APIs to fix rough edges in sbt
Scala
3
star
98

sbt-web-build-base

Scala
3
star
99

sbt-validator

Builds sbt 1.0.x against recent versions of the sbt modules
Shell
3
star
100

sbt-dbuild

Scala
3
star