Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: update usage doc with info about --watch flag and absence of --version flag #1142

Merged
merged 7 commits into from
Apr 3, 2024
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 21 additions & 16 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,29 @@ There are two ways to use the generator:
- [Generator library](#using-as-a-modulepackage)

## AsyncAPI CLI
Generates whatever you want using templates compatible with AsyncAPI Generator.
```bash
Usage: asyncapi generate fromTemplate <asyncapi> <template> [<options>]
USAGE
$ asyncapi generate fromTemplate [ASYNCAPI] [TEMPLATE] [-h] [-d <value>] [-i] [--debug] [-n <value>] [-o <value>] [--force-write] [-w] [-p <value>] [--map-base-url <value>]

- <asyncapi>: Local path or URL pointing to AsyncAPI document for example https://bit.ly/asyncapi
- <template>: Name of the generator template like for example @asyncapi/html-template or https://github.com/asyncapi/html-template
ARGUMENTS
ASYNCAPI - Local path, url or context-name pointing to AsyncAPI file
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Florence-Njeri , @derberg
I did "construct" my update by copy/pasting output of asyncapi generate fromTemplate --help. The suggestions break alignment between code and documentation. Do you really want to go that direction?

Alternative: apply suggestions to code (help text) and documentation in parallel. @derberg, can you point me to the help text?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Florence-Njeri normally I like that you want to clarify help with examples, like example link. Problem is that https://bit.ly/asyncapi is no longer the best as it points to asyncapi 2.0.0 and nobody knows who owns this short link and how to update it. So we should not promote it

so correct help is
Local path, name of CLI context or URL pointing to AsyncAPI document

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eelcofolkertsma we can accept the update here now and if you could followup with PR to fix in in CLI in https://github.com/asyncapi/cli/blob/master/src/commands/generate/fromTemplate.ts#L106 that would be awesome

TEMPLATE - Name of the generator template like for example @asyncapi/html-template or https://github.com/asyncapi/html-template

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@derberg correct me if I am wrong but I feel the changes being made to this file might be unnecessary especially this part asyncapi generate fromTemplate [ASYNCAPI] [TEMPLATE] [-h] [-d <value>] [-i] [--debug] [-n <value>] [-o <value>] [--force-write] [-w] [-p <value>] [--map-base-url <value>] why not just leave it as was asyncapi generate fromTemplate <asyncapi> <template> [<options>]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See earlier argument. Keep documentation in sync with help-output generated from code

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I think in this particular case good to follow the output from CLI that is following best practices

- <options>:
-V, --version output the generator version
-d, --disable-hook [hooks...] disable a specific hook type or hooks from a given hook type
--debug enable more specific errors in the console
-i, --install install the template and its dependencies (defaults to false)
-n, --no-overwrite <glob> glob or path of the file(s) to skip when regenerating
-o, --output <outputDir> directory to put the generated files (defaults to current directory)
-p, --param <name=value> additional parameters to pass to templates
--force-write force writing of the generated files to a given directory even if it is a Git repository with unstaged files or not empty dir (defaults to false)
--watch-template watches the template directory and the AsyncAPI document, and re-generates the files when changes occur. Ignores the output directory. This flag should be used only for template development.
--map-base-url <url:folder> maps all schema references from base URL to local folder
-h, --help display help for command
FLAGS
-d, --disable-hook=<value>... Disable a specific hook type or hooks from a given hook type
-h, --help Show CLI help.
-i, --install Installs the template and its dependencies (defaults to false)
-n, --no-overwrite=<value>... Glob or path of the file(s) to skip when regenerating
-o, --output=<value> Directory where to put the generated files (defaults to current directory)
-p, --param=<value>... Additional param to pass to templates
-w, --watch Watches the template directory and the AsyncAPI document, and re-generate the files when changes occur. Ignores the output directory.
--debug Enable more specific errors in the console
--force-write Force writing of the generated files to given directory even if it is a git repo with unstaged files or not empty dir (defaults to false)
--map-base-url=<value> Maps all schema references from base url to local folder

EXAMPLES
$ asyncapi generate fromTemplate asyncapi.yaml @asyncapi/html-template --param version=1.0.0 singleFile=true --output ./docs --force-write
```

All templates are installable npm packages. Therefore, the value of `template` can be anything supported by `npm install`. Here's a summary of the possibilities:
Expand Down Expand Up @@ -149,4 +154,4 @@ try {
}
```

See the [API documentation](api) for more examples and full API reference information.
See the [API documentation](api) for more examples and full API reference information.
Loading