-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Scaladoc generate flatten structure for API rather then put everything in api
directory
#13130
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
Conversation
Add option to build 'flat' scaladoc package using `generateScalaDocumentation [output] --justAPI`
Is this really a better default if it can lead to conflict when the previous version didn't? Looking at scala/docs.scala-lang#2136 it seems that @julienrf can make symbolic links on the webserver, so he could use whatever path he wants anyway (also I don't really understand why we're moving away from having the documentation and the api all accessible from the same menu as in http://dotty.epfl.ch/docs/) |
True, but that would be simpler to just upload our API documentation on the server, without having to make a symbolic link.
I agree it’s nice to have everything in one place, but I don’t think this is feasible now because we have legacy Jekyll websites, docs.scala-lang.org and scala-lang.org, whose content can’t be just dismissed. So, my strategy was to move the content of dotty.epfl.ch in docs.scala-lang.org so that we can have the Scala 2 and Scala 3 documentation available at the same place, and the last step is to publish the API documentation in scala-lang.org/api, like we do with all the other versions of Scala. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@romanowski Would it be possible to generate the documentation for 3.0.0 and 3.0.1 with this?
Also, what do you think of the following suggestion?
- if there is no
-siteroot
option, we generate only the API documentation at the top-level (noapi/
subdirectory) - if there is a
-siteroot
option, we generate the whole static site, including the documentation under theapi/
subdirectory- we provide a setting to let users provide an alternative path instead of the default
api/
, if they want
- we provide a setting to let users provide an alternative path instead of the default
I feared the same initially but then I realized that we can have conflicts only if one has top-level package called
It depends if tasty has changed. Changes are pretty small. so I am sure it would be possible to cherry-pick the changes and run from those branches.
I think that having different layouts will be confusing and when one would like to introduce a static site then all paths will change
I am not sure how helpful it will be since HTML generated by scaladoc are self-contained and placing API outside structure will render it useless. I am not really sure if making supath of API configurable is really worth added complexity. |
There was PR that was supposed to make automatic releases of older docs with new scaladoc user interface #12784 Nonetheless, if we want to publish them just once, we can:
If we want to get automatic releases we should revive this PR though
I think I like this idea since we are growing fast in number of scaladoc settings and this seems right to don't bother user about nesting of the docs, on the other hand Krzysztof is right that it can be misleading for some users. |
Good point. On the other hand, I must say that I still feel a bit uncomfortable with having the paths of the types and values defined in the projects mixed with the paths of the static pages. I feel like putting them in a sub-path (e.g. Maybe it’s OK to document clearly that @BarkingBad It would be really nice to have a dropdown allowing us to switch between API documentation versions, while still browsing the API documentation for some version, but I would not say it is urgent to have. I would say the top priority is to get the documentation automatically published on https://scala-lang.org/api/3.x/ for every new release. |
The whole point is that static documentation leaves in |
@romanowski I am not much concerned by possible clashes (still, one can have a page |
Is this that a big problem from the user's perspective? I've generated a version of dotty website that merges docs and APIs and I think I prefer to have it that way. ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After a discussion, I realized that my comment was wrong: there is already a separation between the API documentation and the static pages (which are rendered in the docs/
or blog/
sub-paths), so it’s all fine.
Now, I wonder if we should really maintain the -Ylegacy-api-layout
? Why not drop it?
(siteContext.orphanedTemplates :+ siteContext.indexTemplate()).map(templateToPage(_, siteContext)) | ||
val actualIndexTemplate = siteContext.indexTemplates() match | ||
case Nil if effectiveMembers.isEmpty => Seq(siteContext.emptyIndexTemplate) | ||
case templates => templates | ||
|
||
(siteContext.orphanedTemplates ++ actualIndexTemplate).map(templateToPage(_, siteContext)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a comment explaining what this does? I’m a bit lost.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems it just a rewrite (no new logic is added here).
Before:
we got one file by calling siteContext.indexTemplate()
Now:
we call siteContext.indexTemplates()
which returns collection (effectively only one file), then we pattern match on it just to replace it with emptyIndextemplate
(which was embedded in old siteContext.indexTemplate()
) if it was empty or get identity
otherwise and then append it as a collection.
Can you @romanowski explain if I get something wrong here? The only thing is granularity (we have more designated functions to call), but on the other hand main misconception here is that indexTemplates()
actually can yield 0 or 1 file, never 2.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will rewrite to Option
val files = List(new File(root, "index.html"), new File(root, "index.md")).filter { _.exists() } | ||
|
||
if files.size > 1 then | ||
val msg = s"ERROR: Multiple root index pages found: ${files.map(_.getAbsolutePath)}" | ||
report.error(msg) | ||
files |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be indexFile
as we get only one file (either html or md) but not both at once. Moreover it would never be files becuase of assertion in line 25
(siteContext.orphanedTemplates :+ siteContext.indexTemplate()).map(templateToPage(_, siteContext)) | ||
val actualIndexTemplate = siteContext.indexTemplates() match | ||
case Nil if effectiveMembers.isEmpty => Seq(siteContext.emptyIndexTemplate) | ||
case templates => templates | ||
|
||
(siteContext.orphanedTemplates ++ actualIndexTemplate).map(templateToPage(_, siteContext)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems it just a rewrite (no new logic is added here).
Before:
we got one file by calling siteContext.indexTemplate()
Now:
we call siteContext.indexTemplates()
which returns collection (effectively only one file), then we pattern match on it just to replace it with emptyIndextemplate
(which was embedded in old siteContext.indexTemplate()
) if it was empty or get identity
otherwise and then append it as a collection.
Can you @romanowski explain if I get something wrong here? The only thing is granularity (we have more designated functions to call), but on the other hand main misconception here is that indexTemplates()
actually can yield 0 or 1 file, never 2.
@@ -120,5 +120,8 @@ class ScaladocSettings extends SettingGroup with AllScalaSettings: | |||
val generateInkuire: Setting[Boolean] = | |||
BooleanSetting("-Ygenerate-inkuire", "Generates InkuireDB and enables Hoogle-like searches", false) | |||
|
|||
val apiSubdirectory: Setting[Boolean] = | |||
BooleanSetting("-Yapi-subdirectory", "Keep all api member inside `api` directory", false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BooleanSetting("-Yapi-subdirectory", "Keep all api member inside `api` directory", false) | |
BooleanSetting("-Yapi-subdirectory", "Put the API documentation pages inside a directory `api/`", false) |
scaladoc/test/dotty/tools/scaladoc/signatures/AbstractMemberSignaturesTest.scala
Show resolved
Hide resolved
@romanowski How can I generate the API documentation for a specific version of the scala3-library with this? I usually just run |
I partially answered it in this comment #13130 (comment) For now the easiest option is to checkout to specific version and run We can adjust the draft PR I mentioned in the comment I already mentioned so we would could do it automatically. |
This is what I want to achieve, thanks! May I ask you to provide the suite of commands I have to invoke? Especially the part related to invoking the CLI. |
Fixes that should go into #13130
Previously scaladoc keeps always API pages under
api
dir. This PR makes this flat, so documentation forfoo.Bar
is now at/foo/Bar.html
rather then/api/foo/Bar.html
. In case of conflicts with static pages or resources errors are reported.This PR also introduces
-Ylegacy-api-layout
that restores old layout.As a bonus for @julienrf I've added an option to generate just API in provided directory using
scaladoc/generateScalaDocumentation [output] --justAPI
task in sbt.