Skip to content

Commit 9106921

Browse files
author
Albert Schimpf
committed
Text filter & template generator
1 parent ea83548 commit 9106921

3 files changed

Lines changed: 37 additions & 4 deletions

File tree

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ plugins {
33
}
44

55
group = 'scraper.docgen'
6-
version = '0.12.0'
6+
version = '0.13.2'
77
sourceCompatibility = '1.11'
88

99
repositories {

src/main/java/scraper/doclet/HtmlGenerator.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ private static ContainerTag[] sideFilter() {
6565
}
6666

6767
private static ContainerTag[] sideTextFilter() {
68-
// Function<String, String> filter = f -> rawHtml("onclick=\"filterNodes('" + f + "')\"").render();
6968
return List.of(
7069
div(input().withPlaceholder("Name...").withClass("filter-area"))
7170
).toArray(new ContainerTag[0]);

src/main/resources/scraper/doclet/script.js

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,18 @@ function showDoc(e) {
5757
doc.innerHTML = node["doc"]["txt"];
5858
document.getElementById('main').appendChild(doc);
5959

60+
61+
6062
document.getElementById('main').appendChild(document.createElement('hr'));
63+
let template = document.createElement('h4');
64+
template.innerHTML = "Template";
65+
let templatePre = document.createElement('pre');
66+
if(e !== "Node" && e !== "FunctionalNode" && e !== "StreamNode") templatePre.innerText = "type: " + e + "\n";
67+
template.appendChild(templatePre);
68+
document.getElementById('main').appendChild(template);
6169

70+
71+
document.getElementById('main').appendChild(document.createElement('hr'));
6272
let fields = document.createElement('h4');
6373
fields.innerHTML = "Configuration";
6474
document.getElementById('main').appendChild(fields);
@@ -67,13 +77,22 @@ function showDoc(e) {
6777
let fieldsDiv = document.createElement('div');
6878
fieldsDiv.id = 'fields';
6979
document.getElementById('main').appendChild(fieldsDiv);
70-
addFields(node);
80+
81+
82+
addFields(node, templatePre);
7183

7284
window.location.hash = e;
7385
}
7486

75-
function addFields(node) {
87+
function addFields(node, templatePre) {
88+
89+
7690
for (let i = 0; i < node['fields'].length; i++) {
91+
let isMandatory = false;
92+
let defaultValue = null;
93+
let fieldName;
94+
95+
7796
let field = document.createElement('div');
7897
field.classList.add('field');
7998

@@ -82,13 +101,15 @@ function addFields(node) {
82101
name.innerHTML = node['fields'][i]['name'];
83102
name.classList.add('fieldName');
84103
field.appendChild(name);
104+
fieldName = node['fields'][i]['name'];
85105
}
86106
{
87107
let defaultVal = document.createElement('span');
88108
if(node['fields'][i]['defaultValue'] !== 'null') {
89109
defaultVal.innerHTML = node['fields'][i]['defaultValue'];
90110
defaultVal.classList.add('defaultValue');
91111
field.appendChild(defaultVal);
112+
defaultValue = node['fields'][i]['defaultValue'];
92113
}
93114

94115
}
@@ -110,6 +131,7 @@ function addFields(node) {
110131
if(mandatory === 'true') {
111132
tag.classList.add('mandatory');
112133
tag.innerHTML = 'mandatory';
134+
isMandatory = true;
113135
} else {
114136
tag.classList.add('optional');
115137
tag.innerHTML = 'optional';
@@ -141,6 +163,18 @@ function addFields(node) {
141163
}
142164

143165
document.getElementById('fields').appendChild(field);
166+
167+
168+
// create template pre text
169+
if(fieldName !== "type") {
170+
templatePre.innerText = templatePre.innerText
171+
+ (isMandatory?"":"#")
172+
+ fieldName +": "
173+
+ (defaultValue !== null ? defaultValue : "")
174+
+ "\n"
175+
;
176+
}
177+
144178
}
145179

146180
}

0 commit comments

Comments
 (0)