Skip to content

Commit cc89864

Browse files
committed
docs: update CLI docs with feature related to #240 and querySelector option
1 parent 2988304 commit cc89864

File tree

2 files changed

+37
-11
lines changed

2 files changed

+37
-11
lines changed

README.cli.md

+30-11
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,35 @@
11
# Command Line Interface
22

33
```shell
4-
let targetElement_000 = document.querySelector(`:root > body`);
4+
let targetElement_001 = document.querySelector(`:root > body`);
55

66

7-
let div_000 = document.createElement('div');
8-
let text_000 = document.createTextNode(`I am a `);
9-
div_000.appendChild(text_000);
7+
let div_001 = document.createElement('div');
8+
let text_001 = document.createTextNode(`I am a `);
9+
div_001.appendChild(text_001);
1010

11-
let strong_000 = document.createElement('strong');
12-
let text_001 = document.createTextNode(`tea pot`);
13-
strong_000.appendChild(text_001);
14-
div_000.appendChild(strong_000);
15-
targetElement_000.appendChild(div_000);
11+
let strong_001 = document.createElement('strong');
12+
let text_002 = document.createTextNode(`tea pot`);
13+
strong_001.appendChild(text_002);
14+
div_001.appendChild(strong_001);
15+
targetElement_001.appendChild(div_001);
1616
```
1717

1818
---
1919

2020
`jsgenerator` has several options that can be used in a console here is an example of use below
2121

2222
```text
23-
Usage: jsgenerator [-htV] [-e=<extension>] [--inline-pattern=<inlinePattern>]
23+
Usage: jsgenerator [-chtV] [-qs] [-e=<extension>]
24+
[--inline-pattern=<inlinePattern>]
2425
[-k=<variableDeclaration>] [--path-pattern=<pathPattern>]
2526
[-s=<targetElementSelector>]
2627
[--stdin-pattern=<stdinPattern>]
2728
[--variable-name-generation-strategy=<builtinVariableNameStra
2829
tegy>] [-i=<inlineContents>...]... [<paths>...]
2930
Translating files, stdin or inline from HTML to JS
3031
[<paths>...] file paths to translate content, parsed as HTML
32+
-c, --comment optional comments
3133
-e, --ext=<extension> output files' extension
3234
-h, --help Show this help message and exit.
3335
-i, --inline=<inlineContents>...
@@ -38,6 +40,23 @@ Translating files, stdin or inline from HTML to JS
3840
variable declaration keyword
3941
--path-pattern=<pathPattern>
4042
pattern for path-based output filenames
43+
-qs, --query-selector
44+
What the browser renders depends on whether "document.
45+
querySelector(':root > body')" is added to the
46+
output. If added, the browser will render the
47+
output successfully, it is useful for debugging
48+
purpose,
49+
to verify that the js output matches what the
50+
html input does.
51+
If not, if the user tries to run the output as
52+
it is then the browser will not be able to render,
53+
it will show a blank page.
54+
So, it depends on what the user wants to do with
55+
the output.
56+
"https://jsfiddle.net/", "https://codepen.
57+
io/pen/" and Browser Console help to give a quick
58+
feedback.
59+
4160
-s, --selector=<targetElementSelector>
4261
Target element selector
4362
--stdin-pattern=<stdinPattern>
@@ -46,4 +65,4 @@ Translating files, stdin or inline from HTML to JS
4665
-V, --version Print version information and exit.
4766
--variable-name-generation-strategy=<builtinVariableNameStrategy>
4867
Variable names generation strategy
49-
```
68+
```

README.md

+7
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,13 @@ mvn --also-make --projects jsgenerator-cli clean spring-boot:run -Dspring-boot.r
114114

115115
# For example:
116116
mvn --also-make --projects :jsgenerator-cli clean spring-boot:run -Dspring-boot.run.arguments="--tty --inline '<div>I am a <strong>tea pot</strong></div>'"
117+
118+
# It's also possible to create the jar first
119+
mvn clean package
120+
121+
# then run the following commands and replace {version} by the current one (0.0.1-SNAPSHOT at this time)
122+
java -jar jsgenerator-cli/target/jsgenerator-cli-{version}.jar # java -jar jsgenerator-cli/target/jsgenerator-cli-{version}.jar --help
123+
java -jar jsgenerator-cli/target/jsgenerator-cli-{version}.jar --tty --inline '<div>I am a <strong>tea pot</strong></div>'
117124
```
118125

119126
## Packaging

0 commit comments

Comments
 (0)