Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/keenwrite.git

Address build warnings, add help for R usage, update build instructions

AuthorDaveJarvis <email>
Date2020-05-16 18:47:13 GMT-0700
Commit758c28b83325fc49bee806d234d155741ba88513
Parentc8767c6
Delta221 lines added, 15 lines removed, 206-line increase
BUILD.md
Build the application as follows:
- gradle jar
+ gradle clean jar
The application is built.
+
+# Run
+
+After the application is compiled, run it as follows:
+
+ java -jar build/libs/scrivenvar.jar
+
+On Windows:
+
+ java -jar build\libs\scrivenvar.jar
CREDITS.md
-Credits
-===
+# Credits
- * Dave Jarvis: [Scrivenvar](https://github.com/DaveJarvis/scrivenvar/)
- * Karl Tauber: [Markdown Writer FX](https://github.com/JFormDesigner/markdown-writer-fx)
- * Tomas Mikula: [RichTextFX](https://github.com/TomasMikula/RichTextFX), [ReactFX](https://github.com/TomasMikula/ReactFX), [WellBehavedFX](https://github.com/TomasMikula/WellBehavedFX), [Flowless](https://github.com/TomasMikula/Flowless), and [UndoFX](https://github.com/TomasMikula/UndoFX)
- * Mikael Grev: [MigLayout](http://www.miglayout.com/)
- * Tom Eugelink: [MigPane](https://github.com/mikaelgrev/miglayout/blob/master/javafx/src/main/java/org/tbee/javafx/scene/layout/fxml/MigPane.java)
- * Vladimir Schneider: [flexmark](https://website.com)
- * Jens Deters: [FontAwesomeFX](https://bitbucket.org/Jerady/fontawesomefx)
- * Shy Shalom, Kohei Taketa: [juniversalchardet](https://github.com/takscape/juniversalchardet)
- * David Croft, [File Preferences](https://github.com/eis/simple-suomi24-java-client/tree/master/src/main/java/net/infotrek/util/prefs)
+* Dave Jarvis: [Scrivenvar](https://github.com/DaveJarvis/scrivenvar/)
+* Karl Tauber: [Markdown Writer FX](https://github.com/JFormDesigner/markdown-writer-fx)
+* Tomas Mikula: [RichTextFX](https://github.com/TomasMikula/RichTextFX), [ReactFX](https://github.com/TomasMikula/ReactFX), [WellBehavedFX](https://github.com/TomasMikula/WellBehavedFX), [Flowless](https://github.com/TomasMikula/Flowless), and [UndoFX](https://github.com/TomasMikula/UndoFX)
+* Mikael Grev: [MigLayout](http://www.miglayout.com/)
+* Tom Eugelink: [MigPane](https://github.com/mikaelgrev/miglayout/blob/master/javafx/src/main/java/org/tbee/javafx/scene/layout/fxml/MigPane.java)
+* Vladimir Schneider: [flexmark](https://website.com)
+* Jens Deters: [FontAwesomeFX](https://bitbucket.org/Jerady/fontawesomefx)
+* Shy Shalom, Kohei Taketa: [juniversalchardet](https://github.com/takscape/juniversalchardet)
+* David Croft, [File Preferences](https://github.com/eis/simple-suomi24-java-client/tree/master/src/main/java/net/infotrek/util/prefs)
+* Alex Bertram, [Renjin](https://www.renjin.org/)
+* Michael Kay, [XSLT Processor](http://www.saxonica.com/)
+
+
LICENSE.md
# License
-Copyright 2018 White Magic Software, Ltd.
+Copyright 2020 White Magic Software, Ltd.
All rights reserved.
README.md
# $application.title$
-Word processing with variables.
+Text editing using interpolated strings.
## Requirements
Complete the following steps to run the application:
-1. [Download](https://github.com/DaveJarvis/scrivenvar/releases) `scrivenvar.jar`.
+1. [Download](https://github.com/DaveJarvis/scrivenvar/releases)
+`scrivenvar.jar`.
1. Double-click `scrivenvar.jar` to start the application.
+
+## Command Line Start
+
+If the quick start fails, run the application as follows:
+
+1. Open a command prompt.
+1. Change to the download directory containing the archive file.
+1. Run: `java -jar scrivenvar.jar`
## Features
USAGE-R.md
+# Introduction
+
+This document describes how to use the [R](https://www.r-project.org/)
+programming language from within the application. The application uses an
+interpreter known as [Renjin](https://www.renjin.org/) to integrate with R.
+
+# Hello World
+
+Complete the following steps to see R in action:
+
+1. Start the application.
+1. Click **File → New** to create a new file.
+1. Click **File → Save As**.
+1. Set **Name** to: `addition.Rmd`
+1. Click **Save**.
+
+Setting the file name extension tells the application what processor to
+use when transforming the contents for display in the preview pane. Continue
+by typing in the following text, including the backticks:
+
+```r
+`r#1 + 1`
+```
+
+The preview pane shows the result of `1` plus `1`:
+
+```
+2.0
+```
+
+# Bootstrap Script
+
+Being able to run R code while editing an R Markdown document is convenient.
+Having the ability to call functions is where the power of R can be
+leveraged.
+
+Complete the following steps to call an R function from your own library:
+
+1. Click **File → New** to create a new file.
+1. Click **File → Save As**.
+1. Browse to your home directory.
+1. Set **Name** to: `library.R`.
+1. Click **Save**.
+1. Set the contents to:
+ ``` r
+ sum <- function( a, b ) {
+ a + b
+ }
+ ```
+1. Click the **Save** icon.
+1. Click **R → Script**.
+1. Set the **R Startup Script** contents to:
+ ``` r
+ source( 'library.R' );
+ ```
+1. Click **OK**.
+1. Create a new file.
+1. Set the contents to:
+ ``` r
+ `r#sum( 5, 5 )`
+ ```
+1. Save the file as `sum.R`.
+
+The preview panel shows the result of calling the `sum` function:
+
+```
+10.0
+```
+
+This shows how the bootstrap script can load `library.R`, which defines
+a `sum` function that is called by name in the Markdown document.
+
+# Working Directory
+
+R files may be sourced from any directory, not just the user's home
+directory. Accomplish this as follows:
+
+1. Click **R → Directory**.
+1. Set **Directory** to a different directory.
+1. Click **OK**.
+1. Create the directory if it does not exist.
+1. Move `library.R` into the directory.
+1. Append a new function to `library.R` as follows:
+``` r
+mul <- function( a, b ) {
+ a * b
+}
+```
+1. Click **R → Script**.
+1. Set the **R Startup Script** contents to:
+ ``` r
+ setwd( '$application.r.working.directory$' );
+ source( 'library.R' );
+ ```
+1. Change `sum.Rmd` to:
+ ``` r
+ `r#mul( 5, 5 )`
+ ```
+1. Close the file `sum.Rmd`.
+1. Confirm saving the file when prompted.
+1. Re-open `sum.Rmd`.
+
+The preview panel shows:
+
+```
+25.0
+```
+
+Calling `setwd` using `'$application.r.working.directory$'` changes the
+working directory where the R engine searches for source files.
+
+# YAML Definitions
+
+To see how variable definitions work in R, try the following:
+
+1. Create a new file.
+1. Change the contents to (use spaces not tabs):
+ ``` yaml
+ project:
+ title: Project Title
+ author: Author Name
+ ```
+1. Save the file as `definitions.yaml`.
+1. Click **File → Open**.
+1. Set **Source Files** to **Definition Files**.
+1. Select `definitions.yaml`.
+1. Click **Open**.
+1. Open `sum.Rmd` if it is not already open.
+1. Type: `je`
+1. Press `Ctrl+Space`
+
+The editor inserts the following text (matches `je` against Pro**je**ct):
+
+``` r
+`r#x( v$project$title )`
+```
+
+The preview panel shows:
+
+```
+r#x( 'Project Title' )
+```
+
+This is because the application inserts definition reference names based
+on the type of file being edited. By default, the R engine does not have
+a function named `x` defined.
+
+Continue as follows:
+
+1. Click **R → Script**.
+1. Append the following:
+ ``` r
+ x <- function( s ) {
+ tryCatch({
+ r = eval( parse( text = s ) )
+
+ if( is.atomic( r ) ) { r }
+ else { s }
+ },
+ warning = function( w ) { s },
+ error = function( e ) { s })
+ }
+ ```
+1. Click **OK**.
+1. Close and re-open `sum.Rmd`.
+
+The preview panel shows:
+
+```
+25.0
+
+Project Title
+```
+
+The `x` function attempts to evaluate the expression defined by the YAML
+variable. This means that the YAML definitions can also include expressions
+that R is capable of evaluating.
+
+While the `x` function can be defined within the R Startup Script, it is
+better practice to put it into its own library so that it can be reused
+outside of the application.
+
build.gradle
jar {
+ duplicatesStrategy = DuplicatesStrategy.EXCLUDE
+
manifest {
attributes 'Main-Class': launcherClassName