Skip to content
This repository has been archived by the owner on Jan 21, 2022. It is now read-only.

Commit

Permalink
Updated docs to sbt-site
Browse files Browse the repository at this point in the history
  • Loading branch information
rozza committed Dec 7, 2012
1 parent 1d7600b commit 11c73d1
Show file tree
Hide file tree
Showing 44 changed files with 1,570 additions and 291 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
.cache
.classpath
.DS_Store
.history
.idea
.lib
.project
Expand Down
5 changes: 1 addition & 4 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
site.settings

site.includeScaladoc()

site.sphinxSupport()

site.sphinxSupport()
46 changes: 16 additions & 30 deletions buildDocs.sh
Original file line number Diff line number Diff line change
@@ -1,37 +1,23 @@
#!/bin/sh

rm -rf docs/scaladoc casbah-core/scaladocBuild/
SCALA=2.9.2
WEBSITE_ROOT=rozza.github.com/casbah/

./.sbt "+update" "+clean" "+doc" "+all-docs"
./sbt "update" "clean" "make-site" "unidoc"

cp -R casbah-core/scaladocBuild docs/scaladoc
mkdir -p ./target/site/api.sxr/casbah-commons
mkdir -p ./target/site/api.sxr/casbah-core
mkdir -p ./target/site/api.sxr/casbah-gridfs
mkdir -p ./target/site/api.sxr/casbah-query

mkdir -p docs/scaladoc/modules/casbah-commons
mkdir -p docs/scaladoc/modules/casbah-core
mkdir -p docs/scaladoc/modules/casbah-gridfs
mkdir -p docs/scaladoc/modules/casbah-query
cp ./casbah-commons/target/scala-$SCALA/classes.sxr/* ./target/site/api.sxr/casbah-commons
cp ./casbah-core/target/scala-$SCALA/classes.sxr/* ./target/site/api.sxr/casbah-core
cp ./casbah-gridfs/target/scala-$SCALA/classes.sxr/* ./target/site/api.sxr/casbah-gridfs
cp ./casbah-query/target/scala-$SCALA/classes.sxr/* ./target/site/api.sxr/casbah-query

cp -R casbah-commons/target/scala_2.9.0-1/classes.sxr docs/scaladoc/modules/casbah-commons/sxr
cp -R casbah-commons/target/scala_2.9.0-1/doc/main/api docs/scaladoc/modules/casbah-commons/api
cp -R casbah-core/target/scala_2.9.0-1/classes.sxr docs/scaladoc/modules/casbah-core/sxr
cp -R casbah-core/target/scala_2.9.0-1/doc/main/api docs/scaladoc/modules/casbah-core/api
cp -R casbah-gridfs/target/scala_2.9.0-1/classes.sxr docs/scaladoc/modules/casbah-gridfs/sxr
cp -R casbah-gridfs/target/scala_2.9.0-1/doc/main/api docs/scaladoc/modules/casbah-gridfs/api
cp -R casbah-query/target/scala_2.9.0-1/classes.sxr docs/scaladoc/modules/casbah-query/sxr
cp -R casbah-query/target/scala_2.9.0-1/doc/main/api docs/scaladoc/modules/casbah-query/api
touch ./target/site/.nojekyll

cp doc_index.html docs/scaladoc/modules/index.html

cd tutorial_src

make clean html #epub latexpdf

#cp build/epub/CasbahMongoDBScalaToolkitDocumentation.epub ../docs/CasbahDocumentation.epub
#cp build/latex/CasbahDocumentation.pdf ../docs/CasbahDocumentation.pdf
cp -R build/html/* ../docs

cd ..

cd docs/scaladoc
perl -p -i -e 's#a href="http://api.mongodb.org/scala/casbah-(.*)/casbah-(.*)/sxr/.*/casbah-\2/src/main/scala/(.*)"#a href="/scala/casbah/\1/scaladoc/modules/casbah-\2/sxr/\3.scala.html"#gi' `find ./ -name \*.html`
perl -p -i -e 's#a href="http://api.mongodb.org/scala/casbah-(.*)/casbah-casbah-core/sxr/.*/casbah-(.*)/src/main/scala/(.*)"#a href="/scala/casbah/\1/scaladoc/modules/casbah-\2/sxr/\3.scala.html"#gi' `find ./ -name \*.html`
# Update the sxr in url
find ./target/site/api/ -name \*html -exec sed -i 's#/src\(.*\)/\(.*scala.html\)#\2#' {} \;
# Update WEBSITE ROUTE
find ./target/site/api/ -name \*html -exec sed -i "s#/{{WEBSITE_ROOT}}#/$WEBSITE_ROOT#g" {} \;
80 changes: 40 additions & 40 deletions casbah-query/src/main/scala/aggregation/Group.scala
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,18 @@ trait GroupOperator extends PipelineOperator {
private val operator = "$group"

// TODO - Require GroupSubExpressionObject
def $group(target: DBObject) = {
def $group(target: DBObject) = {
require(target contains "_id", "Aggregation $group statements must contain an _id field representing " +
"the 'GROUP BY' key. Please see the aggregation docs at " +
"http://docs.mongodb.org/manual/reference/aggregation/group/#_S_group")
"the 'GROUP BY' key. Please see the aggregation docs at " +
"http://docs.mongodb.org/manual/reference/aggregation/group/#_S_group")
op(operator, target)
}
}

trait GroupSubExpressionObject {
self: DBObject =>
def field: String

}

object GroupSubExpressionObject {
Expand All @@ -82,136 +82,136 @@ trait GroupSubOperator extends Logging {
(field -> opMap)
}
})
}
}

/**
* Returns an array of all the values found in the selected field among
* the documents in that group. Every unique value only appears once
/**
* Returns an array of all the values found in the selected field among
* the documents in that group. Every unique value only appears once
* in the result set.
*
* RValue should be $<documentFieldName>
*/
trait GroupAddToSetOperator extends GroupSubOperator {

def $addToSet(target: String) = {
require(target.startsWith("$"), "The $group.$addToSet operator only accepts a $<fieldName> argument; bare field names will not function. " +
"See http://docs.mongodb.org/manual/reference/aggregation/#_S_group")
"See http://docs.mongodb.org/manual/reference/aggregation/#_S_group")
op("$addToSet", target)
}

}

/**
/**
* Returns the first value it sees for its group.
*
* Note Only use $first when the $group follows an $sort operation.
* Note Only use $first when the $group follows an $sort operation.
* Otherwise, the result of this operation is unpredictable.
*
* RValue should be $&lt;documentFieldName&gt;
*/
trait GroupFirstOperator extends GroupSubOperator {

def $first(target: String) = {
require(target.startsWith("$"), "The $group.$first operator only accepts a $<fieldName> argument; bare field names will not function. " +
"See http://docs.mongodb.org/manual/reference/aggregation/#_S_group")
"See http://docs.mongodb.org/manual/reference/aggregation/#_S_group")
op("$first", target)
}
}

/**
/**
* Returns the last value it sees for its group.
*
* Note Only use $last when the $group follows an $sort operation.
* Note Only use $last when the $group follows an $sort operation.
* Otherwise, the result of this operation is unpredictable.
*
* RValue should be $&lt;documentFieldName&gt;
*/
trait GroupLastOperator extends GroupSubOperator {

def $last(target: String) = {
require(target.startsWith("$"), "The $group.$last operator only accepts a $<fieldName> argument; bare field names will not function. " +
"See http://docs.mongodb.org/manual/reference/aggregation/#_S_group")
"See http://docs.mongodb.org/manual/reference/aggregation/#_S_group")
op("$last", target)
}
}

/**
/**
* Returns the highest value among all values of the field in all documents selected by this group.
*
* RValue should be $&lt;documentFieldName&gt;
*/
trait GroupMaxOperator extends GroupSubOperator {

def $max(target: String) = {
require(target.startsWith("$"), "The $group.$max operator only accepts a $<fieldName> argument; bare field names will not function. " +
"See http://docs.mongodb.org/manual/reference/aggregation/#_S_group")
"See http://docs.mongodb.org/manual/reference/aggregation/#_S_group")
op("$max", target)
}
}

/**
/**
* Returns the lowest value among all values of the field in all documents selected by this group.
*
* RValue should be $&lt;documentFieldName&gt;
*/
trait GroupMinOperator extends GroupSubOperator {

def $min(target: String) = {
require(target.startsWith("$"), "The $group.$min operator only accepts a $<fieldName> argument; bare field names will not function. See http://docs.mongodb.org/manual/reference/aggregation/#_S_group")
op("$min", target)
}
}

/**
/**
* Returns the average of all values of the field in all documents selected by this group.
*
* RValue should be $&lt;documentFieldName&gt;
*/
trait GroupAvgOperator extends GroupSubOperator {
def $avg(target: String) = {
require(target.startsWith("$"), "The $group.$avg operator only accepts a $<fieldName> argument; bare field names will not function. " +
"See http://docs.mongodb.org/manual/reference/aggregation/#_S_group")
"See http://docs.mongodb.org/manual/reference/aggregation/#_S_group")
op("$avg", target)
}
}

/**
* Returns an array of all the values found in the selected field among
* the documents in that group. A value may appear more than once in the
/**
* Returns an array of all the values found in the selected field among
* the documents in that group. A value may appear more than once in the
* result set if more than one field in the grouped documents has that value.
*
* RValue should be $&lt;documentFieldName&gt;
*/
trait GroupPushOperator extends GroupSubOperator {
def $push(target: String) = {
require(target.startsWith("$"), "The $group.$push operator only accepts a $<fieldName> argument; bare field names will not function. " +
"See http://docs.mongodb.org/manual/reference/aggregation/#_S_group")
"See http://docs.mongodb.org/manual/reference/aggregation/#_S_group")
op("$push", target)
}
}

/**
* Returns the sum of all the values for a specified field in the
/**
* Returns the sum of all the values for a specified field in the
* grouped documents, as in the second use above.
*
* The standard usage is to indicate "1" as the value, which counts all the
*
* The standard usage is to indicate "1" as the value, which counts all the
* members in the group.
*
* Alternately, if you specify a field value as an argument, $sum will
* increment this field by the specified value for every document in the
* grouping.
* Alternately, if you specify a field value as an argument, $sum will
* increment this field by the specified value for every document in the
* grouping.
*
*/
trait GroupSumOperator extends GroupSubOperator {
def $sum(target: String) = {
require(target.startsWith("$"), "The $group.$sum operator only accepts a $<fieldName> argument (or '1'); bare field names will not function." +
" See http://docs.mongodb.org/manual/reference/aggregation/#_S_group")
" See http://docs.mongodb.org/manual/reference/aggregation/#_S_group")
op("$sum", target)
}

def $sum(target: Int) = {
require(target == 1, "The $group.$sum operator only accepts a numeric argument of '1', or a $<FieldName>. " +
"See http://docs.mongodb.org/manual/reference/aggregation/#_S_group")
"See http://docs.mongodb.org/manual/reference/aggregation/#_S_group")
op("$sum", target)
}
}
2 changes: 1 addition & 1 deletion casbah-query/src/main/scala/aggregation/Unwind.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ trait UnwindOperator extends PipelineOperator {

def $unwind(target: String) = {
require(target.startsWith("$"), "The $unwind operator only accepts a $<fieldName> argument; bare field names " +
"will not function. See http://docs.mongodb.org/manual/reference/aggregation/#_S_unwind")
"will not function. See http://docs.mongodb.org/manual/reference/aggregation/#_S_unwind")
op(operator, target)
}
}
19 changes: 0 additions & 19 deletions doc_index.html

This file was deleted.

22 changes: 20 additions & 2 deletions project/CasbahBuild.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,30 @@ object CasbahBuild extends Build {

"mongoimport -d casbahIntegration -c artilces --drop ./casbah-core/src/test/resources/articles.json" !

val allSourceDirectories = SettingKey[Seq[Seq[File]]]("all-source-directories")

def sxrOpts(baseDir: File, sourceDirs: Seq[Seq[File]], scalaVersion: String): Seq[String] = {
if (scalaVersion.startsWith("2.10") || scalaVersion.startsWith("2.8"))
Seq()
else
Seq("-P:sxr:base-directory:" + sourceDirs.flatten.mkString(";").replaceAll("\\\\","/"))
}

override lazy val settings = super.settings ++ buildSettings

lazy val baseSettings = Defaults.defaultSettings ++ Seq(
resolvers ++= Seq(sonatypeRels, sonatypeSnaps, sonatypeSTArch, mavenOrgRepo),
testOptions in Test += Tests.Argument(TestFrameworks.Specs2, "console", "junitxml")
testOptions in Test += Tests.Argument(TestFrameworks.Specs2, "console", "junitxml"),
autoCompilerPlugins := true,
addCompilerPlugin("org.scala-tools.sxr" % "sxr_2.9.0" % "0.2.7"),
allSourceDirectories <<= projects.map(sourceDirectories in Compile in _).join,
scalacOptions in (Compile, doc) <++= (baseDirectory, allSourceDirectories, scalaVersion) map sxrOpts,
scalacOptions in (Compile, doc) <++= (baseDirectory, scalaVersion, version, baseDirectory in LocalProject("casbah")).map {
(bd, sv, v, rootBase) =>
val tagOrBranch = if (v.endsWith("-SNAPSHOT")) "dev" else "v" + v
val docSourceUrl = "http://{{WEBSITE_ROOT}}api.sxr/€{FILE_PATH}.scala.html"
Seq("-sourcepath", rootBase.getAbsolutePath, "-doc-source-url", docSourceUrl)
}
)


Expand Down Expand Up @@ -78,7 +96,7 @@ object CasbahBuild extends Build {
lazy val casbah = Project(
id = "casbah",
base = file("."),
settings = parentSettings,
settings = parentSettings ++ Unidoc.settings,
aggregate = Seq(commons, core, query, gridfs)
) dependsOn(commons, core, query, gridfs)

Expand Down
52 changes: 52 additions & 0 deletions project/Unidoc.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import sbt._
import Keys._
import Project.Initialize

/** Borrowed from https://github.com/akka/akka/blob/master/project/Unidoc.scala */
object Unidoc {
val unidocDirectory = SettingKey[File]("unidoc-directory")
val unidocExclude = SettingKey[Seq[String]]("unidoc-exclude")
val unidocAllSources = TaskKey[Seq[Seq[File]]]("unidoc-all-sources")
val unidocSources = TaskKey[Seq[File]]("unidoc-sources")
val unidocAllClasspaths = TaskKey[Seq[Classpath]]("unidoc-all-classpaths")
val unidocClasspath = TaskKey[Seq[File]]("unidoc-classpath")
val unidoc = TaskKey[File]("unidoc", "Create unified scaladoc for all aggregates")

lazy val settings: Seq[Project.Setting[_]] = Seq(
unidocDirectory <<= crossTarget / "../site/api",
unidocExclude := Seq.empty,
unidocAllSources <<= (thisProjectRef, buildStructure, unidocExclude) flatMap allSources,
unidocSources <<= unidocAllSources map { _.flatten },
unidocAllClasspaths <<= (thisProjectRef, buildStructure, unidocExclude) flatMap allClasspaths,
unidocClasspath <<= unidocAllClasspaths map { _.flatten.map(_.data).distinct },
unidoc <<= unidocTask
)

def allSources(projectRef: ProjectRef, structure: Load.BuildStructure, exclude: Seq[String]): Task[Seq[Seq[File]]] = {
val projects = aggregated(projectRef, structure, exclude)
projects flatMap { sources in Compile in LocalProject(_) get structure.data } join
}

def allClasspaths(projectRef: ProjectRef, structure: Load.BuildStructure, exclude: Seq[String]): Task[Seq[Classpath]] = {
val projects = aggregated(projectRef, structure, exclude)
projects flatMap { dependencyClasspath in Compile in LocalProject(_) get structure.data } join
}

def aggregated(projectRef: ProjectRef, structure: Load.BuildStructure, exclude: Seq[String]): Seq[String] = {
val aggregate = Project.getProject(projectRef, structure).toSeq.flatMap(_.aggregate)
aggregate flatMap { ref =>
if (exclude contains ref.project) Seq.empty
else ref.project +: aggregated(ref, structure, exclude)
}
}

def unidocTask: Initialize[Task[File]] = {
(compilers, cacheDirectory, unidocSources, unidocClasspath, unidocDirectory, scalacOptions in (Compile, doc), streams) map {
(compilers, cache, sources, classpath, target, options, s) => {
val scaladoc = new Scaladoc(100, compilers.scalac)
scaladoc.cached(cache / "unidoc", "main", sources, classpath, target, options.filter(x => !(x.startsWith("-X") || x.startsWith("-P"))), s.log)
target
}
}
}
}
3 changes: 2 additions & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "0.6.0") ++
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.1.0")

addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "0.6.0")
Loading

0 comments on commit 11c73d1

Please sign in to comment.