Skip to content
3 changes: 3 additions & 0 deletions bigquery/src/main/resources/interpreter-setting.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
"defaultValue": "100000",
"description": "Maximum number of rows to fetch from BigQuery"
}
},
"editor": {
"language": "sql"
}
}
]
20 changes: 14 additions & 6 deletions docs/development/writingzeppelininterpreter.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ There are three locations where you can store your interpreter group, name and o
{ZEPPELIN_INTERPRETER_DIR}/{YOUR_OWN_INTERPRETER_DIR}/interpreter-setting.json
```

Here is an example of `interpreter-setting.json` on your own interpreter.
Here is an example of `interpreter-setting.json` on your own interpreter. Note that if you don't specify editor object, your interpreter will use plain text mode for syntax highlighting.

```json
[
Expand All @@ -69,6 +69,9 @@ Here is an example of `interpreter-setting.json` on your own interpreter.
"defaultValue": "property2DefaultValue",
"description": "Property 2 description"
}, ...
},
"editor": {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick question - it's a bit not clear if this section is mandatory and if not, what is going to be the default one? May be it could be described in docs below.
Asking as there are i.e PRs that implement a new interpreters, before this section was introduced.

Copy link
Member Author

@minahlee minahlee Sep 13, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! If the language is not specified plain text mode will be used for syntax highlight, which will highlight nothing. I added description in fd7896e. Thanks for review :)

"language": "your-syntax-highlight-language"
}
},
{
Expand All @@ -81,8 +84,8 @@ Finally, Zeppelin uses static initialization with the following:

```
static {
Interpreter.register("MyInterpreterName", MyClassName.class.getName());
}
Interpreter.register("MyInterpreterName", MyClassName.class.getName());
}
```

**Static initialization is deprecated and will be supported until 0.6.0.**
Expand All @@ -96,15 +99,20 @@ some interpreter specific code...
```

## Programming Languages for Interpreter
If the interpreter uses a specific programming language ( like Scala, Python, SQL ), it is generally recommended to add a syntax highlighting supported for that to the notebook paragraph editor.
If the interpreter uses a specific programming language (like Scala, Python, SQL), it is generally recommended to add a syntax highlighting supported for that to the notebook paragraph editor.

To check out the list of languages supported, see the `mode-*.js` files under `zeppelin-web/bower_components/ace-builds/src-noconflict` or from [github.com/ajaxorg/ace-builds](https://github.com/ajaxorg/ace-builds/tree/master/src-noconflict).

If you want to add a new set of syntax highlighting,

1. Add the `mode-*.js` file to <code>[zeppelin-web/bower.json](https://github.com/apache/zeppelin/blob/master/zeppelin-web/bower.json)</code> ( when built, <code>[zeppelin-web/src/index.html](https://github.com/apache/zeppelin/blob/master/zeppelin-web/src/index.html)</code> will be changed automatically. ).
2. Add to the list of `editorMode` in <code>[zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js](https://github.com/apache/zeppelin/blob/master/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js)</code> - it follows the pattern 'ace/mode/x' where x is the name.
3. Add to the code that checks for `%` prefix and calls `session.setMode(editorMode.x)` in `setParagraphMode` located in <code>[zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js](https://github.com/apache/zeppelin/blob/master/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js)</code>.
2. Add `editor` object to `interpreter-setting.json` file. If you want to set your language to `java` for example, add:

```
"editor": {
"language": "java"
}
```

## Install your interpreter binary

Expand Down
3 changes: 3 additions & 0 deletions flink/src/main/resources/interpreter-setting.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
"defaultValue": "6123",
"description": "port of running JobManager."
}
},
"editor": {
"language": "scala"
}
}
]
3 changes: 3 additions & 0 deletions jdbc/src/main/resources/interpreter-setting.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@
"defaultValue": "org.postgresql.Driver",
"description": ""
}
},
"editor": {
"language": "sql"
}
}
]
12 changes: 12 additions & 0 deletions livy/src/main/resources/interpreter-setting.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@
"defaultValue": "",
"description": "Adding extra libraries to livy interpreter"
}
},
"editor": {
"language": "scala"
}
},
{
Expand All @@ -105,20 +108,29 @@
"defaultValue": "false",
"description": "Execute multiple SQL concurrently if set true."
}
},
"editor": {
"language": "sql"
}
},
{
"group": "livy",
"name": "pyspark",
"className": "org.apache.zeppelin.livy.LivyPySparkInterpreter",
"properties": {
},
"editor": {
"language": "python"
}
},
{
"group": "livy",
"name": "sparkr",
"className": "org.apache.zeppelin.livy.LivySparkRInterpreter",
"properties": {
},
"editor": {
"language": "r"
}
}
]
3 changes: 3 additions & 0 deletions markdown/src/main/resources/interpreter-setting.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
"defaultValue": "markdown4j",
"description": "Markdown Parser Type. Available values: markdown4j, pegdown. Default = markdown4j"
}
},
"editor": {
"language": "markdown"
}
}
]
3 changes: 3 additions & 0 deletions python/src/main/resources/interpreter-setting.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
"defaultValue": "1000",
"description": "Max number of dataframe rows to display."
}
},
"editor": {
"language": "python"
}
},
{
Expand Down
5 changes: 4 additions & 1 deletion shell/src/main/resources/interpreter-setting.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
"defaultValue": "",
"description": "Kerberos principal"
}
},
"editor": {
"language": "sh"
}
}
]
]
12 changes: 12 additions & 0 deletions spark/src/main/resources/interpreter-setting.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@
"defaultValue": "local[*]",
"description": "Spark master uri. ex) spark://masterhost:7077"
}
},
"editor": {
"language": "scala"
}
},
{
Expand Down Expand Up @@ -85,6 +88,9 @@
"defaultValue": "true",
"description": "Import implicits, UDF collection, and sql if set true. true by default."
}
},
"editor": {
"language": "sql"
}
},
{
Expand All @@ -104,6 +110,9 @@
"defaultValue": "spark-packages,http://dl.bintray.com/spark-packages/maven,false;",
"description": "A list of 'id,remote-repository-URL,is-snapshot;' for each remote repository."
}
},
"editor": {
"language": "scala"
}
},
{
Expand All @@ -117,6 +126,9 @@
"defaultValue": "python",
"description": "Python command to run pyspark with"
}
},
"editor": {
"language": "python"
}
}
]
15 changes: 15 additions & 0 deletions spark/src/main/sparkr-resources/interpreter-setting.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@
"defaultValue": "local[*]",
"description": "Spark master uri. ex) spark://masterhost:7077"
}
},
"editor": {
"language": "scala"
}
},
{
Expand Down Expand Up @@ -85,6 +88,9 @@
"defaultValue": "true",
"description": "Import implicits, UDF collection, and sql if set true. true by default."
}
},
"editor": {
"language": "sql"
}
},
{
Expand All @@ -104,6 +110,9 @@
"defaultValue": "spark-packages,http://dl.bintray.com/spark-packages/maven,false;",
"description": "A list of 'id,remote-repository-URL,is-snapshot;' for each remote repository."
}
},
"editor": {
"language": "scala"
}
},
{
Expand All @@ -117,6 +126,9 @@
"defaultValue": "python",
"description": "Python command to run pyspark with"
}
},
"editor": {
"language": "python"
}
},
{
Expand Down Expand Up @@ -148,6 +160,9 @@
"defaultValue": "out.format = 'html', comment = NA, echo = FALSE, results = 'asis', message = F, warning = F",
"description": ""
}
},
"editor": {
"language": "r"
}
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ public static class RegisteredInterpreter {
private String className;
private boolean defaultInterpreter;
private Map<String, InterpreterProperty> properties;
private Map<String, Object> editor;
private String path;

public RegisteredInterpreter(String name, String group, String className,
Expand All @@ -266,6 +267,7 @@ public RegisteredInterpreter(String name, String group, String className,
this.className = className;
this.defaultInterpreter = defaultInterpreter;
this.properties = properties;
this.editor = new HashMap<>();
}

public String getName() {
Expand All @@ -292,6 +294,10 @@ public Map<String, InterpreterProperty> getProperties() {
return properties;
}

public Map<String, Object> getEditor() {
return editor;
}

public void setPath(String path) {
this.path = path;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,9 @@ public void onMessage(NotebookSocket conn, String msg) {
case SAVE_INTERPRETER_BINDINGS:
saveInterpreterBindings(conn, messagereceived);
break;
case EDITOR_SETTING:
getEditorSetting(conn, messagereceived);
break;
default:
break;
}
Expand Down Expand Up @@ -1457,7 +1460,7 @@ public void afterStatusChange(Job job, Status before, Status after) {
}

/**
* This callback is for praragraph that runs on RemoteInterpreterProcess
* This callback is for paragraph that runs on RemoteInterpreterProcess
* @param paragraph
* @param out
* @param output
Expand Down Expand Up @@ -1569,11 +1572,23 @@ public void onRemove(String interpreterGroupId, String name, String noteId, Stri
if (id.equals(interpreterGroupId)) {
broadcast(
note.getId(),
new Message(OP.ANGULAR_OBJECT_REMOVE).put("name", name).put(
"noteId", noteId).put("paragraphId", paragraphId));
new Message(OP.ANGULAR_OBJECT_REMOVE)
.put("name", name)
.put("noteId", noteId)
.put("paragraphId", paragraphId));
}
}
}
}

private void getEditorSetting(NotebookSocket conn, Message fromMessage)
throws IOException {
String replName = (String) fromMessage.get("magic");
String noteId = getOpenNoteId(conn);
Message resp = new Message(OP.EDITOR_SETTING);
resp.put("editor", notebook().getInterpreterFactory().getEditorSetting(noteId, replName));
conn.send(serializeMessage(resp));
return;
}
}

4 changes: 2 additions & 2 deletions zeppelin-web/bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"angular-elastic": "~2.4.2",
"angular-elastic-input": "~2.2.0",
"angular-xeditable": "0.1.12",
"highlightjs": "^9.2.0",
"highlightjs": "^9.4.0",
"lodash": "~3.9.3",
"angular-filter": "~0.5.4",
"ngtoast": "~2.0.0",
Expand Down Expand Up @@ -62,7 +62,7 @@
"highlight.pack.js",
"styles/github.css"
],
"version": "8.4.0",
"version": "9.4.0",
"name": "highlightjs"
}
}
Expand Down
Loading