diff --git a/docs/docs/usage/scaladoc/settings.md b/docs/docs/usage/scaladoc/settings.md index d83f59472ffe..4881c9790d4e 100644 --- a/docs/docs/usage/scaladoc/settings.md +++ b/docs/docs/usage/scaladoc/settings.md @@ -13,8 +13,12 @@ If you want to know what is current state of compatibility with scaladoc old fla ## Providing settings -Supply scaladoc settings as command-line arguments, e.g., `scaladoc -d output -project my-project target/scala-3.0.0-RC2/classes`. If called from sbt, -update the value of `Compile / doc / scalacOptions`, e. g. `Compile / doc / scalacOptions ++= Seq("-d", "output", "-project", "my-project")` +Supply scaladoc settings as command-line arguments, e.g., `scaladoc -d output -project my-project target/scala-3.0.0-RC2/classes`. If called from sbt, update the value of `Compile / doc / scalacOptions` and `Compile / doc / target` respectively, e. g. + +``` +Compile / doc / target ++= Seq("-d", "output") +Compile / doc / scalacOptions ++= Seq("-project", "my-project") +``` ## Overview of all available settings @@ -118,6 +122,10 @@ A base URL to use as prefix and add `canonical` URLs to all pages. The canonical A directory containing static files from which to generate documentation. Default directory is `./docs` +##### -no-link-warnings + +Suppress warnings for ambiguous or incorrect links in members’ lookup. Doesn't affect warnings for incorrect links of assets etc. + ##### -versions-dictionary-url A URL pointing to a JSON document containing a dictionary: `version label -> documentation location`. @@ -134,3 +142,39 @@ Example JSON file: } ``` +##### -snippet-compiler + +Snippet compiler arguments provide a way to configure snippet type checking. + +This setting accepts a list of arguments in the format: +args := arg{,arg} +arg := [path=]flag +where `path` is a prefix of the path to source files where snippets are located and `flag` is the mode in which snippets will be type checked. + +If the path is not present, the argument will be used as the default for all unmatched paths. + +Available flags: +compile - Enables snippet checking. +nocompile - Disables snippet checking. +fail - Enables snippet checking, asserts that snippet doesn't compile. + +The fail flag comes in handy for snippets that present that some action would eventually fail during compilation, e. g. [Opaques page](docs/reference/other-new-features/opaques.html) + +Example usage: + +`-snippet-compiler:my/path/nc=nocompile,my/path/f=fail,compile` + +Which means: + +all snippets in files under directory `my/path/nc` should not be compiled at all +all snippets in files under directory `my/path/f` should fail during compilation +all other snippets should compile successfully + +##### -Ysnippet-compiler-debug + +Setting this option makes snippet compiler print the snippet as it is compiled (after wrapping). + +##### -Ydocument-synthetic-types + +Include pages providing documentation for the intrinsic types (e. g. Any, Nothing) to the docs. The setting is useful only for stdlib because scaladoc for Scala 3 relies on TASTy files, but we cannot provide them for intrinsic types since they are embedded in the compiler. +All other users should not concern with this setting. diff --git a/docs/docs/usage/scaladoc/staticSite.md b/docs/docs/usage/scaladoc/staticSite.md index f94318497729..f9d61342cba7 100644 --- a/docs/docs/usage/scaladoc/staticSite.md +++ b/docs/docs/usage/scaladoc/staticSite.md @@ -2,13 +2,13 @@ title: Static documentation --- -# {{ page.title}} +# {{ page.title }} -Scaladoc is able to generate static sites, known from [Jekyll](http://jekyllrb.com/) or [Docusaurus](https://docusaurus.io/). -Having a combined tool allows to provide interaction between static documentation and API, thus allowing the two to blend naturally. +Scaladoc can generate static sites, known from [Jekyll](http://jekyllrb.com/) or [Docusaurus](https://docusaurus.io/). +Having a combined tool allows providing interaction between static documentation and API, thus allowing the two to blend naturally. Creating a site is just as simple as in Jekyll. The site root contains the -layout of the site and all files placed there will be either considered static, +the layout of the site and all files placed there will be either considered static, or processed for template expansion. The files that are considered for template expansion must end in `*.{html,md}` @@ -29,26 +29,33 @@ index.html docs/getting-started.html ``` -Scaladoc can transform both files and directories (to organize your documentation into tree-like structure). By default directories has title based on file name and has empty content. There is an option to include `index.html` or `index.md` (not both) to provide both content and properties like title (see [Properties](#properties)). +Scaladoc can transform both files and directories (to organize your documentation into a tree-like structure). By default, directories have a title based on the file name and have empty content. It is possible to provide index pages for each section by creating `index.html` or `index.md` (not both) in the dedicated directory. ## Properties Scaladoc uses the [Liquid](https://shopify.github.io/liquid/) templating engine -and provides a number of custom filters and tags specific to Scala +and provides several custom filters and tags specific to Scala documentation. In Scaladoc, all templates can contain YAML front-matter. The front-matter is parsed and put into the `page` variable available in templates via Liquid. -Scaladoc uses some predefined properties to controls some aspect of page. +Example front-matter +``` +--- +title: My custom title +--- +``` + +Scaladoc uses some predefined properties to controls some aspects of page. Predefined properties: - - **title** provide page title that will be used in navigation and html metadata. - - **extraCss** additional `.css` files that will be included in this page. Paths should be relative to documentation root. **This setting is not exported to template engine.** - - **extraJs** additional `.js` files that will be included in this page. Paths should be relative to documentation root. **This setting is not exported to template engine.** - - **hasFrame** when set to `false` page will not include default layout (navigation, breadcrumbs etc.) but only token html wrapper to provide metadata and resources (js and css files). **This setting is not exported to template engine.** -- **layout** - predefined layout to use, see below. **This setting is not exported to template engine.** + - **title** provide page title that will be used in navigation and HTML metadata. + - **extraCss** additional `.css` files that will be included in this page. Paths should be relative to the documentation root. **This setting is not exported to the template engine.** + - **extraJs** additional `.js` files that will be included in this page. Paths should be relative to the documentation root. **This setting is not exported to the template engine.** + - **hasFrame** when set to `false` page will not include default layout (navigation, breadcrumbs, etc.) but only token HTML wrapper to provide metadata and resources (js and css files). **This setting is not exported to the template engine.** +- **layout** - predefined layout to use, see below. **This setting is not exported to the template engine.** ## Using existing Templates and Layouts @@ -99,23 +106,44 @@ Scaladoc by default uses layout of files in `docs` directory to create table of ```yaml sidebar: - title: Blog - - title: Docs - url: docs/index.html - - title: Usage + - title: My title + page: my-page1.md + - page: my-page2.md + - page: my-page3/subsection + - title: Reference subsection: - - title: Dottydoc - url: docs/usage/dottydoc.html - - title: sbt-projects - url: docs/usage/sbt-projects.html + - page: my-page3.md + - index: my-page4/index.md + subsection: + - page: my-page4/my-page4.md + - title: My subsection + index: my-page5/index.md + subsection: + - page: my-page5/my-page5.md + - index: my-page6/index.md + subsection: + - index: my-page6/my-page6/index.md + subsection: + - page: my-page6/my-page6/my-page6.md ``` -The `sidebar` key is mandatory, as well as `title` for each element. The -default table of contents allows you to have subsections - albeit the current -depth limit is 2 however it accepts both files and directories and latter can be used to provide deeper structures. +The `sidebar` key is mandatory. +On each level, you can have three different types of entries: `page`, `blog` or `subsection`. + +`page` is a leaf of the structure and accepts the following attributes: +- `title` (optional) - title of the page +- `page` (mandatory) - path to the file that will represent the page, it can be either html or markdown file to be rendered, there is also the possibility to pass the `directory` path. If so, the scaladoc will render the directory and all its content as if there were no `sidebar.yml` basing on its tree structure and index files. + +The `page` property -The items must provide either `subsection` or `url` but not both at once! -The only exception is `Blog` which is only a `title` and behaves differently. -You can read more about blog [here](blog.md). +`subsection` accepts nested nodes, these can be either pages or subsections, which allow you to create tree-like navigation. The attributes are: +- `title` (optional) - title of the page +- `index` (optional) - path to the file that will represent the index file of the subsection, it can be either html or markdown file to be rendered +- `subsection` (mandatory) - nested nodes, can be either pages or subsections + +In `subsection`s, you can omit `title` or `index`, however not specifying any of these properties prevents you from specifying the title of the section. + +`blog` is a special node represented by simple entry `- title: Blog` with no other attributes. All your blog posts will be automatically linked under this section. You can read more about the blog [here](blog.md). ``` ├── blog @@ -126,10 +154,29 @@ You can read more about blog [here](blog.md). └── sidebar.yml ``` +## Hierarchy of title + +If the title is specified multiple times, the priority is as follows (from highest to lowest priority): + +#### Page + +1. `title` from the `front-matter` of the markdown/html file +2. `title` property from the `sidebar.yml` property +3. filename + +#### Subsection + +1. `title` from the `front-matter` of the markdown/html index file +2. `title` property from the `sidebar.yml` property +3. filename + +Note that if you skip the `index` file in your tree structure or you don't specify the `title` in the frontmatter, there will be given a generic name `index`. The same applies when using `sidebar.yml` but not specifying `title` nor `index`, just a subsection. Again, a generic `index` name will appear. + + ## Static resources You can attach static resources (pdf, images) to your documentation by using two dedicated directories: -`resources` and `images`. When you upload your assests under any of these directories you can reference them in markdown +`resources` and `images`. After placing your assets under any of these directories, you can reference them in markdown as if they were relatively at the same level. For example, consider the following situation: @@ -151,5 +198,5 @@ For example, consider the following situation: You can refer to the assets from within any of the files using markdown links: ``` -This is my blogpost. Here is the image ![](my_image.png) and here is my [pdf](my_file.pdf) +This is my blog post. Here is the image ![](my_image.png) and here is my [pdf](my_file.pdf) ``` diff --git a/docs/sidebar.yml b/docs/sidebar.yml index e62606aed0e7..471382fa292f 100644 --- a/docs/sidebar.yml +++ b/docs/sidebar.yml @@ -1,254 +1,142 @@ sidebar: - - title: Blog - - title: Usage - subsection: - - title: Getting Started - url: docs/usage/getting-started.html - - title: sbt-projects - url: docs/usage/sbt-projects.html - - title: IDE support for Dotty - url: docs/usage/ide-support.html - - title: Worksheet mode in Dotty IDE - url: docs/usage/worksheet-mode.html - - title: Language Versions - url: docs/usage/language-versions.html - - title: cbt-projects - url: docs/usage/cbt-projects.html - - title: Scaladoc - url: docs/usage/scaladoc - - title: Reference - subsection: - - title: Overview - url: docs/reference/overview.html - - title: New Types - subsection: - - title: Intersection types - url: docs/reference/new-types/intersection-types.html - - title: Union types - url: docs/reference/new-types/union-types.html - - title: Type lambdas - url: docs/reference/new-types/type-lambdas.html - - title: Match types - url: docs/reference/new-types/match-types.html - - title: Dependent Function Types - url: docs/reference/new-types/dependent-function-types.html - - title: Polymorphic Function Types - url: docs/reference/new-types/polymorphic-function-types.html - - title: Enums - subsection: - - title: Enumerations - url: docs/reference/enums/enums.html - - title: Algebraic Data Types - url: docs/reference/enums/adts.html - - title: Translation - url: docs/reference/enums/desugarEnums.html - - title: Contextual Abstractions - subsection: - - title: Overview - url: docs/reference/contextual/motivation.html - - title: Given Instances - url: docs/reference/contextual/givens.html - - title: Using Clauses - url: docs/reference/contextual/using-clauses.html - - title: Context Bounds - url: docs/reference/contextual/context-bounds.html - - title: Given Imports - url: docs/reference/contextual/given-imports.html - - title: Extension Methods - url: docs/reference/contextual/extension-methods.html - - title: Implementing Type classes - url: docs/reference/contextual/type-classes.html - - title: Type Class Derivation - url: docs/reference/contextual/derivation.html - - title: Multiversal Equality - url: docs/reference/contextual/multiversal-equality.html - - title: Context Functions - url: docs/reference/contextual/context-functions.html - - title: Implicit Conversions - url: docs/reference/contextual/conversions.html - - title: By-Name Context Parameters - url: docs/reference/contextual/by-name-context-parameters.html - - title: Relationship with Scala 2 Implicits - url: docs/reference/contextual/relationship-implicits.html - - title: Metaprogramming - subsection: - - title: Overview - url: docs/reference/metaprogramming/toc.html - - title: Inline - url: docs/reference/metaprogramming/inline.html - - title: Compile-time ops - url: docs/reference/metaprogramming/compiletime-ops.html - - title: Macros - url: docs/reference/metaprogramming/macros.html - - title: Runtime Staging - url: docs/reference/metaprogramming/staging.html - - title: Reflection - url: docs/reference/metaprogramming/reflection.html - - title: TASTy Inspection - url: docs/reference/metaprogramming/tasty-inspect.html - - title: Other New Features - subsection: - - title: Trait Parameters - url: docs/reference/other-new-features/trait-parameters.html - - title: Transparent Traits - url: docs/reference/other-new-features/transparent-traits.html - - title: Universal Applies - url: docs/reference/other-new-features/creator-applications.html - - title: Export Clauses - url: docs/reference/other-new-features/export.html - - title: Opaque Type Aliases - url: docs/reference/other-new-features/opaques.html - - title: Open Classes - url: docs/reference/other-new-features/open-classes.html - - title: Parameter Untupling - url: docs/reference/other-new-features/parameter-untupling.html - - title: Kind Polymorphism - url: docs/reference/other-new-features/kind-polymorphism.html - - title: Matchable Trait - url: docs/reference/other-new-features/matchable.html - - title: threadUnsafe Annotation - url: docs/reference/other-new-features/threadUnsafe-annotation.html - - title: targetName Annotation - url: docs/reference/other-new-features/targetName.html - - title: New Control Syntax - url: docs/reference/other-new-features/control-syntax.html - - title: Optional Braces - url: docs/reference/other-new-features/indentation.html - - title: Explicit Nulls - url: docs/reference/other-new-features/explicit-nulls.html - - title: Safe Initialization - url: docs/reference/other-new-features/safe-initialization.html - - title: TypeTest - url: docs/reference/other-new-features/type-test.html - - title: Other Changed Features - subsection: - - title: Numeric Literals - url: docs/reference/changed-features/numeric-literals.html - - title: Structural Types - url: docs/reference/changed-features/structural-types.html - - title: Operators - url: docs/reference/changed-features/operators.html - - title: Wildcard Types - url: docs/reference/changed-features/wildcards.html - - title: Imports - url: docs/reference/changed-features/imports.html - - title: Type Checking - url: docs/reference/changed-features/type-checking.html - - title: Type Inference - url: docs/reference/changed-features/type-inference.html - - title: Implicit Resolution - url: docs/reference/changed-features/implicit-resolution.html - - title: Implicit Conversions - url: docs/reference/changed-features/implicit-conversions.html - - title: Overload Resolution - url: docs/reference/changed-features/overload-resolution.html - - title: Match Expressions - url: docs/reference/changed-features/match-syntax.html - - title: Vararg Splices - url: docs/reference/changed-features/vararg-splices.html - - title: Pattern Bindings - url: docs/reference/changed-features/pattern-bindings.html - - title: Pattern Matching - url: docs/reference/changed-features/pattern-matching.html - - title: Eta Expansion - url: docs/reference/changed-features/eta-expansion.html - - title: Compiler Plugins - url: docs/reference/changed-features/compiler-plugins.html - - title: Lazy Vals initialization - url: docs/reference/changed-features/lazy-vals-init.html - - title: Main Functions - url: docs/reference/changed-features/main-functions.html - - title: Dropped Features - subsection: - - title: DelayedInit - url: docs/reference/dropped-features/delayed-init.html - - title: Macros - url: docs/reference/dropped-features/macros.html - - title: Existential Types - url: docs/reference/dropped-features/existential-types.html - - title: Type Projection - url: docs/reference/dropped-features/type-projection.html - - title: Do-While - url: docs/reference/dropped-features/do-while.html - - title: Procedure Syntax - url: docs/reference/dropped-features/procedure-syntax.html - - title: Package Objects - url: docs/reference/dropped-features/package-objects.html - - title: Early Initializers - url: docs/reference/dropped-features/early-initializers.html - - title: Class Shadowing - url: docs/reference/dropped-features/class-shadowing.html - - title: Limit 22 - url: docs/reference/dropped-features/limit22.html - - title: XML literals - url: docs/reference/dropped-features/xml.html - - title: Symbol Literals - url: docs/reference/dropped-features/symlits.html - - title: Auto-Application - url: docs/reference/dropped-features/auto-apply.html - - title: Weak Conformance - url: docs/reference/dropped-features/weak-conformance.html - - title: Nonlocal Returns - url: docs/reference/dropped-features/nonlocal-returns.html - - title: "[this] Qualifier" - url: docs/reference/dropped-features/this-qualifier.html - - title: Wildcard initializers - url: docs/reference/dropped-features/wildcard-init.html - - title: Syntax Summary - url: docs/reference/syntax.html - - title: Contributing - subsection: - - title: Contribute Knowledge - url: docs/contributing/contribute-knowledge.html - - title: Getting Started - url: docs/contributing/getting-started.html - - title: Workflow - url: docs/contributing/workflow.html - - title: Testing - url: docs/contributing/testing.html - - title: Debugging - url: docs/contributing/debugging.html - - title: IDEs and Tools - subsection: - - title: IDEs - url: docs/contributing/tools/ide.html - - title: Mill - url: docs/contributing/tools/mill.html - - title: Scalafix - url: docs/contributing/tools/scalafix.html - - title: Procedures - subsection: - - title: Release Model - url: docs/contributing/procedures/release.html - - title: Modifying the Test Framework - url: docs/contributing/procedures/vulpix.html - - title: Internals - subsection: - - title: Backend - url: docs/internals/backend.html - - title: Classpaths - url: docs/internals/classpaths.html - - title: Core Data Structrues - url: docs/internals/core-data-structures.html - - title: Contexts - url: docs/internals/contexts.html - - title: Dotc vs Scalac - url: docs/internals/dotc-scalac.html - - title: Higher-Kinded Types - url: docs/internals/higher-kinded-v2.html - - title: Overall Structure - url: docs/internals/overall-structure.html - - title: Periods - url: docs/internals/periods.html - - title: Syntax - url: docs/internals/syntax.html - - title: Type System - url: docs/internals/type-system.html - - title: "Dotty Internals 1: Trees & Symbols (Meeting Notes)" - url: docs/internals/dotty-internals-1-notes.html - - title: Debug Macros - url: docs/internals/debug-macros.html - - title: Resources - subsection: - - title: Talks - url: docs/resources/talks.html + - title: Blog + - title: Usage + subsection: + - page: docs/usage/getting-started.md + - page: docs/usage/sbt-projects.md + - page: docs/usage/ide-support.md + - page: docs/usage/worksheet-mode.md + - page: docs/usage/language-versions.md + - page: docs/usage/cbt-projects.md + - page: docs/usage/scaladoc + - title: Reference + subsection: + - page: docs/reference/overview.md + - title: New Types + subsection: + - page: docs/reference/new-types/intersection-types.md + - page: docs/reference/new-types/union-types.md + - page: docs/reference/new-types/type-lambdas.md + - page: docs/reference/new-types/match-types.md + - page: docs/reference/new-types/dependent-function-types.md + - page: docs/reference/new-types/polymorphic-function-types.md + - title: Enums + subsection: + - page: docs/reference/enums/enums.md + - page: docs/reference/enums/adts.md + - page: docs/reference/enums/desugarEnums.md + - title: Contextual Abstractions + subsection: + - page: docs/reference/contextual/motivation.md + - page: docs/reference/contextual/givens.md + - page: docs/reference/contextual/using-clauses.md + - page: docs/reference/contextual/context-bounds.md + - page: docs/reference/contextual/given-imports.md + - page: docs/reference/contextual/extension-methods.md + - page: docs/reference/contextual/type-classes.md + - page: docs/reference/contextual/derivation.md + - page: docs/reference/contextual/multiversal-equality.md + - page: docs/reference/contextual/context-functions.md + - page: docs/reference/contextual/conversions.md + - page: docs/reference/contextual/by-name-context-parameters.md + - page: docs/reference/contextual/relationship-implicits.md + - title: Metaprogramming + subsection: + - page: docs/reference/metaprogramming/toc.md + - page: docs/reference/metaprogramming/inline.md + - page: docs/reference/metaprogramming/compiletime-ops.md + - page: docs/reference/metaprogramming/macros.md + - page: docs/reference/metaprogramming/staging.md + - page: docs/reference/metaprogramming/reflection.md + - page: docs/reference/metaprogramming/tasty-inspect.md + - title: Other New Features + subsection: + - page: docs/reference/other-new-features/trait-parameters.md + - page: docs/reference/other-new-features/transparent-traits.md + - page: docs/reference/other-new-features/creator-applications.md + - page: docs/reference/other-new-features/export.md + - page: docs/reference/other-new-features/opaques.md + - page: docs/reference/other-new-features/open-classes.md + - page: docs/reference/other-new-features/parameter-untupling.md + - page: docs/reference/other-new-features/kind-polymorphism.md + - page: docs/reference/other-new-features/matchable.md + - page: docs/reference/other-new-features/threadUnsafe-annotation.md + - page: docs/reference/other-new-features/targetName.md + - page: docs/reference/other-new-features/control-syntax.md + - page: docs/reference/other-new-features/indentation.md + - page: docs/reference/other-new-features/explicit-nulls.md + - page: docs/reference/other-new-features/safe-initialization.md + - page: docs/reference/other-new-features/type-test.md + - title: Other Changed Features + subsection: + - page: docs/reference/changed-features/numeric-literals.md + - page: docs/reference/changed-features/structural-types.md + - page: docs/reference/changed-features/operators.md + - page: docs/reference/changed-features/wildcards.md + - page: docs/reference/changed-features/imports.md + - page: docs/reference/changed-features/type-checking.md + - page: docs/reference/changed-features/type-inference.md + - page: docs/reference/changed-features/implicit-resolution.md + - page: docs/reference/changed-features/implicit-conversions.md + - page: docs/reference/changed-features/overload-resolution.md + - page: docs/reference/changed-features/match-syntax.md + - page: docs/reference/changed-features/vararg-splices.md + - page: docs/reference/changed-features/pattern-bindings.md + - page: docs/reference/changed-features/pattern-matching.md + - page: docs/reference/changed-features/eta-expansion.md + - page: docs/reference/changed-features/compiler-plugins.md + - page: docs/reference/changed-features/lazy-vals-init.md + - page: docs/reference/changed-features/main-functions.md + - title: Dropped Features + subsection: + - page: docs/reference/dropped-features/delayed-init.md + - page: docs/reference/dropped-features/macros.md + - page: docs/reference/dropped-features/existential-types.md + - page: docs/reference/dropped-features/type-projection.md + - page: docs/reference/dropped-features/do-while.md + - page: docs/reference/dropped-features/procedure-syntax.md + - page: docs/reference/dropped-features/package-objects.md + - page: docs/reference/dropped-features/early-initializers.md + - page: docs/reference/dropped-features/class-shadowing.md + - page: docs/reference/dropped-features/limit22.md + - page: docs/reference/dropped-features/xml.md + - page: docs/reference/dropped-features/symlits.md + - page: docs/reference/dropped-features/auto-apply.md + - page: docs/reference/dropped-features/weak-conformance.md + - page: docs/reference/dropped-features/nonlocal-returns.md + - page: docs/reference/dropped-features/this-qualifier.md + - page: docs/reference/dropped-features/wildcard-init.md + - page: docs/reference/syntax.md + - title: Contributing + subsection: + - page: docs/contributing/contribute-knowledge.md + - page: docs/contributing/getting-started.md + - page: docs/contributing/workflow.md + - page: docs/contributing/testing.md + - page: docs/contributing/debugging.md + - title: IDEs and Tools + subsection: + - page: docs/contributing/tools/ide.md + - page: docs/contributing/tools/mill.md + - page: docs/contributing/tools/scalafix.md + - title: Procedures + subsection: + - page: docs/contributing/procedures/release.md + - page: docs/contributing/procedures/vulpix.md + - title: Internals + subsection: + - page: docs/internals/backend.md + - page: docs/internals/classpaths.md + - page: docs/internals/core-data-structures.md + - page: docs/internals/contexts.md + - page: docs/internals/dotc-scalac.md + - page: docs/internals/higher-kinded-v2.md + - page: docs/internals/overall-structure.md + - page: docs/internals/periods.md + - page: docs/internals/syntax.md + - page: docs/internals/type-system.md + - page: docs/internals/dotty-internals-1-notes.md + - page: docs/internals/debug-macros.md + - title: Resources + subsection: + - page: docs/resources/talks.md diff --git a/scaladoc/src/dotty/tools/scaladoc/ScaladocSettings.scala b/scaladoc/src/dotty/tools/scaladoc/ScaladocSettings.scala index c857f37222fc..7d42fa03ad10 100644 --- a/scaladoc/src/dotty/tools/scaladoc/ScaladocSettings.scala +++ b/scaladoc/src/dotty/tools/scaladoc/ScaladocSettings.scala @@ -103,7 +103,7 @@ class ScaladocSettings extends SettingGroup with AllScalaSettings: ) val YdocumentSyntheticTypes: Setting[Boolean] = - BooleanSetting("-Ydocument-synthetic-types", "Documents intrinsic types e. g. Any, Nothing. Setting is useful only for stdlib", false) + BooleanSetting("-Ydocument-synthetic-types", "Attach pages with documentation of the intrinsic types e. g. Any, Nothing to the docs. Setting is useful only for stdlib.", false) val snippetCompiler: Setting[List[String]] = MultiStringSetting("-snippet-compiler", "snippet-compiler", snippets.SnippetCompilerArgs.usage) diff --git a/scaladoc/src/dotty/tools/scaladoc/site/SidebarParser.scala b/scaladoc/src/dotty/tools/scaladoc/site/SidebarParser.scala index 971c766b7fe2..718ce816d001 100644 --- a/scaladoc/src/dotty/tools/scaladoc/site/SidebarParser.scala +++ b/scaladoc/src/dotty/tools/scaladoc/site/SidebarParser.scala @@ -8,25 +8,26 @@ import collection.JavaConverters._ import java.util.Optional enum Sidebar: - case Category(title: String, url: Option[String], nested: List[Sidebar]) - case Page(title: Option[String], url: String) + case Category(title: Option[String], indexPath: Option[String], nested: List[Sidebar]) + case Page(title: Option[String], pagePath: String) object Sidebar: - case class RawInput(var title: String, var url: String, var subsection: JList[RawInput]): - def this() = this("", "", JList()) + case class RawInput(var title: String, var page: String, var index: String, var subsection: JList[RawInput]): + def this() = this("", "", "", JList()) def setTitle(t: String) = this.title = t - def setUrl(u: String) = this.url = u - def setSubsection(l: JList[RawInput]) = this.subsection = l + def setPage(p: String) = this.page = p + def setIndex(i: String) = this.index = i + def setSubsection(s: JList[RawInput]) = this.subsection = s type RawInnerTpe = JMap[String, JList[RawInput]] private object RawTypeRef extends TypeReference[RawInnerTpe] private def toSidebar(r: RawInput): Sidebar = r match - case RawInput(title, url, list) if url.nonEmpty && list.isEmpty() || title == "Blog" => - Sidebar.Page(Option.when(title.nonEmpty)(title), url) - case RawInput(title, url, list) if title.nonEmpty && !list.isEmpty() => - Sidebar.Category(title, Option.when(url.nonEmpty)(url), list.asScala.map(toSidebar).toList) + case RawInput(title, page, index, subsection) if page.nonEmpty && index.isEmpty && subsection.isEmpty() || title == "Blog" => + Sidebar.Page(Option.when(title.nonEmpty)(title), page) + case RawInput(title, page, index, subsection) if page.isEmpty && !subsection.isEmpty() => + Sidebar.Category(Option.when(title.nonEmpty)(title), Option.when(index.nonEmpty)(index), subsection.asScala.map(toSidebar).toList) def load(content: String): Seq[Sidebar] = val mapper = ObjectMapper(YAMLFactory()) diff --git a/scaladoc/src/dotty/tools/scaladoc/site/StaticSiteContext.scala b/scaladoc/src/dotty/tools/scaladoc/site/StaticSiteContext.scala index 00526bf623b1..34455a343876 100644 --- a/scaladoc/src/dotty/tools/scaladoc/site/StaticSiteContext.scala +++ b/scaladoc/src/dotty/tools/scaladoc/site/StaticSiteContext.scala @@ -125,11 +125,11 @@ class StaticSiteContext( None private def loadSidebarContent(entry: Sidebar): LoadedTemplate = entry match - case Sidebar.Page(optionTitle, url) => + case Sidebar.Page(optionTitle, pagePath) => val isBlog = optionTitle == Some("Blog") val path = if isBlog then "blog" else - if Files.exists(root.toPath.resolve(url)) then url - else url.stripSuffix(".html") + ".md" + if Files.exists(root.toPath.resolve(pagePath)) then pagePath + else pagePath.stripSuffix(".html") + ".md" val file = root.toPath.resolve(path).toFile val LoadedTemplate(template, children, _) = loadTemplate(file, isBlog).get // Add proper logging if file does not exisits @@ -143,11 +143,14 @@ class StaticSiteContext( case None => LoadedTemplate(template.copy(settings = template.settings, file = file), children, file) - case Sidebar.Category(title, optionUrl, nested) => - optionUrl match - case Some(url) => // There is an index page for section, let's load it - loadSidebarContent(Sidebar.Page(Some(title), url)).copy(children = nested.map(loadSidebarContent)) + case Sidebar.Category(optionTitle, optionIndexPath, nested) => + optionIndexPath match + case Some(indexPath) => // There is an index page for section, let's load it + loadSidebarContent(Sidebar.Page(optionTitle, indexPath)).copy(children = nested.map(loadSidebarContent)) case None => // No index page, let's create default fake file. + val title = optionTitle match + case Some(t) => t + case None => "index" val fakeFile = new File(new File(root, "docs"), title) LoadedTemplate(emptyTemplate(fakeFile, title), nested.map(loadSidebarContent), fakeFile) diff --git a/scaladoc/src/dotty/tools/scaladoc/snippets/SnippetCompilerArgs.scala b/scaladoc/src/dotty/tools/scaladoc/snippets/SnippetCompilerArgs.scala index dcba74b12533..3198f4ce191a 100644 --- a/scaladoc/src/dotty/tools/scaladoc/snippets/SnippetCompilerArgs.scala +++ b/scaladoc/src/dotty/tools/scaladoc/snippets/SnippetCompilerArgs.scala @@ -30,14 +30,14 @@ case class SnippetCompilerArgs(scFlags: PathBased[SCFlags], val debug: Boolean, object SnippetCompilerArgs: val usage = """ - |Snippet compiler arguments provide a way to configure snippet checking. + |Snippet compiler arguments provide a way to configure snippet type checking. | |This setting accept list of arguments in format: |args := arg{,arg} |arg := [path=]flag - |where path is a prefix of source paths to members to which argument should be set. + |where `path` is a prefix of the path to source files where snippets are located and `flag` is the mode in which snippets will be type checked. | - |If path is not present, argument will be used as default. + |If the path is not present, the argument will be used as the default for all unmatched paths.. | |Available flags: |compile - Enables snippet checking. diff --git a/scaladoc/test/dotty/tools/scaladoc/site/SidebarParserTest.scala b/scaladoc/test/dotty/tools/scaladoc/site/SidebarParserTest.scala new file mode 100644 index 000000000000..183bd792b262 --- /dev/null +++ b/scaladoc/test/dotty/tools/scaladoc/site/SidebarParserTest.scala @@ -0,0 +1,49 @@ +package dotty.tools.scaladoc +package site + +import org.junit.Test +import org.junit.Assert._ + +// TODO add negaitve and more details tests +class SidebarParserTest: + + private val sidebar = """sidebar: + - title: Blog + - title: My title + page: my-page1.md + - page: my-page2.md + - page: my-page3/subsection + - title: Reference + subsection: + - page: my-page3.md + - index: my-page4/index.md + subsection: + - page: my-page4/my-page4.md + - title: My subsection + index: my-page5/index.md + subsection: + - page: my-page5/my-page5.md + - subsection: + - page: my-page7/my-page7.md + - index: my-page6/index.md + subsection: + - index: my-page6/my-page6/index.md + subsection: + - page: my-page6/my-page6/my-page6.md + """ + + @Test + def loadSidebar(): Unit = assertEquals( + Seq( + Sidebar.Page(Some("Blog"), ""), + Sidebar.Page(Some("My title"), "my-page1.md"), + Sidebar.Page(None, "my-page2.md"), + Sidebar.Page(None, "my-page3/subsection"), + Sidebar.Category(Some("Reference"), None, List(Sidebar.Page(None, "my-page3.md"))), + Sidebar.Category(None, Some("my-page4/index.md"), List(Sidebar.Page(None, "my-page4/my-page4.md"))), + Sidebar.Category(Some("My subsection"), Some("my-page5/index.md"), List(Sidebar.Page(None, "my-page5/my-page5.md"))), + Sidebar.Category(None, None, List(Sidebar.Page(None, "my-page7/my-page7.md"))), + Sidebar.Category(None, Some("my-page6/index.md"), List(Sidebar.Category(None, Some("my-page6/my-page6/index.md"), List(Sidebar.Page(None, "my-page6/my-page6/my-page6.md"))))), + ), + Sidebar.load(sidebar) + ) diff --git a/scaladoc/test/dotty/tools/scaladoc/site/StaticSiteContextTest.scala b/scaladoc/test/dotty/tools/scaladoc/site/StaticSiteContextTest.scala deleted file mode 100644 index 126a6b85d04b..000000000000 --- a/scaladoc/test/dotty/tools/scaladoc/site/StaticSiteContextTest.scala +++ /dev/null @@ -1,27 +0,0 @@ -package dotty.tools.scaladoc -package site - -import org.junit.Test -import org.junit.Assert._ - -// TODO add negaitve and more details tests -class SidebarParserTest: - - private val sidebar = """sidebar: - - title: Blog - url: blog/index.html - - title: Reference - subsection: - - title: Overview - url: docs/reference/overview.html - - title: New Types - subsection: - - title: Intersection types - url: docs/reference/new-types/intersection-types.html - - title: Union types - url: docs/reference/new-types/union-types.html - """ - - @Test - def loadSidebar(): Unit = - assertEquals(2, Sidebar.load(sidebar).size)