Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions documentation/Functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ createDevon4jProject("com.mycustomer.myapplication")

### buildJava <a name="buildJava"></a>
#### parameter
1. The project directory
1. The project directory, relative to workspace.
2. (Optional) Indicator whether tests should be run. Default is false.
#### example
buildJava("cobigenexample", true)
Expand Down Expand Up @@ -323,7 +323,7 @@ downloadFile("https://bit.ly/2BCkFa9", "file", "downloads")

### buildNg <a name="buildNg"></a>
#### parameter
1. Path to the angular project relative to workspace
1. Path to the angular project, relative to workspace
2. (Optional) Custom output directory.
#### example
buildNg("exampleAngularProject")
Expand Down Expand Up @@ -364,6 +364,7 @@ Available attributes in the json objects:
2. content: Plain text to be displayed in the Katacoda step. This Text should be following the formating of asciidoc files.
3. image: Path to an image to be displayed in the Katacoda step.


#### Formatting rules for content and .asciidoc or .txt files.
* You can add headers to structure your text. The generated headers are shown in the examples below. The headers should fit into the overall structure of the generated wiki so level 1 header are not allowed, but the other header can be used at your judgement.
* A list always needs an empty newline between the last row and the list.
Expand Down
23 changes: 21 additions & 2 deletions engine/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ export class Parser {
let result = new Playbook();
result.title = parseResult[0][2];
result.subtitle = parseResult[1]? parseResult[1][3]: "";
result.description = parseResult[2][2].descriptionlines;
result.conclusion = parseResult[4]? parseResult[4][2].conclusionlines: "";
result.description = this.insertNewlineIntoDescription(parseResult[2][2].descriptionlines);
result.conclusion = this.insertNewlineIntoDescription(parseResult[4]? parseResult[4][2].conclusionlines: "");
for(let index in parseResult[3]){
let step = new Step();
step.text = this.getText(parseResult, index);
Expand Down Expand Up @@ -81,4 +81,23 @@ export class Parser {
return "";
}
}

insertNewlineIntoDescription(description: string): string{
let result = description;
let offset = 0;
for(let i = 0; i < description.length-1; i++){
if(description[i] == '#' && description[i+1] == '#'){
let temp = result.slice(0,i+offset);
result = temp +"\n"+result.slice(i+offset);
offset++;
}
if(description[i] == '*'){
let temp = result.slice(0,i+offset);
result = temp +"\n"+result.slice(i+offset);
offset++;
}

}
return result;
}
}
3 changes: 2 additions & 1 deletion runners/katacoda/templates/intro.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<%= description; %>


<% if(tutorialPath){ %>
The definition of each step of this tutorial can be found at https://github.com/devonfw-tutorials/tutorials/tree/main/<%= tutorialPath; %>. <% } %>

Feel free to report any errors to us or fix them yourself. Errors can be reported by creating an issue in the https://github.com/devonfw-tutorials/tutorials/issues[tutorials repository]. To fix the error fork the repository and create a pull request. Errors in the wiki can be reported and fixed in the https://github.com/devonfw-tutorials/tutorial-compiler[Tutorial-compiler repository].
You can find a description of what to look for when creating a pull request at the devonfw contribution guide: https://devonfw.com/website/pages/community/community.html#community.asciidoc_contributing-to-devonfw. If you want to create a tutorial you can start with the https://katacoda.com/devonfw/scenarios/create-your-own-tutorial[katacoda tutorial] and read the description for creating your own tutorials: https://github.com/devonfw-tutorials/tutorials/wiki/Development.

<%= description; %>
21 changes: 14 additions & 7 deletions runners/wikiConsole/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { RunCommand } from "../../engine/run_command";
import { RunResult } from "../../engine/run_result";
import { WikiRunner } from "../../engine/wikiRunner";
import * as path from "path";
import * as fs from "fs";
import * as fs from "fs-extra";


export class WikiConsole extends WikiRunner {
Expand Down Expand Up @@ -181,27 +181,34 @@ export class WikiConsole extends WikiRunner {
runDisplayContent(runCommand: RunCommand): RunResult {
let text = this.checkForText(runCommand);
let textAfter = this.checkForTextAfter(runCommand);
this.checkForText(runCommand);
this.checkForTextAfter(runCommand);
let stepTitle = this.checkForTitle(runCommand);
let tempFile = path.join(this.getTempDirectory(), runCommand.command.name + ".md");
fs.writeFileSync(tempFile, "");
let counter = 2;
Comment thread
GuentherJulian marked this conversation as resolved.
for(let i = 0; i < runCommand.command.parameters[1].length; i++) {
let param = runCommand.command.parameters[1][i];
if(param.content) {
fs.appendFileSync(tempFile, param.content);
} else if(param.file) {
fs.appendFileSync(tempFile, fs.readFileSync(path.join(this.playbookPath, param.file), "utf-8"));
} else if (param.image) {
let image = path.join(this.playbookPath, param.image);
fs.appendFileSync(tempFile, "![" + path.basename(image) + "](./assets/" + path.basename(image) + ")");
this.createFolder(path.join(this.outputPathTutorial, "images"), false);
let imageName = path.join(this.outputPathTutorial, "images",path.basename(param.image));
while(fs.existsSync(imageName)){
imageName = path.join(this.outputPathTutorial, "images",path.parse(param.image).name+"_"+counter+path.parse(param.image).ext);
counter++;
}
fs.copyFileSync(path.join(this.playbookPath, param.image),imageName);
fs.appendFileSync(tempFile, "image::images/"+path.basename(imageName)+"[]");
}
fs.appendFileSync(tempFile, "\n\n");
}

let content = fs.readFileSync(tempFile, "utf-8");
this.renderWiki(path.join(this.getRunnerDirectory(), "templates", "displayContent.asciidoc"),
{ title: runCommand.command.parameters[0], content: content, path: runCommand.command.parameters[2], text: text, textAfter: textAfter});

this.renderWiki(path.join(this.getRunnerDirectory(), "templates", "displayContent.asciidoc"),
{ steptitle: stepTitle, text: text, textAfter: textAfter, title: runCommand.command.parameters[0], content: content, path: runCommand.command.parameters[2]});

return null;
}

Expand Down
10 changes: 8 additions & 2 deletions runners/wikiConsole/templates/displayContent.asciidoc
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
== <%= title; %>
<%if(text){%><%- text; %><%}%>
<% if(steptitle){ %>== <%= steptitle;%>
=== <%= title; %>
<%if(text){%><%- text; %> <%}%>
<%}else if(steptitle === undefined){%>=== <%= title; %>
<%if(text){%><%- text; %> <%}%>
<%}else if(steptitle === null){ %>== <%= title; %>
<%if(text){%><%- text; %><%}%> <%}%>

<%= content; %>

Expand All @@ -8,3 +13,4 @@ After that, move to the target directory by executing `cd <%= path; %>` in the
<% } %>

<%if(textAfter){%><%- textAfter; %><%}%>

2 changes: 1 addition & 1 deletion runners/wikiConsole/templates/npmInstall.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ You can install the package <%= npmCommand.name; %><% if(!npmCommand.global){ %>
You need to be located in the project directory where the package.json file lies.
For this tutorial it is `<%= projectPath; %>`. You can either move there manually and open the terminal there or open the terminal and move there by executing `cd <%= projectPath; %>`.<% } %>

Now execute `npm install<% if(npmCommand.global){ %> -g<% } %> <%= npmCommand.args; %> <%= npmCommand.name; %>` in the terminal.
Now execute `npm install<% if(npmCommand.global){ %> -g<% } %><% if(npmCommand.args){%> <%= npmCommand.args; %><% } %><%if(npmCommand.name){ %> <%= npmCommand.name; %><%}%>` in the terminal.

<% if(npmCommand.global){ %>Due to the argument '-g' the package will be installed globally.<% } %>
This may take some time.
Expand Down