Skip to content

Commit

Permalink
docs: update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
j178 authored Feb 1, 2023
1 parent 3066b24 commit a3a6ccf
Showing 1 changed file with 50 additions and 46 deletions.
96 changes: 50 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -277,52 +277,56 @@ There are three ways to make cookies available to `leetgo`:

## Advanced Usage

1. Templates
Several fields in leetgo's config file support templating. These fields are often suffixed with `_template`.
You can use custom template to generate your own filename, code, etc.

2. Blocks

A code file is composed of different blocks, you can overwrite some of them to provide your own snippets.
Supported blocks:
- header
- description
- title
- beforeMarker
- beforeCode
- code
- afterCode
- afterMarker

For example:
```yaml
code:
lang: cpp
cpp:
blocks:
- name: beforeCode
template: |
#include <iostream>
using namespace std;
- name: afterMarker
template: |
int main() {}
```

3. Script

`leetgo` supports providing a JavaScript function to handle the code before generation, for example:
```yaml
code:
lang: cpp
cpp:
modifiers:
- name: removeUselessComments
- script: |
function modify(code) {
return "// hello world\n" + code;
}
```
### Templates

Several fields in leetgo's config file support templating. These fields are often suffixed with `_template`.
You can use custom template to generate your own filename, code, etc.

### Blocks

A code file is composed of different blocks, you can overwrite some of them to provide your own snippets.

| Available blocks |
| -- |
| header |
| description |
| title |
| beforeMarker |
| beforeCode |
| code |
| afterCode |
| afterMarker |

For example:
```yaml
code:
lang: cpp
cpp:
blocks:
- name: beforeCode
template: |
#include <iostream>
using namespace std;
- name: afterMarker
template: |
int main() {}
```

### Scripting

`leetgo` supports providing a JavaScript function to handle the code before generation, for example:

```yaml
code:
lang: cpp
cpp:
modifiers:
- name: removeUselessComments
- script: |
function modify(code) {
return "// hello world\n" + code;
}
```

## FAQ

Expand Down

0 comments on commit a3a6ccf

Please sign in to comment.