Skip to content
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

Exclude a package from all projects #56

Open
skvithalani opened this issue Mar 20, 2018 · 3 comments
Open

Exclude a package from all projects #56

skvithalani opened this issue Mar 20, 2018 · 3 comments

Comments

@skvithalani
Copy link

skvithalani commented Mar 20, 2018

We want to exclude a particular package named "internal" from scaladoc and javadoc for all projects. We have UnidocSite plugin as follows:

object UnidocSite extends AutoPlugin {
  import sbtunidoc.{BaseUnidocPlugin, JavaUnidocPlugin, ScalaUnidocPlugin}
  import JavaUnidocPlugin.autoImport._
  import ScalaUnidocPlugin.autoImport._
  import BaseUnidocPlugin.autoImport.unidoc

  import com.typesafe.sbt.site.SitePlugin.autoImport._

  override def requires: Plugins = ScalaUnidocPlugin && JavaUnidocPlugin

  def excludeJavadoc: Set[String] = Set("internal", "scaladsl", "csw_protobuf")
  
  def excludeScaladoc: String     = Seq("internal", "csw_protobuf", "akka").mkString(":")

  override def projectSettings: Seq[Setting[_]] = Seq(
    siteSubdirName in ScalaUnidoc := "/api/scala",
    addMappingsToSiteDir(mappings in (ScalaUnidoc, packageDoc), siteSubdirName in ScalaUnidoc),
    siteSubdirName in JavaUnidoc := "/api/java",
    filterNotSources(sources in (JavaUnidoc, unidoc), excludeJavadoc),
    addMappingsToSiteDir(mappings in (JavaUnidoc, packageDoc), siteSubdirName in JavaUnidoc),
    
    scalacOptions in (ScalaUnidoc, unidoc) ++= Seq("-skip-packages", excludeScaladoc),
    
    autoAPIMappings := true
  )

  def filterNotSources(filesKey: TaskKey[Seq[File]], subPaths: Set[String]): Setting[Task[Seq[File]]] = {
    filesKey := filesKey.value.filterNot(file => subPaths.exists(file.getAbsolutePath.contains))
  }
}

But somehow "internal" package gets excluded only from javadoc and not from scaladoc.

Is there something we are missing ?

@nachmikott
Copy link

Hey @skvithalani , I hope all is well. I'm wondering, did this ever work for you? I have a similar issue, where I don't want certain packages in a sbt unidoc.

@skvithalani
Copy link
Author

Hello @nachmikott, for packages to be excluded from scala, we make all the members in that package private/package private. If none of the members are visible to outer world then sbt-unidoc does not include that package in scaladoc.

So, if we don't have any visible members, we don't need scaladoc for it. That's the approach.

@vbmacher
Copy link

Hello all, I didnt want to start a new ticket for this, because I think it's related. My question:

Is it possible to exclude documentation of generated sources? I mean the ones generated with Compile / sourceGenerators?

Even though this question applies generally (e.g. for the generated parsers, etc.) - in my specific case, I have zipped source code of some external library, because it's not published anywhere. I dont want to include/generate the documentation of this external source.

Example part of my build.sbt:

lazy val myproject = project
        .settings(
          Compile / sourceGenerators += unzipMyLibraryTask,
          ...
        )

lazy val root = (project in file("."))
        .enablePlugins(ScalaUnidocPlugin)
        .aggregate(myproject)
        .settings(
          ScalaUnidoc / unidoc / scalacOptions ++= Seq("-skip-packages", "com.mylibrary")  // this is what I tried, but doesnt work..
        )

If there is no other option, I would include it, but the problem is the library source code is not perfectly written and so the unidoc shows errors and refuses to continue. I really don't want to spend any time of fixing the library.

Thanks for any advice!

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

No branches or pull requests

3 participants