Skip to content

Commit 5d5eeae

Browse files
authored
Significant refurbish of jaspModuleTemplate (#18)
* Update lock file * First steps in Interface example * Add minimal interactive output to Interface example * Clearer output in Interface example * Add 'other controls' section to Interface example * Add 'Advanced controls' section * Simplify html generation in Interface example * Polish the documentation in Using the interface section * Move 'Load data' to 'Basic interactivity' section * Minor stylistic change * Improve readme and close issue #17
1 parent ca7c49c commit 5d5eeae

File tree

9 files changed

+9009
-794
lines changed

9 files changed

+9009
-794
lines changed

NAMESPACE

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ import(jaspBase)
22
export(addOne)
33
export(processData)
44
export(processTable)
5-
export(parabola)
5+
export(parabola)
6+
export(interfaceExample)

R/examples.R

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,51 @@
1+
interfaceExample <- function(jaspResults, dataset, options) {
2+
# Just show the options as they are understood the R backend
3+
jaspResults[["explanation"]] <- createJaspHtml(title = "User inputs, returned as html",
4+
text = sprintf("Here we show, for pedagogical purposes, the user inputs as they are understood by the R backend."))
5+
6+
jaspResults[["logicals"]] <- createJaspHtml(
7+
title = "Logical controls",
8+
text = sprintf("The tick mark is set to: %s
9+
The radio buttons are set to: %s",
10+
as.character(options$my_tick_mark), # These variables are defined in .inst/qml/Interface.qml
11+
as.character(options$radio_buttons)) # Notice we have to be careful with the data type
12+
)
13+
14+
jaspResults[["others"]] <- createJaspHtml(
15+
title = "Other controls",
16+
text = sprintf("The chosen dropdown element is: %s
17+
The slider value is: %s",
18+
as.character(options$my_dropdown),
19+
as.character(options$my_slider))
20+
)
21+
22+
jaspResults[["keyboard"]] <- createJaspHtml(
23+
title = "Keyboard controls",
24+
text = sprintf("The integer is set to: %s
25+
The double is set to: %s
26+
The percentage is set to: %s
27+
The confidence interval is set to: %s
28+
The text box is set to: <i>%s</i>",
29+
as.character(options$my_integer),
30+
as.character(options$my_double),
31+
as.character(options$my_percent),
32+
as.character(options$my_ci),
33+
options$my_text) # No data-type conversion needed for text
34+
)
35+
36+
jaspResults[["developers"]] <- createJaspHtml(
37+
title = "Note for developers",
38+
text = sprintf("Potential developers will find it useful to inspect the following files:
39+
<ul>
40+
<li><a href='https://github.com/jasp-stats/jaspModuleTemplate/blob/master/inst/qml/Interface.qml'>./inst/qml/Interface.qml</a>: builds the menu on the left panel</li>
41+
<li><a href='https://github.com/jasp-stats/jaspModuleTemplate/blob/master/R/examples.R'>./R/examples.R</a>: builds the output screen you are looking at</li>
42+
<li><a href='https://github.com/jasp-stats/jaspModuleTemplate/blob/master/inst/Description.qml'>./inst/Description.qml</a>: adds access to the current submodule to the module icon on the ribbon above</li>
43+
</ul>")
44+
)
45+
46+
return()
47+
}
48+
149
addOne <- function(jaspResults, dataset, options) {
250
result <- as.character(options$my_number + 1) # options$my_number comes from the menu created by inst/qml/integer.qml
351

README.md

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
11
# jaspModuleTemplate
22

3-
This template repository is a starting point for developing a new module for JASP.
4-
It contains the necessary files and structure, plus a numbers of examples to get started.
3+
This template repository contains example functionality, which makes it an excellent starting point for developing a new JASP module.
4+
It contains the necessary files and structure, plus a numbers of examples to get started and to understand JASP's internals.
55

66
## How to use this repository
77

8-
Fork this template repository to your own GitHub account to start developing your module.
9-
You can then clone the repository to your local machine and start developing your module.
8+
1. Fork this template repository to your own GitHub account
9+
2. Clone it to your machine
10+
3. Open JASP and add it as a development module
1011

11-
The repository contains example functionality.
12-
Feel free to reuse and adapt the examples to your needs.
12+
### For newcomers
13+
14+
It is very illuminating to take a look at our examples **and** at the files that generate them.
15+
16+
For instance, the image below shows the different menus for the _"Using the interface"_ analysis, together with the files that generate them:
17+
18+
![](inst/img/JASP.png)
19+
20+
### For contributors
21+
22+
Feel free to reuse and adapt to your needs.
1323
Feel also free to remove the ones you don't need.
1424

1525
## Contributing back new module to JASP

inst/Description.qml

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,27 @@ Description
1515
preloadData: true
1616
requiresData: true
1717

18+
GroupTitle
19+
{
20+
title: qsTr("Basic interactivity")
21+
}
22+
23+
Analysis
24+
{
25+
title: qsTr("Using the interface") // Title for window
26+
menu: qsTr("Using the interface") // Title for ribbon
27+
func: "interfaceExample" // Function to be called
28+
qml: "Interface.qml" // Design input window
29+
requiresData: false // Allow to run even without data
30+
}
31+
32+
Analysis
33+
{
34+
title: qsTr("Loading data")
35+
menu: qsTr("Loading data")
36+
func: "processData"
37+
qml: "Data.qml"
38+
}
1839

1940
GroupTitle
2041
{
@@ -30,14 +51,6 @@ Description
3051
requiresData: false // Allow to run even without data
3152
}
3253

33-
Analysis
34-
{
35-
title: qsTr("Load data")
36-
menu: qsTr("Load data")
37-
func: "processData"
38-
qml: "Data.qml"
39-
}
40-
4154
Analysis
4255
{
4356
title: qsTr("Tabular results")

inst/img/JASP.png

557 KB
Loading

0 commit comments

Comments
 (0)