Skip to content

Commit 30d9c1c

Browse files
Merge branch 'main' into feature/wikiRunnerExecuteCommand
2 parents a9d3b3b + be74445 commit 30d9c1c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1303
-513
lines changed

documentation/Definition of DONE.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# **General**
2+
* I kept the name of my tutorial short. For a small explanation of my tutorial, I used sub-topics.
3+
* I described what I wanted to train in a few words and clearly state the objective of my tutorial. This should give the reader an idea of what to expect from my tutorial and help them to determine if they really want to learn this topic.
4+
* I addressed the user directly.
5+
* I was clear and concise in my writing.
6+
* I provided links for further related topics.
7+
* I did not just copy and paste the documentation into a tutorial. I broke down the information into smaller and more simple packages.
8+
* I want to teach something. Therefore, I did not just write down the steps and results but explained why this step was necessary.
9+
* I rather made many small steps than a few big steps.
10+
* I used images and code examples in my tutorial which were provided in the devonfw documentation. Plain text gets boring after time.
11+
* I used an organized structure in my tutorial.
12+
* All the things that the user should do actively, I have always written with function calls and steps . I have not given any instructions for action in text form.
13+
* I proofread my tutorial:
14+
1. Are the steps available and in the correct order?
15+
1. Are there any spelling mistakes?
16+
1. Does everything make sense?
17+
* I ran through the latest update of my tutorial in Katacoda-Dev and checked if everything was working as intended BEFORE requesting a review.
18+
19+
# **Technical**
20+
* The files that were used in `nextKatacodaStep `are available in `.asciidoc` files and do not contain Katacoda Syntax. `nextKatacodaStep` is almost never needed.
21+
* Commands like `--- cd devonfw {{execute T1}} ---` should not be used, as it could break certain functions.
22+
23+
# Different types of tutorials
24+
* “Learning”: The user gets a detailed explanation of certain code/feature/functionality.
25+
* “Quick Start”: Implementing code/feature without comprehensive explanation
26+
* “Try Out”: The user gets a working sample project (like MyThaiStar), suitable for showcasing functionalities and ease of use.
27+
28+
# **Additional things to consider**
29+
30+
### Only for Learning-tutorials:
31+
32+
* I provided a detailed explanation of the topic in a way, that everybody can understand it.
33+
* I used more theory and less practice.
34+
35+
### Only for Quick Start-tutorials:
36+
37+
* I implemented a certain functionality straightforward without any comprehensive explanation.
38+
* I emphasized practice, and used less theory.
39+
* I only provided the information which is really needed to understand what I did in the tutorial.
40+
* For comprehensive explanation of the everything what I have done in the tutorial, I provide links to either the devonfw documentation or the specific Learning-tutorial of the topic (if there is any).
41+
42+
### Only for Try Out-tutorials:
43+
44+
* I wanted to showcase a certain sample project/feature and its capabilities in a fast and straightforward way to the reader. Example: Tutorial for launching MyThaiStar, so the reader can click through it, and see what is possible.
45+
* I provided little explanation of the things done in the tutorial.

documentation/Functions.md

Lines changed: 654 additions & 290 deletions
Large diffs are not rendered by default.

documentation/Home.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
To download and setup the tutorial-compiler use the description in the setup section.<br/>
44
[Setup](https://github.com/devonfw-tutorials/tutorial-compiler/wiki/Setup)
55

6+
If you want to know if your tutorial meets the general requirements, check out the Definition of DONE<br/>
7+
[Definition of DONE](https://github.com/devonfw-tutorials/tutorial-compiler/wiki/Definition-of-DONE)
8+
69
The Development section may help you to contribute code to the tutorial-compiler.<br/>
710
[Development](https://github.com/devonfw-tutorials/tutorial-compiler/wiki/Development)
811

documentation/Structure.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,12 @@
1111
|-- tutorials
1212
|-- [playbook-name]
1313
/--index.asciidoc
14+
|-- images
15+
/--image.jpg
16+
1417

15-
Write your own tutorials in "./tutorials/[playbook-name]/index.asciidoc".
18+
19+
Write your own tutorials in "./tutorials/[playbook-name]/index.asciidoc". Images must be saved in a folder called `images`.
1620
You will find all the details in the tutorials [Developement](https://github.com/devonfw-tutorials/tutorials/wiki/Development) page.
1721

1822

documentation/Tutorials.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Every tutorial has three main parts
99
* at least one step
1010
Additionally, there are optional parts
1111
* a subtitle
12+
* tags
1213
* a conclusion of the tutorial. This will be shown at the last page and can be used to summarize the learned, to foreshadow the next steps on the learning path or to mention useful sources.
1314

1415
The tutorials are written in asciidoc files.
@@ -94,6 +95,22 @@ functionName2(parameters)
9495
--
9596
```
9697

98+
To display images within a step, you can use either the [displayContent](https://github.com/devonfw-tutorials/tutorial-compiler/wiki/Functions#displayContent) function or the following syntax in the index.asciidoc file:
99+
```
100+
![alternative text](./assets/image.jpg)
101+
```
102+
The image must be in a folder called `images` in the folder of the playbook (see [Structure](https://github.com/devonfw-tutorials/tutorial-compiler/wiki/Structure)).
103+
104+
There is the option to add tags to your tutorials. To do that, you have to add the following syntax after the title or if you have specified a subtitle, after the subtitle.
105+
106+
````
107+
[tags]
108+
--
109+
tagType=tag0;tag1
110+
tagType=tag0;tag1;tag2
111+
--
112+
```
113+
97114
You can also add an optional conclusion text, which is shown on completion of the tutorial. Use this to summarize the important content of the tutorial, to point out what to learn next or to mention other useful informations.
98115
99116
To do that, you have to provide the conclusion at the end of the tutorial (after the last step) surrounded by ```====```.
@@ -110,11 +127,17 @@ These blocks are combined to a complete tutorial.
110127
```
111128
= Title
112129
== Subtitle
130+
[tags]
131+
--
132+
tagType=tag0;tag1
133+
tagType=tag0;tag1;tag2
134+
--
113135
====
114136
Description of the tutorial
115137
====
116138
117139
The explanation for the step 1
140+
![alternative text](./assets/image.jpg)
118141
[step]
119142
--
120143
functionName1(parameters)

engine/parser.def

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
start
22
= headline
33
subtitle?
4+
tags?
45
description
56
steps
67
conclusion?
7-
8+
89
headline "headline starting with ="
910
= "=" _ string ___
1011

@@ -83,6 +84,18 @@ conclusionlines
8384
conclusionline
8485
= !blockmarker string __
8586

87+
tags
88+
= "[tags]" ___
89+
"--" ___
90+
taglines
91+
"--" __
92+
93+
taglines
94+
= tagline+ { return { "taglines": text()}; }
95+
96+
tagline
97+
= !"--" string __
98+
8699
string "string"
87100
= [^\r\n]+ { return text(); }
88101

engine/parser.ts

Lines changed: 47 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ export class Parser {
2020
let result = new Playbook();
2121
result.title = parseResult[0][2];
2222
result.subtitle = parseResult[1]? parseResult[1][3]: "";
23-
result.description = parseResult[2][2].descriptionlines;
24-
result.conclusion = parseResult[4]? parseResult[4][2].conclusionlines: "";
25-
for(let index in parseResult[3]){
23+
result.tags = this.getTags(parseResult);
24+
result.description = this.insertNewlineIntoDescription(parseResult[3][2].descriptionlines);
25+
result.conclusion = this.insertNewlineIntoDescription(parseResult[5]? parseResult[5][2].conclusionlines: "");
26+
for(let index in parseResult[4]){
2627
let step = new Step();
2728
step.text = this.getText(parseResult, index);
2829
step.lines = this.getLines(parseResult, index);
@@ -35,26 +36,26 @@ export class Parser {
3536

3637
getText(parseResult, index){
3738
try {
38-
return parseResult[3][index][1].steptextlines || parseResult[3][index][2][1].steptextlines;
39+
return parseResult[4][index][1].steptextlines || parseResult[4][index][2][1].steptextlines;
3940
} catch (error) {
40-
return parseResult[3][index][2][1].steptextlines;
41+
return parseResult[4][index][2][1].steptextlines;
4142
}
4243
}
4344

4445
getLines(parseResult, index):Command[]{
4546
let linebreak = process.platform=="win32" ? "\r\n" : "\n";
4647
try {
47-
return (parseResult[3][index][7].steplines || parseResult[3][index][2][7].steplines).split(linebreak).filter(e => e.trim() != '').map(e => this.createCommand(e));
48+
return (parseResult[4][index][7].steplines || parseResult[4][index][2][7].steplines).split(linebreak).filter(e => e.trim() != '').map(e => this.createCommand(e));
4849
} catch (error) {
49-
return parseResult[3][index][2][7].steplines.split(linebreak).filter(e => e.trim() != '').map(e => this.createCommand(e));
50+
return parseResult[4][index][2][7].steplines.split(linebreak).filter(e => e.trim() != '').map(e => this.createCommand(e));
5051
}
5152
}
5253

5354
getTitle(parseResult, index) {
5455
try {
5556
// parseResult[3][index][4][2] step without block
5657
// parseResult[3][index][2][4][2] step inside a block
57-
return (parseResult[3][index][4][2].steptitle || parseResult[3][index][2][4][2].steptitle);
58+
return (parseResult[4][index][4][2].steptitle || parseResult[4][index][2][4][2].steptitle);
5859
} catch(error) {
5960
return null;
6061
}
@@ -76,9 +77,46 @@ export class Parser {
7677

7778
getTextAfter(parseResult, index){
7879
try {
79-
return parseResult[3][index][3].steptextafterlines || "";
80+
return parseResult[4][index][3].steptextafterlines || "";
8081
} catch (error) {
8182
return "";
8283
}
8384
}
85+
86+
getTags(parseResult){
87+
let tagDict = {};
88+
try{
89+
let results = parseResult[2] ? parseResult[2][4].taglines.split(/\r?\n/) : Array();
90+
for (let result of results){
91+
if(result){
92+
result = result.split("=")
93+
let type = result[0];
94+
let tags = result[1].includes(";") ? result[1].split(";") : Array(result[1]);
95+
tagDict[type] = tags;
96+
}
97+
}
98+
}catch (error) {
99+
throw error;
100+
}
101+
return tagDict;
102+
}
103+
104+
insertNewlineIntoDescription(description: string): string{
105+
let result = description;
106+
let offset = 0;
107+
for(let i = 0; i < description.length-1; i++){
108+
if(description[i] == '#' && description[i+1] == '#' && description[i+2] == '#'){
109+
let temp = result.slice(0,i+offset);
110+
result = temp +"\n"+result.slice(i+offset);
111+
offset++;
112+
}
113+
if(description[i] == '*'){
114+
let temp = result.slice(0,i+offset);
115+
result = temp +"\n"+result.slice(i+offset);
116+
offset++;
117+
}
118+
119+
}
120+
return result;
121+
}
84122
}

engine/playbook.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ export class Playbook{
88
public description: string;
99
public conclusion: string;
1010
public steps: Step[] = [];
11+
public tags: Record<string, string[]>;
1112
}

engine/wikiRunner.ts

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,30 @@
11
import { Runner } from "./runner";
22
import { Playbook } from "./playbook";
3+
import { RunCommand } from "./run_command";
34
import * as fs from "fs";
45
import * as path from "path";
56
import * as ejs from "ejs";
67

78
export abstract class WikiRunner extends Runner {
89

910
public outputPathTutorial: string;
11+
public commandCntMap = new Map();
12+
13+
protected readonly INSTALLED_TOOLS: string = "installedTools";
1014
protected fileTypeMap = new Map([ [".java", "java"],[".ts", "typescript"],
1115
[".js", "javascript"], [".html", "html"],
1216
[".scss", "css"], [".asciidoc", "asciidoc"], ]);
13-
protected readonly INSTALLED_TOOLS: string = "installedTools";
17+
1418

1519

1620
init(playbook: Playbook): void {
1721
let outputDirectory = this.createFolder(path.join(this.getOutputDirectory(), "wiki", this.environmentName), false)
1822
this.outputPathTutorial = this.createFolder(path.join(outputDirectory, playbook.name), true);
1923
this.setVariable(this.WORKSPACE_DIRECTORY, path.join(this.getWorkingDirectory()));
2024
this.setVariable(this.INSTALLED_TOOLS, "");
25+
for(let i = 0; i< playbook.steps.length; i++){
26+
this.commandCntMap.set(i, playbook.steps[i].lines.length-1);
27+
}
2128
}
2229

2330
async destroy(playbook: Playbook): Promise<void> {
@@ -31,4 +38,22 @@ export abstract class WikiRunner extends Runner {
3138
fs.writeFileSync(tempFile, result, { flag: "a" });
3239
}
3340

41+
protected checkForText(runCommand: RunCommand): string{
42+
return runCommand.lineIndex == 0
43+
? runCommand.text
44+
: undefined;
45+
}
46+
47+
protected checkForTitle(runCommand: RunCommand): string{
48+
return runCommand.lineIndex == 0
49+
? runCommand.stepTitle
50+
: undefined;
51+
}
52+
53+
protected checkForTextAfter(runCommand: RunCommand): string{
54+
return this.commandCntMap.get(runCommand.stepIndex) == runCommand.lineIndex
55+
? runCommand.textAfter
56+
: undefined;
57+
}
58+
3459
}

runners/console/index.ts

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ export class Console extends Runner {
413413
return result;
414414
}
415415

416-
runNextKatacodaStep(runCommand: RunCommand): RunResult {
416+
runDisplayContent(runCommand: RunCommand): RunResult {
417417
//Only needed for katacoda and wiki runner
418418
return null;
419419
}
@@ -591,8 +591,8 @@ export class Console extends Runner {
591591
.noErrorCode(result)
592592
.noException(result)
593593
.directoryExits(path.join(this.getWorkingDirectory(), "devonfw", "software", "cobigen-cli"))
594-
.fileExits(path.join(this.getWorkingDirectory(), "devonfw", "software", "cobigen-cli", "cobigen.jar"))
595-
.fileExits(path.join(this.getWorkingDirectory(), "devonfw", "software", "cobigen-cli", "cobigen"));
594+
.fileExits(path.join(this.getWorkingDirectory(), "devonfw", "software", "cobigen-cli", "lib", "cli.jar"))
595+
.fileExits(path.join(this.getWorkingDirectory(), "devonfw", "software", "cobigen-cli", "bin", "cobigen"));
596596
} catch(error) {
597597
await this.cleanUp();
598598
throw error;
@@ -941,16 +941,6 @@ export class Console extends Runner {
941941
for(let asyncProcess of this.asyncProcesses) {
942942
killProcessesRecursively(systemProcesses, asyncProcess.pid);
943943
}
944-
}
945-
for(let proc of systemProcesses){
946-
if(path.normalize(proc.path).includes(path.normalize(this.getWorkingDirectory()))){
947-
try {
948-
process.kill(proc.pid);
949-
} catch(e) {
950-
console.error("Error killing process "+proc.name+" with id: " + proc.pid , e);
951-
}
952-
}
953-
}
954944
//Check if there are still running processes on the given ports
955945
// Maybe not needed anymore can be deleted and the function documentation should be updated
956946
for(let asyncProcess of this.asyncProcesses.reverse()) {
@@ -964,10 +954,19 @@ export class Console extends Runner {
964954
}
965955
}
966956
}
967-
}
968-
969-
957+
}
958+
}
959+
systemProcesses = await snapshot("name", "pid", "ppid", "path");
960+
for(let proc of systemProcesses){
961+
if(path.normalize(proc.path).includes(path.normalize(this.getWorkingDirectory()))){
962+
try {
963+
process.kill(proc.pid);
964+
} catch(e) {
965+
console.error("Error killing process "+proc.name+" with id: " + proc.pid , e);
966+
}
967+
}
970968
}
969+
}
971970

972971
private async cleanUp(): Promise<void> {
973972
await this.killAsyncProcesses();

0 commit comments

Comments
 (0)