Skip to content

Commit 2af295e

Browse files
committed
Create scaladoc script and replace scalad
1 parent 190e127 commit 2af295e

File tree

3 files changed

+185
-127
lines changed

3 files changed

+185
-127
lines changed

dist/bin/scalad

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

dist/bin/scaladoc

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
#!/usr/bin/env bash
2+
3+
if [ -z "$PROG_HOME" ] ; then
4+
## resolve links - $0 may be a link to PROG_HOME
5+
PRG="$0"
6+
7+
# need this for relative symlinks
8+
while [ -h "$PRG" ] ; do
9+
ls=`ls -ld "$PRG"`
10+
link=`expr "$ls" : '.*-> \(.*\)$'`
11+
if expr "$link" : '/.*' > /dev/null; then
12+
PRG="$link"
13+
else
14+
PRG="`dirname "$PRG"`/$link"
15+
fi
16+
done
17+
18+
saveddir=`pwd`
19+
20+
PROG_HOME=`dirname "$PRG"`/..
21+
22+
# make it fully qualified
23+
PROG_HOME=`cd "$PROG_HOME" && pwd`
24+
25+
cd "$saveddir"
26+
fi
27+
28+
source "$PROG_HOME/bin/common"
29+
30+
default_java_opts="-Xmx768m -Xms768m"
31+
withCompiler=true
32+
33+
CompilerMain=dotty.tools.dotc.Main
34+
DecompilerMain=dotty.tools.dotc.decompiler.Main
35+
ReplMain=dotty.tools.repl.Main
36+
ScriptingMain=dotty.tools.scripting.Main
37+
38+
PROG_NAME=$CompilerMain
39+
40+
addJava () {
41+
java_args+=("'$1'")
42+
}
43+
addScala () {
44+
scala_args+=("'$1'")
45+
}
46+
addResidual () {
47+
residual_args+=("'$1'")
48+
}
49+
addScripting () {
50+
scripting_args+=("'$1'")
51+
}
52+
53+
classpathArgs () {
54+
CLASS_PATH=""
55+
CLASS_PATH+="$(find_lib "*scaladoc*")$PSEP"
56+
CLASS_PATH+="$(find_lib "*scala3-compiler*")$PSEP"
57+
CLASS_PATH+="$(find_lib "*scala3-interfaces*")$PSEP"
58+
CLASS_PATH+="$(find_lib "*scala3-library*")$PSEP"
59+
CLASS_PATH+="$(find_lib "*tasty-core*")$PSEP"
60+
CLASS_PATH+="$(find_lib "*scala3-tasty-inspector*")$PSEP"
61+
CLASS_PATH+="$(find_lib "*flexmark-0*")$PSEP"
62+
CLASS_PATH+="$(find_lib "*flexmark-html-parser*")$PSEP"
63+
CLASS_PATH+="$(find_lib "*flexmark-ext-anchorlink*")$PSEP"
64+
CLASS_PATH+="$(find_lib "*flexmark-ext-autolink*")$PSEP"
65+
CLASS_PATH+="$(find_lib "*flexmark-ext-emoji*")$PSEP"
66+
CLASS_PATH+="$(find_lib "*flexmark-ext-gfm-strikethrough*")$PSEP"
67+
CLASS_PATH+="$(find_lib "*flexmark-ext-gfm-tables*")$PSEP"
68+
CLASS_PATH+="$(find_lib "*flexmark-ext-gfm-tasklist*")$PSEP"
69+
CLASS_PATH+="$(find_lib "*flexmark-ext-wikilink*")$PSEP"
70+
CLASS_PATH+="$(find_lib "*flexmark-ext-yaml-front-matter*")$PSEP"
71+
CLASS_PATH+="$(find_lib "*liqp*")$PSEP"
72+
CLASS_PATH+="$(find_lib "*jsoup*")$PSEP"
73+
CLASS_PATH+="$(find_lib "*jackson-dataformat-yaml*")$PSEP"
74+
CLASS_PATH+="$(find_lib "*scala-asm*")$PSEP"
75+
CLASS_PATH+="$(find_lib "*compiler-interface*")$PSEP"
76+
CLASS_PATH+="$(find_lib "*jline-reader*")$PSEP"
77+
CLASS_PATH+="$(find_lib "*jline-terminal-3*")$PSEP"
78+
CLASS_PATH+="$(find_lib "*jline-terminal-jna*")$PSEP"
79+
CLASS_PATH+="$(find_lib "*flexmark-util*")$PSEP"
80+
CLASS_PATH+="$(find_lib "*flexmark-formatter*")$PSEP"
81+
CLASS_PATH+="$(find_lib "*autolink-0.6*")$PSEP"
82+
CLASS_PATH+="$(find_lib "*flexmark-jira-converter*")$PSEP"
83+
CLASS_PATH+="$(find_lib "*antlr-3*")$PSEP"
84+
CLASS_PATH+="$(find_lib "*jackson-annotations*")$PSEP"
85+
CLASS_PATH+="$(find_lib "*jackson-core*")$PSEP"
86+
CLASS_PATH+="$(find_lib "*jackson-databind*")$PSEP"
87+
CLASS_PATH+="$(find_lib "*snakeyaml*")$PSEP"
88+
CLASS_PATH+="$(find_lib "*scala-library*")$PSEP"
89+
CLASS_PATH+="$(find_lib "*protobuf-java*")$PSEP"
90+
CLASS_PATH+="$(find_lib "*util-interface*")$PSEP"
91+
CLASS_PATH+="$(find_lib "*jna-5*")$PSEP"
92+
CLASS_PATH+="$(find_lib "*flexmark-ext-tables*")$PSEP"
93+
CLASS_PATH+="$(find_lib "*flexmark-ext-ins*")$PSEP"
94+
CLASS_PATH+="$(find_lib "*flexmark-ext-superscript*")$PSEP"
95+
CLASS_PATH+="$(find_lib "*antlr-runtime*")$PSEP"
96+
CLASS_PATH+="$(find_lib "*ST4*")"
97+
98+
jvm_cp_args="-classpath \"$CLASS_PATH\""
99+
}
100+
101+
in_scripting_args=false
102+
while [[ $# -gt 0 ]]; do
103+
case "$1" in
104+
--) shift; for arg; do addResidual "$arg"; done; set -- ;;
105+
-h|-help) help=true && shift ;;
106+
-v|-verbose) verbose=true && addScala "-verbose" && shift ;;
107+
-debug) DEBUG="$DEBUG_STR" && shift ;;
108+
-q|-quiet) quiet=true && shift ;;
109+
110+
-colors) colors=true && shift ;;
111+
-no-colors) unset colors && shift ;;
112+
# break out -D and -J options and add them to java_args so
113+
# they reach the JVM in time to do some good. The -D options
114+
# will be available as system properties.
115+
-D*) addJava "$1" && shift ;;
116+
-J*) addJava "${1:2}" && shift ;;
117+
*) if [ $in_scripting_args == false ]; then
118+
addResidual "$1"
119+
else
120+
addScripting "$1"
121+
fi
122+
shift
123+
;;
124+
esac
125+
done
126+
127+
classpathArgs
128+
129+
eval exec "\"$JAVACMD\"" \
130+
${JAVA_OPTS:-$default_java_opts} \
131+
"$DEBUG" \
132+
"${java_args[@]}" \
133+
"$jvm_cp_args" \
134+
"dotty.tools.scaladoc.Main" \
135+
"${scala_args[@]}" \
136+
"${residual_args[@]}" \
137+
"$scripting_string"
138+
exit $?

project/Build.scala

Lines changed: 47 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1496,20 +1496,23 @@ object Build {
14961496
}
14971497

14981498
def asScaladoc: Project = {
1499-
def generateDocumentation(targets: String, name: String, outDir: String, ref: String, params: String = "") = Def.taskDyn {
1499+
def generateDocumentation(targets: Seq[String], name: String, outDir: String, ref: String, params: Seq[String] = Nil) =
1500+
Def.taskDyn {
1501+
val distLocation = pack.in(dist).value
15001502
val projectVersion = version.value
15011503
IO.createDirectory(file(outDir))
15021504
val scala3version = stdlibVersion(Bootstrapped)
15031505
// TODO add versions etc.
15041506
val srcManaged = s"out/bootstrap/stdlib-bootstrapped/scala-$baseVersion/src_managed/main/scala-library-src"
1505-
val sourceLinks = s"-source-links:$srcManaged=github://scala/scala/v$scala3version#src/library -source-links:github://lampepfl/dotty"
1506-
val revision = s"-revision $ref -project-version $projectVersion"
1507-
val cmd = s""" -d $outDir -project "$name" $sourceLinks $revision $params $targets"""
1508-
run.in(Compile).toTask(cmd)
1509-
}
1507+
val sourceLinks = s"-source-links:$srcManaged=github://scala/scala/v$scala3version#src/library-source-links:github://lampepfl/dotty"
1508+
val revision = Seq("-revision", ref, "-project-version", projectVersion)
1509+
val cmd = Seq("-d", outDir, "-project", name, sourceLinks) ++ revision ++ params ++ targets
1510+
import _root_.scala.sys.process._
1511+
Def.task((s"$distLocation/bin/scaladoc" +: cmd).!)
1512+
}
15101513

15111514
def joinProducts(products: Seq[java.io.File]): String =
1512-
products.iterator.map(_.getAbsolutePath.toString).mkString(" ")
1515+
products.iterator.map(_.getAbsolutePath).map(p => s"'$p'").mkString(" ")
15131516

15141517
val flexmarkVersion = "0.42.12"
15151518

@@ -1520,12 +1523,16 @@ object Build {
15201523
baseDirectory.in(run) := baseDirectory.in(ThisBuild).value,
15211524
generateSelfDocumentation := Def.taskDyn {
15221525
generateDocumentation(
1523-
classDirectory.in(Compile).value.getAbsolutePath,
1526+
classDirectory.in(Compile).value.getAbsolutePath :: Nil,
15241527
"scaladoc", "scaladoc/output/self", VersionUtil.gitHash,
1525-
"-siteroot scaladoc/documentation -project-logo scaladoc/documentation/logo.svg " +
1526-
"-external-mappings:" +
1527-
".*scala.*::scaladoc3::http://dotty.epfl.ch/api/," +
1528-
".*java.*::javadoc::https://docs.oracle.com/javase/8/docs/api/"
1528+
Seq(
1529+
"-siteroot", "scaladoc/documentation",
1530+
"-project-logo", "scaladoc/documentation/logo.svg",
1531+
"-external-mappings:" +
1532+
".*scala.*::scaladoc3::http://dotty.epfl.ch/api/," +
1533+
".*java.*::javadoc::https://docs.oracle.com/javase/8/docs/api/"
1534+
)
1535+
15291536
)
15301537
}.value,
15311538
generateScalaDocumentation := Def.inputTaskDyn {
@@ -1539,7 +1546,7 @@ object Build {
15391546
(`tasty-core-bootstrapped`/Compile/products).value,
15401547
).flatten
15411548

1542-
val roots = joinProducts(dottyJars)
1549+
val roots = dottyJars.map(_.getAbsolutePath)
15431550

15441551
val managedSources =
15451552
(`stdlib-bootstrapped`/Compile/sourceManaged).value / "scala-library-src"
@@ -1555,27 +1562,36 @@ object Build {
15551562
IO.write(dest / "CNAME", "dotty.epfl.ch")
15561563
}.dependsOn(generateDocumentation(
15571564
roots, "Scala 3", dest.getAbsolutePath, "master",
1558-
// contains special definitions which are "transplanted" elsewhere
1559-
// and which therefore confuse Scaladoc when accessed from this pkg
1560-
"-skip-by-id:scala.runtime.stdLibPatches " +
1561-
// MatchCase is a special type that represents match type cases,
1562-
// Reflect doesn't expect to see it as a standalone definition
1563-
// and therefore it's easier just not to document it
1564-
"-skip-by-id:scala.runtime.MatchCase " +
1565-
"-skip-by-regex:.+\\.internal($|\\..+) " +
1566-
"-skip-by-regex:.+\\.impl($|\\..+) " +
1567-
"-comment-syntax wiki -siteroot docs -project-logo docs/logo.svg " +
1568-
"-external-mappings:.*java.*::javadoc::https://docs.oracle.com/javase/8/docs/api/ " +
1569-
"-social-links:github::https://github.com/lampepfl/dotty," +
1570-
"gitter::https://gitter.im/scala/scala," +
1571-
"twitter::https://twitter.com/scala_lang " +
1572-
s"-source-links:$stdLibRoot=github://scala/scala/v${stdlibVersion(Bootstrapped)}#src/library " +
1573-
s"-doc-root-content $docRootFile"
1574-
))
1565+
Seq(
1566+
// contains special definitions which are "transplanted" elsewhere
1567+
// and which therefore confuse Scaladoc when accessed from this pkg
1568+
"-skip-by-id:scala.runtime.stdLibPatches",
1569+
// MatchCase is a special type that represents match type cases,
1570+
// Reflect doesn't expect to see it as a standalone definition
1571+
// and therefore it's easier just not to document it
1572+
"-skip-by-id:scala.runtime.MatchCase",
1573+
"-skip-by-regex:.+\\.internal($|\\..+)",
1574+
"-skip-by-regex:.+\\.impl($|\\..+)",
1575+
"-comment-syntax", "wiki",
1576+
"-siteroot", "docs",
1577+
"-project-logo", "docs/logo.svg",
1578+
"-external-mappings:.*java.*::javadoc::https://docs.oracle.com/javase/8/docs/api/",
1579+
"-social-links:" +
1580+
"github::https://github.com/lampepfl/dotty," +
1581+
"gitter::https://gitter.im/scala/scala," +
1582+
"twitter::https://twitter.com/scala_lang",
1583+
s"-source-links:$stdLibRoot=github://scala/scala/v${stdlibVersion(Bootstrapped)}#src/library",
1584+
"-doc-root-content", docRootFile.toString
1585+
)
1586+
))
15751587
}.evaluated,
15761588

15771589
generateTestcasesDocumentation := Def.taskDyn {
1578-
generateDocumentation(Build.testcasesOutputDir.in(Test).value, "scaladoc testcases", "scaladoc/output/testcases", "master")
1590+
generateDocumentation(
1591+
Build.testcasesOutputDir.in(Test).value :: Nil,
1592+
"scaladoc testcases",
1593+
"scaladoc/output/testcases",
1594+
"master")
15791595
}.value,
15801596

15811597
buildInfoKeys in Test := Seq[BuildInfoKey](

0 commit comments

Comments
 (0)