@@ -34,17 +34,17 @@ class Scala3docArgs extends SettingGroup with CommonScalaSettings:
3434 val revision : Setting [String ] =
3535 StringSetting (" -revision" , " revision" , " Revision (branch or ref) used to build project project" , " " )
3636
37+ def scala3docSpecificSettings : Set [Setting [_]] = Set (sourceLinks, syntax, revision)
38+
3739object Scala3docArgs :
38- def extract (args : List [String ])( using CompilerContext ) =
40+ def extract (args : List [String ], rootCtx : CompilerContext ) : ( Scala3doc . Args , CompilerContext ) =
3941 val inst = new Scala3docArgs
4042 import inst ._
4143 val initialSummary =
4244 ArgsSummary (defaultState, args, errors = Nil , warnings = Nil )
4345 val summary =
4446 processArguments(initialSummary, processAll = true , skipped = Nil )
45-
46- summary.warnings.foreach(report.warning(_))
47- summary.errors.foreach(report.error(_))
47+ val newContext = rootCtx.fresh
4848
4949 extension[T ](arg : Setting [T ]):
5050 def get = arg.valueIn(summary.sstate)
@@ -53,6 +53,19 @@ object Scala3docArgs:
5353 def nonDefault =
5454 if arg.get == arg.default then None else Some (arg.get)
5555
56+ def setInGlobal [T ](s : Setting [T ]) =
57+ s.nonDefault.foreach { newValue =>
58+ newContext.settings.allSettings.find(_ == s).fold(
59+ report.warning(s " Unable to set ${s.name} in global context " )
60+ )(s => newContext.setSetting(s.asInstanceOf [Setting [T ]], newValue))
61+ }
62+
63+ allSettings.filterNot(scala3docSpecificSettings.contains).foreach(setInGlobal)
64+
65+ given CompilerContext = newContext
66+ summary.warnings.foreach(report.warning(_))
67+ summary.errors.foreach(report.error(_))
68+
5669 def parseTastyRoots (roots : String ) =
5770 roots.split(File .pathSeparatorChar).toList.map(new File (_))
5871
@@ -91,7 +104,7 @@ object Scala3docArgs:
91104 report.inform(
92105 s " Generating documenation $printableProjectName in $destFile" )
93106
94- Args (
107+ val docArgs = Args (
95108 projectName.withDefault(" root" ),
96109 dirs,
97110 validFiles,
@@ -103,4 +116,5 @@ object Scala3docArgs:
103116 parseSyntax,
104117 sourceLinks.nonDefault.fold(Nil )(_.split(" ," ).toList),
105118 revision.nonDefault
106- )
119+ )
120+ (docArgs, newContext)
0 commit comments