Skip to content

Commit fc8abc6

Browse files
committed
Remove preprocessor
1 parent 2856264 commit fc8abc6

File tree

11 files changed

+16
-152
lines changed

11 files changed

+16
-152
lines changed

build.sbt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ val scaladoc = Build.scaladoc
2222
val `scaladoc-testcases` = Build.`scaladoc-testcases`
2323
val `scaladoc-js-common` = Build.`scaladoc-js-common`
2424
val `scaladoc-js-main` = Build.`scaladoc-js-main`
25-
val `scaladoc-js-markdown` = Build.`scaladoc-js-markdown`
2625
val `scaladoc-js-contributors` = Build.`scaladoc-js-contributors`
2726
val `scala3-bench-run` = Build.`scala3-bench-run`
2827
val dist = Build.dist

docs/docs/usage/ide-support.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
layout: doc-page
33
title: "IDE support for Scala 3"
4+
movedTo: https://docs.scala-lang.org/scala3/getting-started.html
45
---
56

67
This page is deprecated. Please go to the [getting-started](https://docs.scala-lang.org/scala3/getting-started.html)

project/Build.scala

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,7 +1251,6 @@ object Build {
12511251
// Note: the two tasks below should be one, but a bug in Tasty prevents that
12521252
val generateScalaDocumentation = inputKey[Unit]("Generate documentation for dotty lib")
12531253
val generateTestcasesDocumentation = taskKey[Unit]("Generate documentation for testcases, usefull for debugging tests")
1254-
val renderScaladocScalajsToFile = inputKey[Unit]("Copy the output of the scaladoc js files")
12551254

12561255
lazy val `scaladoc-testcases` = project.in(file("scaladoc-testcases")).
12571256
dependsOn(`scala3-compiler-bootstrapped`).
@@ -1260,9 +1259,8 @@ object Build {
12601259

12611260
/**
12621261
* Collection of projects building targets for scaladoc, these are:
1263-
* - common - common module for javascript shared among html and markdown outpu
1262+
* - common - common module for javascript
12641263
* - main - main target for default scaladoc producing html webpage
1265-
* - markdown - companion js for preprocessing features. Can be later used with some templating engine
12661264
* - contributors - not related project to any of forementioned modules. Used for presenting contributors for static site.
12671265
* Made as an indepented project to be scaladoc-agnostic.
12681266
*/
@@ -1279,14 +1277,6 @@ object Build {
12791277
Test / fork := false
12801278
)
12811279

1282-
lazy val `scaladoc-js-markdown` = project.in(file("scaladoc-js/markdown")).
1283-
enablePlugins(DottyJSPlugin).
1284-
dependsOn(`scaladoc-js-common`).
1285-
settings(
1286-
scalaJSUseMainModuleInitializer := true,
1287-
Test / fork := false
1288-
)
1289-
12901280
lazy val `scaladoc-js-contributors` = project.in(file("scaladoc-js/contributors")).
12911281
enablePlugins(DottyJSPlugin).
12921282
dependsOn(`scala3-library-bootstrappedJS`).
@@ -1434,23 +1424,6 @@ object Build {
14341424
)
14351425
}.value,
14361426

1437-
renderScaladocScalajsToFile := Def.inputTask {
1438-
val extraArgs = spaceDelimited("<arg>").parsed
1439-
val (destJS, destCSS, csses) = extraArgs match {
1440-
case js :: css :: tail => (js, css, tail)
1441-
case js :: Nil => (js, "", Nil)
1442-
case _ => throw new IllegalArgumentException("No js destination provided")
1443-
}
1444-
val jsDestinationFile: File = Paths.get(destJS).toFile
1445-
sbt.IO.copyFile((`scaladoc-js-markdown` / Compile / fullOptJS).value.data, jsDestinationFile)
1446-
csses.map { file =>
1447-
val cssDesitnationFile = Paths.get(destCSS).toFile / file
1448-
val cssSourceFile = (`scaladoc-js-markdown` / Compile / resourceDirectory).value / file
1449-
sbt.IO.copyFile(cssSourceFile, cssDesitnationFile)
1450-
cssDesitnationFile
1451-
}
1452-
}.evaluated,
1453-
14541427
Test / buildInfoKeys := Seq[BuildInfoKey](
14551428
(Test / Build.testcasesOutputDir),
14561429
(Test / Build.testcasesSourceRoot),

scaladoc-js/markdown/src/Main.scala

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

scaladoc/src/dotty/tools/scaladoc/Scaladoc.scala

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ object Scaladoc:
6060
generateInkuire : Boolean = false,
6161
apiSubdirectory : Boolean = false,
6262
scastieConfiguration: String = "",
63-
projectFormat: String = "html",
6463
defaultTemplate: Option[String] = None,
6564
)
6665

@@ -239,7 +238,6 @@ object Scaladoc:
239238
generateInkuire.get,
240239
apiSubdirectory.get,
241240
scastieConfiguration.get,
242-
projectFormat.get,
243241
defaultTemplate.nonDefault
244242
)
245243
(Some(docArgs), newContext)
@@ -248,11 +246,6 @@ object Scaladoc:
248246
private [scaladoc] def run(args: Args)(using ctx: CompilerContext): DocContext =
249247
given docContext: DocContext = new DocContext(args, ctx)
250248
val module = ScalaModuleProvider.mkModule()
251-
252-
val renderer = args.projectFormat match
253-
case "html" => new dotty.tools.scaladoc.renderers.HtmlRenderer(module.rootPackage, module.members)
254-
case "md" => new dotty.tools.scaladoc.renderers.MarkdownRenderer(module.rootPackage, module.members)
255-
256-
renderer.render()
249+
new dotty.tools.scaladoc.renderers.HtmlRenderer(module.rootPackage, module.members).render()
257250
report.inform("generation completed successfully")
258251
docContext

scaladoc/src/dotty/tools/scaladoc/ScaladocSettings.scala

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -125,16 +125,6 @@ class ScaladocSettings extends SettingGroup with AllScalaSettings:
125125
val scastieConfiguration: Setting[String] =
126126
StringSetting("-scastie-configuration", "Scastie configuration", "Additional configuration passed to Scastie in code snippets", "")
127127

128-
val projectFormat: Setting[String] =
129-
ChoiceSetting(
130-
"-format",
131-
"format of the static site output",
132-
"Format of the static site output. The default value is html, which converts all static articles into a webpage. " +
133-
"The md format only preprocess markdown files and should not be used as a direct output, but rather as a sources generator for an outer templating engine like Jekyll",
134-
List("html", "md"),
135-
"html"
136-
)
137-
138128
val defaultTemplate: Setting[String] =
139129
StringSetting(
140130
"-default-template",

scaladoc/src/dotty/tools/scaladoc/renderers/SiteRenderer.scala

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -56,24 +56,11 @@ trait SiteRenderer(using DocContext) extends Locations:
5656
else
5757
processLocalLink(str)
5858

59-
summon[DocContext].args.projectFormat match
60-
case "html" =>
61-
val document = Jsoup.parse(content.resolved.code)
62-
document.select("a").forEach(element =>
63-
element.attr("href", processLocalLinkWithGuard(element.attr("href")))
64-
)
65-
document.select("img").forEach { element =>
66-
element.attr("src", processLocalLink(element.attr("src")))
67-
} // foreach does not work here. Why?
68-
raw(document.outerHtml())
69-
case "md" =>
70-
val links = """(?<!\\!)\[(.*)\\]\\((.*)\\)""".r
71-
val imgs = """!\\[(.*)\\]\\((.*)\\)""".r
72-
73-
raw(links.replaceAllIn(
74-
imgs.replaceAllIn(
75-
content.resolved.code,
76-
m => s"[${m.group(1)}](${processLocalLink(m.group(2))})"
77-
),
78-
m => s"[${m.group(1)}](${processLocalLinkWithGuard(m.group(2))})"
79-
))
59+
val document = Jsoup.parse(content.resolved.code)
60+
document.select("a").forEach(element =>
61+
element.attr("href", processLocalLinkWithGuard(element.attr("href")))
62+
)
63+
document.select("img").forEach { element =>
64+
element.attr("src", processLocalLink(element.attr("src")))
65+
} // foreach does not work here. Why?
66+
raw(document.outerHtml())

scaladoc/src/dotty/tools/scaladoc/site/FrontMatterRenderer.scala

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

scaladoc/src/dotty/tools/scaladoc/site/common.scala

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,7 @@ def defaultMarkdownOptions(using ctx: StaticSiteContext): DataHolder =
3737
YamlFrontMatterExtension.create(),
3838
StrikethroughExtension.create(),
3939
WikiLinkExtension.create(),
40-
(ctx.args.projectFormat match
41-
case "html" => tasty.comments.markdown.SnippetRenderingExtension
42-
case "md" => tasty.comments.markdown.SnippetFormattingExtension
43-
),
40+
tasty.comments.markdown.SnippetRenderingExtension
4441
))
4542

4643
def emptyTemplate(file: File, title: String): TemplateFile = TemplateFile(

scaladoc/src/dotty/tools/scaladoc/site/templates.scala

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ case class TemplateFile(
9292
if (ctx.resolving.contains(file.getAbsolutePath))
9393
throw new RuntimeException(s"Cycle in templates involving $file: ${ctx.resolving}")
9494

95-
val layoutTemplate = layout.filter(_ => ssctx.args.projectFormat == "html").map(name =>
95+
val layoutTemplate = layout.map(name =>
9696
ctx.layouts.getOrElse(name, throw new RuntimeException(s"No layouts named $name in ${ctx.layouts}")))
9797

9898
def asJavaElement(o: Object): Object = o match
@@ -105,24 +105,17 @@ case class TemplateFile(
105105
// Library requires mutable maps..
106106
val mutableProperties = new JHashMap(ctx.properties.transform((_, v) => asJavaElement(v)).asJava)
107107

108-
val rendered = ssctx.args.projectFormat match
109-
case "html" => Template.parse(this.rawCode).render(mutableProperties)
110-
case "md" => this.rawCode
108+
val rendered = Template.parse(this.rawCode).render(mutableProperties)
111109

112110
// We want to render markdown only if next template is html
113111
val code = if (isHtml || layoutTemplate.exists(!_.isHtml)) rendered else
114112
// Snippet compiler currently supports markdown only
115113
val parser: Parser = Parser.builder(defaultMarkdownOptions).build()
116114
val parsedMd = parser.parse(rendered)
117115
val processed = FlexmarkSnippetProcessor.processSnippets(parsedMd, None, snippetCheckingFunc, withContext = false)(using ssctx.outerCtx)
116+
HtmlRenderer.builder(defaultMarkdownOptions).build().render(processed)
118117

119-
ssctx.args.projectFormat match
120-
case "html" => HtmlRenderer.builder(defaultMarkdownOptions).build().render(processed)
121-
case "md" => FrontMatterRenderer.render(ctx.properties ++ settings) +
122-
Formatter.builder(defaultMarkdownOptions).build().render(processed)
123-
124-
125-
if layoutTemplate.isEmpty || ssctx.args.projectFormat == "md" then
118+
if layoutTemplate.isEmpty then
126119
ResolvedPage(code, resources ++ ctx.resources)
127120
else
128121
layoutTemplate.get.resolveInner(ctx.nest(code, file, resources))

scaladoc/src/dotty/tools/scaladoc/tasty/comments/markdown/SnippetFormattingExtension.scala

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

0 commit comments

Comments
 (0)