Skip to content

Commit

Permalink
Create site with documentation #164
Browse files Browse the repository at this point in the history
  • Loading branch information
xonixx committed Mar 4, 2024
1 parent 930c2b9 commit a28a07e
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 48 deletions.
94 changes: 47 additions & 47 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ Example:

### @goal

<ins>Syntax #1:</ins>
#### Simple goal
```
@goal goal_name [ @private ]
```
Expand Down Expand Up @@ -254,7 +254,7 @@ Invoking `./makesure` without arguments will attempt to call the goal named `def
echo "I'm default goal"
```

<ins>Syntax #2:</ins>
#### Glob goal
```
@goal [ goal_name ] @glob <glob pattern> [ @private ]
```
Expand Down Expand Up @@ -320,16 +320,16 @@ to be able to run each test individually (`./makesure test2.js` for example) and

In case if you need to glob the files with spaces in their names, please check the [naming rules section](#naming-rules) below.

### Parameterized goals
#### Parameterized goal

Make code easier to reuse.

<ins>Declaration syntax (using `@params`):</ins>
```shell
```sh
@goal goal_name @params A B C
```
<ins>Usage syntax (using `@args`):</ins>
```shell
```sh
@goal other_goal @params PARAM
@depends_on goal_name @args 'value1' 'value 2' PARAM
```
Expand All @@ -338,7 +338,7 @@ The idea of using two complementary keywords `@params` + `@args` was inspired by

Example:

```shell
```sh
@goal file_downloaded @params FILE_NAME
echo "Downloading $FILE_NAME..."

Expand Down Expand Up @@ -397,7 +397,7 @@ Note, the goal's body parameter values will appear as environment variables (as

Note, you can reference the `@define`-ed variables in the arguments of the parameterized goals:

```shell
```sh
@define HELLO 'hello'

@goal parameterized_goal @params ARG
Expand Down Expand Up @@ -425,6 +425,45 @@ Please find a more real-world example [here](https://github.com/xonixx/fhtagn/bl

For more technical consideration regarding this feature see [parameterized_goals.md](docs/parameterized_goals.md).

#### Naming rules

It's *recommended* that you name your goals using alphanumeric chars + underscore.

However, it's possible to name a goal any way you want provided that you apply proper escaping:

```sh
@goal 'name with spaces' # all chars between '' have literal meaning, same as in shell, ' itself is not allowed in it

@goal $'name that contains \' single quote' # if you need to have ' in a string, use dollar-strings and escape it

@goal usual_name
```

Now `./makesure -l` gives:
```
Available goals:
'name with spaces'
$'name that contains \' single quote'
usual_name
```

Note, how goal names are already escaped in output. This is to make it easier for you to call it directly:
```sh
./makesure $'name that contains \' single quote'
```

Same naming rules apply to other directives (like `@doc`).

Usually you won't need this escaping tricks often, but they can be especially in use for `@glob` goals if the relevant files have spaces in them:

```sh
@goal @glob 'file\ with\ spaces*.txt'
@goal other
@depends_on 'file with spaces1.txt'
```

More info on this topic is covered in the [issue](https://github.com/xonixx/makesure/issues/63).

### @doc

Only valid: inside `@goal`.
Expand Down Expand Up @@ -614,49 +653,10 @@ Only valid: inside `@goal`.

Only single `@use_lib` per goal is allowed.

### Naming rules

It's *recommended* that you name your goals using alphanumeric chars + underscore.

However, it's possible to name a goal any way you want provided that you apply proper escaping:

```sh
@goal 'name with spaces' # all chars between '' have literal meaning, same as in shell, ' itself is not allowed in it

@goal $'name that contains \' single quote' # if you need to have ' in a string, use dollar-strings and escape it

@goal usual_name
```

Now `./makesure -l` gives:
```
Available goals:
'name with spaces'
$'name that contains \' single quote'
usual_name
```

Note, how goal names are already escaped in output. This is to make it easier for you to call it directly:
```sh
./makesure $'name that contains \' single quote'
```

Same naming rules apply to other directives (like `@doc`).

Usually you won't need this escaping tricks often, but they can be especially in use for `@glob` goals if the relevant files have spaces in them:

```sh
@goal @glob 'file\ with\ spaces*.txt'
@goal other
@depends_on 'file with spaces1.txt'
```

More info on this topic is covered in the [issue](https://github.com/xonixx/makesure/issues/63).

## Bash completion
Install Bash completion for `./makesure` locally
```shell
```sh
[[ ! -f ~/.bash_completion ]] && touch ~/.bash_completion
grep makesure ~/.bash_completion >/dev/null || echo '. ~/.makesure_completion.bash' >> ~/.bash_completion
curl "https://raw.githubusercontent.com/xonixx/makesure/main/completion.bash?token=$(date +%s)" -o ~/.makesure_completion.bash
Expand Down
3 changes: 2 additions & 1 deletion mdbooker.awk
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ BEGIN {
/^# / { handleTitle(1); next }
/^## / { handleTitle(2); next }
/^### / { handleTitle(3); next }
/^#### / { print "error: ####"; exit 1 }
/^#### / { handleTitle(4); next }
/^#####/ { print "error: #####"; exit 1 }
{ Content = Content $0 "\n"; next }

function handleTitle(h, md,indent,dir,i,path) {
Expand Down

0 comments on commit a28a07e

Please sign in to comment.