//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
/** @author Hao Peng
* @version 1.6
* @date Sat Nov 4 12:18:00 EDT 2017
* @see LICENSE (MIT style license file).
*/
package scalation
import java.io.{File, PrintWriter}
import java.util.Scanner
import scala.io.Source
//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
/** The `GenReadmeHtml` object is used to create the html tables for the api and
* src directories for convenient Web browsing.
* > runMain scalation.GenReadmeHtml
*/
object GenReadmeHtml extends App
{
val SKIP = "old" // do not process files in this directory
val moduleList = Array ("scalation_mathstat", "scalation_database", "scalation_modeling", "scalation_models")
val moduleNames = Array ("MATH AND STAT", "DATABASE", "MODELING", "APPLICATIONS")
val scalationVer = BASE.substring (BASE.lastIndexOf ('_') + 1) // ScalaTion version (i.e., 1.4)
val scalaVerFull = scala.util.Properties.versionNumberString // full scala version (i.e., 2.12.4)
val scalaVer = scalaVerFull.substring (0, scalaVerFull.lastIndexOf ('.')) // main scala version (i.e., 2.12)
val javaVer = System.getProperty("java.version").split('.')(1) // current java version (i.e., 8)
val fApi = new File (BASE + ⁄ + "api.html")
val fSrc = new File (BASE + ⁄ + "src.html")
val outApi = new PrintWriter (fApi) // api table writer
val outSrc = new PrintWriter (fSrc) // src table writer
// write table headers
outApi.println (s"""\n\n \n \n\n
Welcome to ScalaTion, the Scala-based system for Simulation, Optimization and Analytics.
This system, coded in Scala, supports multi-paradigm simulation modeling including
'tableau', 'event', 'process', 'dynamics', 'dynamics_pde', 'activity' and 'state' oriented models.
Scala is a modern object-oriented, functional programming language
that is well-suited for developing simulation engines.
It is in the Java family of languages and can call Java code.
The inclusion of advanced and functional programming capabilities,
makes the code much more concise than Java.
ScalaTion also supports optimization and analytics as they nowadays go hand-in-hand with simulation modeling.
Some of the algorithms come in both sequential and parallel versions.
The ScalaTion $scalationVer version defines multiple .par subpackages that contain parallel versions of sequential algorithms.
Future directions include completing the 'scala3d' and 'physics' packages.
As of version $scalationVer, ScalaTion consists of ${moduleList.length} subprojects:
$moduleListS
Please read the LICENSE file (an MIT style license).
Source Packages (doc)
\n\n
")
outApi.close
outSrc.close
val moduleListS = new StringBuilder
for (i <- 0 until moduleList.length) {
moduleListS.append (moduleList(i))
if (i < moduleList.length - 2) moduleListS.append (", ")
else if (i == moduleList.length - 2) moduleListS.append (" and ")
} // for
val prefix = raw"""
SCALAble SimulaTION - ScalaTion
Installation Instructions
Requires:
Scala $scalaVer.x and
Java $javaVer
Recommended:
sbt
(see Setup.html)
$$ tar xvfz scalation_$scalationVer.tar.gz
OR
$$ unzip scalation_$scalationVer.zip
$$ cd scalation_$scalationVer
$$ cd scalation_models
$$ sbt
> compile
> runMain apps.process.Bank
> runMain scalation.analytics.RegressionTest
> exit
ScalaTion $scalationVer is set up to use the Simple Build Tool sbt.
ScalaTion $scalationVer uses the following build specification files build.sbt, build.sbt and build.sbt. Source packages are in the src/main/scala directory, class files are in the target/scala-${scalaVer}/classes directory, and documentation files are in the target/scala-${scalaVer}/api directory. Data file input, output or analytics are stored in subdirectories of data, while database files are stored in store.
To develop using an IDE:
For more information about the source code, see
src/README_src.hmtl.
"""
val readmeOut = new PrintWriter (BASE + ⁄ + "README.html")
readmeOut.println (prefix)
readmeOut.println (Source.fromFile (fApi).mkString)
readmeOut.println (Source.fromFile (fSrc).mkString)
readmeOut.println (postfix)
readmeOut.close
//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
/** Recursively write table rows for each package.
* @param f the directory to examine
* @param module the module name (i.e. scalation_mathstat)
* @param parPath the path of the parent directories (i.e. scalation/util)
* @param parName the name of the parent directories (i.e. scalation.util)
* @param depth the depth of the project structure
* @param isTestPac flag for whether dealing with unit testing packages or not
*/
def recWrite (f: File, module: String, parPath : String, parName: String, depth: Int, isTestPac: Boolean = false)
{
val dirs = f.listFiles // list files in the current directory
val mainTest = if (isTestPac) "test" else "main"
for (fi <- dirs if (fi.isDirectory && !fi.getName.contains (SKIP))) { // process each subpackage in the current package/directory
val pacName = fi.getName
val hyphens = getHyphens (depth)
val descriptions = getDescriptions (new File (fi.getAbsolutePath + ⁄ + "package.scala"))
if (!isTestPac) outApi.println (s""" Papers/Documentation
"""
val postfix = raw"""
Online supplement
Code Release Process
Similarly for scalation_modeling and scalation_models.
Currently the .jar files need to be copied (copy_jars.sh) into the lib directory of dependent subprojects.
$$ cd scalation_$scalationVer
$$ cd scalation_mathstat
$$ sbt
> compile
> package
> test
> runMain scalation.util.RunSpellCheck 'package-directory'
> runMain scalation.GenIndexHtml
> clean
> doc
> exit
\n ${hyphens} $parName.$pacName \n $descriptions""")
outSrc.println (s""" \n ${hyphens} $parName.$pacName \n $descriptions""")
recWrite (fi, module, s"$parPath/$pacName", s"$parName.$pacName", depth+1, isTestPac)
} // for
} // recWrite
//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
/** Obtain the number of hyphens for the sub-packages.
* @param depth the depth of the project structure
*/
def getHyphens (depth: Int): String =
{
val sb = new StringBuilder
for (i <- 0 until depth) sb.append ("- ")
sb.toString
} // getHyphens
//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
/** Obtain the Descriptions of a package from its package.scala comments.
* @param f the package.scala file
*/
def getDescriptions (f: File): String =
{
if (f.exists) {
val scan = new Scanner (f)
var foundStart = false // flag for fining the starting point of search, which is the package line
var contSearch = true // flag for continuing with the search (has not encountered */)
var sb = new StringBuilder
while (contSearch && scan.hasNextLine) {
var line = scan.nextLine
if (foundStart) {
if (line.startsWith ("/**")) {
line = line.substring (3).trim
sb.append (line)
sb += ' '
} else if (line.startsWith (" */")) {
contSearch = false
} else if (line.startsWith (" *")) {
line = line.substring (2).trim
sb.append (line)
sb += ' '
} // if
} else if (line.contains ("package")) foundStart = true
} // while
sb.toString
} else s"There is currently no `package.scala` for ${f.getParentFile.getName}"
} // getDescriptions
} // GenReadmeHtml object