Skip to content

Commit 3342c03

Browse files
2mraboof
authored andcommitted
Update to the latest sbt-scalafmt (#39)
* Move from source folders with dots * Update to the latest scalafmt sbt plugin * Reformat build code * Reformat code * Check formatting for all code in Travis * Migrate to travis-ci.com * Fix travis configuration
1 parent d3d6650 commit 3342c03

File tree

10 files changed

+247
-229
lines changed

10 files changed

+247
-229
lines changed

.scalafmt.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
version = 2.0.0-RC8
2+
13
maxColumn = 120
24
docstrings = JavaDoc
35
assumeStandardLibraryStripMargin = true

.travis.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,21 @@ scala: 2.12.8
44

55
jobs:
66
include:
7+
- stage: check
8+
script: sbt scalafmtCheckAll || { echo "[error] Unformatted code found. Please run 'scalafmtAll' and commit the reformatted code."; false; }
9+
name: Code style check (fixed with `sbt scalafmtAll`)
10+
- script: sbt scalafmtSbtCheck || { echo "[error] Unformatted sbt code found. Please run 'scalafmtSbt' and commit the reformatted code."; false; }
11+
name: Build code style check (fixed with `sbt scalafmtSbt`)
712
- stage: test
8-
script: sbt scalafmtCheck scalafmtSbtCheck
9-
name: "Formatting check"
10-
- script: sbt test
11-
name: "Tests run"
13+
script: sbt test
14+
name: Tests run
1215
- stage: publish
1316
script: sbt ^publish
17+
name: Publish artifacts
1418

1519
stages:
20+
- name: check # runs on master commits and PRs
21+
if: NOT tag =~ ^v
1622
- name: test # runs on master commits and PRs
1723
if: NOT tag =~ ^v
1824
- name: publish # runs on main repo master commits or version-tagged commits

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
[bintray]: https://bintray.com/sbt/sbt-plugin-releases/sbt-paradox-apidoc
44
[bintray-badge]: https://api.bintray.com/packages/sbt/sbt-plugin-releases/sbt-paradox-apidoc/images/download.svg
5-
[travis]: https://travis-ci.org/lightbend/sbt-paradox-apidoc
6-
[travis-badge]: https://travis-ci.org/lightbend/sbt-paradox-apidoc.svg?branch=master
5+
[travis]: https://travis-ci.com/lightbend/sbt-paradox-apidoc
6+
[travis-badge]: https://travis-ci.com/lightbend/sbt-paradox-apidoc.svg?branch=master
77

88
A [paradox](https://github.com/lightbend/paradox/) directive that automatically adds links for classes from documentation to scaladoc and javadoc.
99

build.sbt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,14 @@ libraryDependencies ++= Seq(
1515
licenses += ("Apache-2.0", url("http://www.apache.org/licenses/LICENSE-2.0"))
1616
homepage := Some(url("https://github.com/lightbend/sbt-paradox-apidoc"))
1717
scmInfo := Some(
18-
ScmInfo(url("https://github.com/lightbend/sbt-paradox-apidoc"), "git@github.com:lightbend/sbt-paradox-apidoc.git"))
19-
developers += Developer("contributors",
20-
"Contributors",
21-
"https://gitter.im/lightbend/paradox",
22-
url("https://github.com/lightbend/sbt-paradox-apidoc/graphs/contributors"))
18+
ScmInfo(url("https://github.com/lightbend/sbt-paradox-apidoc"), "git@github.com:lightbend/sbt-paradox-apidoc.git")
19+
)
20+
developers += Developer(
21+
"contributors",
22+
"Contributors",
23+
"https://gitter.im/lightbend/paradox",
24+
url("https://github.com/lightbend/sbt-paradox-apidoc/graphs/contributors")
25+
)
2326
organizationName := "Lightbend Inc."
2427
startYear := Some(2018)
2528

project/plugins.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
addSbtPlugin("com.dwijnand" % "sbt-dynver" % "3.3.0")
22
addSbtPlugin("org.foundweekends" % "sbt-bintray" % "0.5.5")
33
addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.2.0")
4-
addSbtPlugin("com.geirsson" % "sbt-scalafmt" % "1.5.1")
4+
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.0.1")

src/main/scala/com/lightbend/paradox/apidoc/ApidocDirective.scala

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -84,21 +84,25 @@ class ApidocDirective(allClassesAndObjects: IndexedSeq[String]) extends InlineDi
8484
null,
8585
attributes,
8686
null,
87-
new DirectiveNode(DirectiveNode.Format.Inline,
88-
group + "doc",
89-
label,
90-
syntheticSource,
91-
node.attributes,
92-
fqcn,
93-
new TextNode(label))
87+
new DirectiveNode(
88+
DirectiveNode.Format.Inline,
89+
group + "doc",
90+
label,
91+
syntheticSource,
92+
node.attributes,
93+
fqcn,
94+
new TextNode(label)
95+
)
9496
)
9597
}
9698

97-
def renderMatches(query: Query,
98-
matches: Seq[String],
99-
node: DirectiveNode,
100-
visitor: Visitor,
101-
printer: Printer): Unit = {
99+
def renderMatches(
100+
query: Query,
101+
matches: Seq[String],
102+
node: DirectiveNode,
103+
visitor: Visitor,
104+
printer: Printer
105+
): Unit = {
102106
val scalaClassSuffix = if (query.linkToObject) "$" else ""
103107

104108
matches.size match {
@@ -119,7 +123,7 @@ class ApidocDirective(allClassesAndObjects: IndexedSeq[String]) extends InlineDi
119123
case n =>
120124
throw new java.lang.IllegalStateException(
121125
s"$n matches found for $query, but not javadsl/scaladsl: ${matches.mkString(", ")}. " +
122-
s"You may want to use the fully qualified class name as @apidoc[fqcn] instead of @apidoc[$query]."
126+
s"You may want to use the fully qualified class name as @apidoc[fqcn] instead of @apidoc[$query]."
123127
)
124128
}
125129
}

src/main/scala/com/lightbend/paradox/apidoc/ApidocPlugin.scala

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,26 +40,27 @@ object ApidocPlugin extends AutoPlugin {
4040
def apidocParadoxGlobalSettings: Seq[Setting[_]] = Seq(
4141
apidocRootPackage := "scala",
4242
paradoxDirectives ++= Def.taskDyn {
43-
val classpath = (fullClasspath in Compile).value.files.map(_.toURI.toURL).toArray
44-
val classLoader = new java.net.URLClassLoader(classpath, this.getClass.getClassLoader)
45-
val scanner = new ClassGraph()
46-
.whitelistPackages(apidocRootPackage.value)
47-
.addClassLoader(classLoader)
48-
.scan()
49-
val allClasses = scanner.getAllClasses.getNames.asScala.toVector
50-
Def.task {
51-
Seq(
52-
{ _: Writer.Context
53-
new ApidocDirective(allClasses)
43+
val classpath = (fullClasspath in Compile).value.files.map(_.toURI.toURL).toArray
44+
val classLoader = new java.net.URLClassLoader(classpath, this.getClass.getClassLoader)
45+
val scanner = new ClassGraph()
46+
.whitelistPackages(apidocRootPackage.value)
47+
.addClassLoader(classLoader)
48+
.scan()
49+
val allClasses = scanner.getAllClasses.getNames.asScala.toVector
50+
Def.task {
51+
Seq(
52+
{ _: Writer.Context
53+
new ApidocDirective(allClasses)
54+
}
55+
)
5456
}
55-
)
56-
}
57-
}.value
57+
}.value
5858
)
5959

6060
def apidocSettings(config: Configuration): Seq[Setting[_]] =
6161
apidocParadoxGlobalSettings ++ inConfig(config)(
62-
Seq(
63-
// scoped settings here
64-
))
62+
Seq(
63+
// scoped settings here
64+
)
65+
)
6566
}

src/test/scala/com.lightbend.paradox/apidoc/ApidocDirectiveSpec.scala

Lines changed: 0 additions & 179 deletions
This file was deleted.

0 commit comments

Comments
 (0)