From 51afa538b9dc3df50cb15970b19aece54480f851 Mon Sep 17 00:00:00 2001 From: David Bieber Date: Fri, 9 Dec 2022 17:11:58 -0500 Subject: [PATCH] Update documentation to show new serialize kwarg and to clean up misformatted tables (#419) * Shows new serialize kwarg * Cleans up misformatted tables --- docs/api.md | 59 ++++++++++++-------------------------------- docs/guide.md | 13 +++++++++- docs/index.md | 3 ++- docs/installation.md | 4 +-- 4 files changed, 32 insertions(+), 47 deletions(-) diff --git a/docs/api.md b/docs/api.md index 66451071..aae92cd6 100644 --- a/docs/api.md +++ b/docs/api.md @@ -1,37 +1,23 @@ ## Python Fire Quick Reference | Setup | Command | Notes -| :------ | :------------------ | :--------- -| install | `pip install fire` | +| ------- | ------------------- | ---------- +| install | `pip install fire` | Installs fire from pypi | Creating a CLI | Command | Notes -| :--------------| :--------------------- | :--------- +| ---------------| ---------------------- | ---------- | import | `import fire` | | Call | `fire.Fire()` | Turns the current module into a Fire CLI. | Call | `fire.Fire(component)` | Turns `component` into a Fire CLI. -| Using a CLI | Command | Notes | -| :----------------------------------------- | :------------- | :------------- | -| [Help](using-cli.md#help-flag) | `command | Show the help | -: : --help` : screen. : -| [REPL](using-cli.md#interactive-flag) | `command -- | Enters | -: : --interactive` : interactive : -: : : mode. : -| [Separator](using-cli.md#separator-flag) | `command -- | This sets the | -: : --separator=X` : separator to : -: : : `X`. The : -: : : default : -: : : separator is : -: : : `-`. : -| [Completion](using-cli.md#completion-flag) | `command -- | Generate a | -: : --completion : completion : -: : [shell]` : script for the : -: : : CLI. : -| [Trace](using-cli.md#trace-flag) | `command -- | Gets a Fire | -: : --trace` : trace for the : -: : : command. : -| [Verbose](using-cli.md#verbose-flag) | `command -- | | -: : --verbose` : : +| Using a CLI | Command | Notes | +| ------------------------------------------ | ----------------- | -------------- | +| [Help](using-cli.md#help-flag) | `command --help` | Show the help screen. | +| [REPL](using-cli.md#interactive-flag) | `command -- --interactive` | Enters interactive mode. | +| [Separator](using-cli.md#separator-flag) | `command -- --separator=X` | This sets the separator to `X`. The default separator is `-`. | +| [Completion](using-cli.md#completion-flag) | `command -- --completion [shell]` | Generate a completion script for the CLI. | +| [Trace](using-cli.md#trace-flag) | `command -- --trace` | Gets a Fire trace for the command. | +| [Verbose](using-cli.md#verbose-flag) | `command -- --verbose` | | _Note that flags are separated from the Fire command by an isolated `--` arg. Help is an exception; the isolated `--` is optional for getting help._ @@ -39,24 +25,11 @@ Help is an exception; the isolated `--` is optional for getting help._ ## Arguments for Calling fire.Fire() | Argument | Usage | Notes | -| :-------- | :------------------------ | :----------------------------------- | -| component | `fire.Fire(component)` | If omitted, defaults to a dict of | -: : : all locals and globals. : -| command | `fire.Fire(command='hello | Either a string or a list of | -: : --name=5')` : arguments. If a string is provided, : -: : : it is split to determine the : -: : : arguments. If a list or tuple is : -: : : provided, they are the arguments. If : -: : : `command` is omitted, then : -: : : `sys.argv[1\:]` (the arguments from : -: : : the command line) are used by : -: : : default. : -| name | `fire.Fire(name='tool')` | The name of the CLI, ideally the | -: : : name users will enter to run the : -: : : CLI. This name will be used in the : -: : : CLI's help screens. If the argument : -: : : is omitted, it will be inferred : -: : : automatically. : +| --------- | ------------------------- | ------------------------------------ | +| component | `fire.Fire(component)` | If omitted, defaults to a dict of all locals and globals. | +| command | `fire.Fire(command='hello --name=5')` | Either a string or a list of arguments. If a string is provided, it is split to determine the arguments. If a list or tuple is provided, they are the arguments. If `command` is omitted, then `sys.argv[1:]` (the arguments from the command line) are used by default. | +| name | `fire.Fire(name='tool')` | The name of the CLI, ideally the name users will enter to run the CLI. This name will be used in the CLI's help screens. If the argument is omitted, it will be inferred automatically.| +| serialize | `fire.Fire(serialize=custom_serializer)` | If omitted, simple types are serialized via their builtin str method, and any objects that define a custom `__str__` method are serialized with that. If specified, all objects are serialized to text via the provided method. | ## Using a Fire CLI without modifying any code diff --git a/docs/guide.md b/docs/guide.md index cb2c07db..44d8a46d 100644 --- a/docs/guide.md +++ b/docs/guide.md @@ -742,7 +742,18 @@ The complete set of flags available is shown below, in the reference section. | [Trace](using-cli.md#trace-flag) | `command -- --trace` | Gets a Fire trace for the command. | [Verbose](using-cli.md#verbose-flag) | `command -- --verbose` | Include private members in the output. -_Note that flags are separated from the Fire command by an isolated `--` arg._ +_Note that flags are separated from the Fire command by an isolated `--` arg. +Help is an exception; the isolated `--` is optional for getting help._ + + +##### Arguments for Calling fire.Fire() + +| Argument | Usage | Notes | +| --------- | ------------------------- | ------------------------------------ | +| component | `fire.Fire(component)` | If omitted, defaults to a dict of all locals and globals. | +| command | `fire.Fire(command='hello --name=5')` | Either a string or a list of arguments. If a string is provided, it is split to determine the arguments. If a list or tuple is provided, they are the arguments. If `command` is omitted, then `sys.argv[1:]` (the arguments from the command line) are used by default. | +| name | `fire.Fire(name='tool')` | The name of the CLI, ideally the name users will enter to run the CLI. This name will be used in the CLI's help screens. If the argument is omitted, it will be inferred automatically.| +| serialize | `fire.Fire(serialize=custom_serializer)` | If omitted, simple types are serialized via their builtin str method, and any objects that define a custom `__str__` method are serialized with that. If specified, all objects are serialized to text via the provided method. | ### Disclaimer diff --git a/docs/index.md b/docs/index.md index 4eb114b1..8dcc5db6 100644 --- a/docs/index.md +++ b/docs/index.md @@ -106,7 +106,8 @@ Please see [The Python Fire Guide](guide.md). | [Trace](using-cli.md#trace-flag) | `command -- --trace` | Gets a Fire trace for the command. | [Verbose](using-cli.md#verbose-flag) | `command -- --verbose` | -_Note that these flags are separated from the Fire command by an isolated `--`._ +_Note that flags are separated from the Fire command by an isolated `--` arg. +Help is an exception; the isolated `--` is optional for getting help._ ## License diff --git a/docs/installation.md b/docs/installation.md index 614243af..7e4cccb8 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -4,5 +4,5 @@ To install Python Fire with pip, run: `pip install fire` To install Python Fire with conda, run: `conda install fire -c conda-forge` -To install Python Fire from source, first clone the repository and then run: -`python setup.py install` +To install Python Fire from source, first clone the repository and then run +`python setup.py install`. To install from source for development, instead run `python setup.py develop`.