Skip to content

Commit 4e6608a

Browse files
committed
docs: update docs
1 parent 6f2ff4c commit 4e6608a

File tree

3 files changed

+40
-11
lines changed

3 files changed

+40
-11
lines changed

documentation/Compiler-API.md

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,28 +44,53 @@ const compiled = Wenyan.compile('吾有一言。曰「「問天地好在。」
4444

4545
- core
4646
- [compile](#compile)
47+
- [execute](#execute)
48+
49+
### Execute
50+
51+
[Source](../src/parser.js)
52+
53+
```ts
54+
function execute(source: string, options?: ExecuteOptions)
55+
```
56+
57+
**Parameters**
58+
59+
| Name | Type | Note |
60+
| --- | --- | --- |
61+
| source | string | The Wenyan source code |
62+
| options | object | [Execute Options](#Execute-Options) |
4763

4864
### Compile
4965

5066
[Source](../src/parser.js)
5167

5268
```ts
53-
function compile(targetLang: string, source: string, options?: CompilerOptions)
69+
function compile(source: string, options?: CompilerOptions)
5470
```
5571

5672
**Parameters**
5773

5874
| Name | Type | Note |
5975
| --- | --- | --- |
60-
| targetLang | string | Can be `js`, `py` or `rb` |
6176
| source | string | The Wenyan source code |
6277
| options | object | [Compiler Options](#Compiler-Options) |
6378

64-
### Compiler Options
79+
#### Compiler Options
6580

6681
| Fields | Default Value | Note |
6782
| --- | --- | --- |
83+
| lang | `js` | Target language, can be `js`, `py` or `rb` |
6884
| romanizeIdentifiers | none | Romanize variable identifiers (e.g. `` to `JIA2`) |
6985
| resetVarCnt | false | Reset temporary variable counter |
7086
| logCallback | console.log | Get verbose debug log |
7187
| errorLog | process.exit | Error log |
88+
89+
#### Execute Options
90+
91+
Execute Options extends all field in [Compiler Options](#Compiler-Options)
92+
93+
| Fields | Default Value | Note |
94+
| --- | --- | --- |
95+
| outputHanzi | true | Convert numbers and bools to Hanzi |
96+
| output | `console.log` | You can redirect the output if you don't want to use `console.log` |

documentation/Runtime.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
You can now run Wenyan as normal Javscript script right in your html.
66

7-
[**Check out the demo**](https://jsfiddle.net/antfu/u532ny49/2/)
7+
[**Check out the demo**](https://jsfiddle.net/antfu/u532ny49/)
88

99
## Installation
1010

@@ -47,6 +47,16 @@ You can import remote scripts as you will do for Javascript.
4747
<script type="application/wenyan" src="https://raw.githubusercontent.com/LingDong-/wenyan-lang/master/examples/fizzbuzz.wy"></script>
4848
```
4949

50+
### Outputing Hanzi
51+
52+
By default, it will convert numbers and bools to hanzi. If you want to output raw numbers, you can specify `ouputHanzi="false"` in attr of script tag.
53+
54+
```html
55+
<script type="application/wenyan" ouputHanzi="false">
56+
吾有一數。曰三。書之。
57+
</script>
58+
```
59+
5060
### DOM Hacks
5161

5262
There are some hacks you can do to access the DOM and browser APIs. This allows wenyan to do some realworld applications.

documentation/Testing.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,7 @@
44

55
This project uses [Mocha](https://mochajs.org/) and [Chai](https://www.chaijs.com/) for unit testing and snapshot testing.
66

7-
You will need to build first
8-
9-
```bash
10-
npm run build
11-
```
12-
13-
Then you can run all the tests by
7+
You can run all the tests by
148

159
```bash
1610
npm test

0 commit comments

Comments
 (0)