Restructured text format

The restructured text format (.rst) is a simple, plain text markup language that is sometimes used for programming documentation. It looks very similar to the .md format discussed earlier.

For example, the RST format for the example page looks like this:

 
.. code:: scala 
 
    import scala.io.Source; 
     
    //copied file locally https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data 
    val filename = "iris.data" 
    //println("SepalLength, SepalWidth, PetalLength, PetalWidth, Class"); 
     
    //load iris data into an array 
    val array = scala.collection.mutable.ArrayBuffer.empty[Float] 
    for (line <- Source.fromFile(filename).getLines) { 
        var cols = line.split(",").map(_.trim); 
        //println(s"${cols(0)}|${cols(1)}|${cols(2)}|${cols(3)} |${cols(4)}"); 
        val i = cols(0).toFloat 
        array += i; 
    } 
     
    //get some minimal statistics 
    val count = array.length; 
    var min:Double = 9999.0; 
    var max:Double = 0.0; 
    var total:Double = 0.0; 
    for ( x <- array ) { 
        if (x < min) { min = x; } 
        if (x > max) { max = x; } 
        total += x;      
    } 
    val mean:Double = total / count; 
 
.. parsed-literal:: 
... 

As you can see, it is similar to the markdown in the previous example; the code is roughly broken up into chunks.

Using Atom to display the .rst file results in this:

The .rst display is not as nice as some of the others.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.222.115.120