Skip to content

Add missing features to scala3doc to match dotty docs #10320

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Nov 18, 2020

Conversation

romanowski
Copy link
Contributor

@romanowski romanowski commented Nov 15, 2020

Links do generated documentation using this PR for Scala 3 and scal3doc itself (however it has just a token static site).

Scope of this PR:

  • render index page for blog
  • blogposts has all required parameters
  • render images properly in static site/blog
  • search bar is flating
  • Add properties for version, revision etc.
  • edit on github links does not work
  • linking from static pages to types
  • linking to paragraphs
  • ensure that we document all the classes that are documented on https://dotty.epfl.ch/

Known differences:

  • navigation is a bit different but allow for adding content of each level (so e.g. https://dotty.epfl.ch/docs/reference/overview.html can be moved directly to Reference node: https://scala3doc.virtuslab.com/pr-10320/scala3/docs/Reference/index.html)
  • searchbar is dynamic and is able to search in titles of static pages and blogs however we do search for packages (however I am pretty sure @pikinier20 will be able to make this work)
  • For now we do not support includes in static documentation but this is a matter of day or two (documentation for scala 3 uses it on main page and to add a table of conent on one page)
  • We do not support (but shoudl not be hard to implement if needed) rendering of docstrings in static doumentation but this is not used in Scala 3 documentation
  • Scala3doc doesn not come with predefined layouts. images and includse for static documentation. Once we migrate Scala 3 documentaiton we plan to reach out to community to ask what kind of defaults are expected.
  • TODO: inspect other differneces

New features:

  • [site] sidebar can have arbitrary deps, sections (directories) can have its own content (in index.html or index.md)
  • scala3doc cover all language features (bug in givens is being fixed by @pikinier20)
  • scala3doc has members filter (improved version of one in scaladoc)
  • members in scala3doc is groped by kind and origin (defined and inherited) and in future we can apply arbitraty (also dynamic) groupping
  • scala3doc provides subset of implicit members (from extension methods, given and implicit conversions) however this is really a naive implemtnation
  • scala3doc provide linear subtypes and type hierarchy diagrams (https://scala3doc.virtuslab.com/pr-10298/scala3/api/scala/-empty-tuple/index.html)
  • scala3doc is fast and reuses compilation artifacts. It takes under 20s seconds on my machine to generate documentation for Scala 3 once code is compiled. Scala3doc was not optimized at any point so I am sure we can be even faster
  • scala3doc has proper implementation of linking to sources that even more powerfull then scaladoc (allows to provide custom patterns as well as partial patterns for subrepositories or documentation compose from various repositories)
  • scala3doc has abstract and unified mechanism for linking to pages based on DRIs that will allow us to link to documentation from other projects
  • scala3doc properly parsers doc comments (this includes linking etc.)
  • scala3doc allow to cusomize logo and has its own custom logo :)

@romanowski romanowski force-pushed the scala3doc/dotty-doc-parity branch from 028bb16 to 40cf93e Compare November 15, 2020 09:08
BarkingBad and others added 10 commits November 16, 2020 10:50
 - add links
 - implement more generic children mechanism
To not refactor half of model I needed to use a var that accepts lambda. We should probably find better way to do it (probably by processing TASTY before we start dokka)

Add local alias for DRI
also expost it as fields in static site
Set cwd form generate*Documentation tasks to root project path
@romanowski romanowski force-pushed the scala3doc/dotty-doc-parity branch from 2a0cc49 to 7fce442 Compare November 16, 2020 09:50
Copy link
Contributor

@BarkingBad BarkingBad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So far look good

import scala.collection.JavaConverters._


case class LazyEntry(val getKey: String, value: () => String) extends JMapEntry[String, Object]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant val

@romanowski romanowski marked this pull request as ready for review November 16, 2020 12:06
This makes our source link precisily pin-point used source not what is currently on master.
EmojiExtension.ROOT_IMAGE_PATH,
"https://github.global.ssl.fastly.net/images/icons/emoji/"
)
.set(Parser.INDENTED_CODE_BLOCK_PARSER, false)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we intentionally disable indented code blocks?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I copied the settings over from dotty-doc so I do not have a strong feeling aboout any of this options beside ANCHORLINKS ones.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should support them, unless we have a reason not to.

There's a separate topic here: linking to documentation from static site should be done with Wiki links, like in doc comments. This requires the WikiLink extension like here and some link-handling code that's already in MarkdownConverter here.

Copy link
Contributor

@abgruszecki abgruszecki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aside from the comments, LGTM!

Comment on lines 114 to 117
config.staticSiteContext.foreach { p =>
val previous = p.memberLinkResolver
p.memberLinkResolver = link => previous(link).orElse(driFor(link))
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It shouldn't be neccessary to store multiple contexts, any of them should work for resolving links.

EmojiExtension.ROOT_IMAGE_PATH,
"https://github.global.ssl.fastly.net/images/icons/emoji/"
)
.set(Parser.INDENTED_CODE_BLOCK_PARSER, false)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should support them, unless we have a reason not to.

There's a separate topic here: linking to documentation from static site should be done with Wiki links, like in doc comments. This requires the WikiLink extension like here and some link-handling code that's already in MarkdownConverter here.

Do not fail on missing link but display a warning.
@abgruszecki abgruszecki merged commit 8963e5f into scala:master Nov 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants