-
Notifications
You must be signed in to change notification settings - Fork 49
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
Create TypelevelUnidocPlugin
#119
Create TypelevelUnidocPlugin
#119
Conversation
build.sbt
Outdated
lazy val unidoc = project | ||
.in(file("unidoc")) | ||
.enablePlugins(TypelevelUnidocPlugin) | ||
.settings( | ||
name := "sbt-typelevel-unidoc" | ||
) |
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.
This is how you set it up. Choice of "unidoc" for the module name is arbitrary—it would be good to establish a best practice.
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.
Actually: this might not even need a separate module. In theory you could enable the TypelevelUnidocPlugin
on your core module and it would replace its API docs artifact with the unidoc artifact. Not entirely sure if this would work—could be playing with fire.
Edit: just tried this and it seems to work 😅
) | ||
|
||
private[sbt] def javadocioUrl = Def.setting { | ||
if (isSnapshot.value) None // javadoc.io doesn't support snapshots |
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.
build.sbt
Outdated
tlSiteApiModule := Some((unidoc / projectID).value), | ||
tlSiteApiPackage := Some("org.typelevel.sbt") |
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.
This is a bit clunky.
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 have an idea to set tlSiteApiModule := Some((unidoc / projectID).value)
automatically.
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.
A bit reflection-y but gets the job done :)
sbt-typelevel/sonatype/src/main/scala/org/typelevel/sbt/TypelevelUnidocPlugin.scala
Lines 36 to 37 in 0e013b4
// tell the site plugin about us, without forcing the dependency! | |
ThisBuild / SettingKey[Option[ModuleID]]("tlSiteApiModule") := Some(projectID.value) |
build.sbt
Outdated
// Doesn't conflict w/ core artifact since this one won't have the sbt cross version suffix | ||
// javadoc.io doesn't recognize sbt artifacts, so we must publish like this | ||
name := "sbt-typelevel", |
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.
In retrospect not sure if naming the artifact sbt-typelevel
is a good idea. sbt-typelevel-docs
or sbt-typelevel-unidoc
etc. is much better.
I got additional support for this idea in erikerlandson/coulomb#233 (reply in thread). So I'm going to move ahead with it for the next release :) |
This one is pretty simple. A plugin to publish a unidoc artifact to sonatype/maven accessible via javadoc.io, e.g.:
https://www.javadoc.io/doc/org.typelevel/sbt-typelevel_2.12/0.4.4/
AFAIK since javadoc.io can't render snapshots, you can't really update docs between releases.