Skip to content

Commit

Permalink
Update documentation to show new serialize kwarg and to clean up misf…
Browse files Browse the repository at this point in the history
…ormatted tables (#419)

* Shows new serialize kwarg
* Cleans up misformatted tables
  • Loading branch information
dbieber authored Dec 9, 2022
1 parent 2cb16f6 commit 51afa53
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 47 deletions.
59 changes: 16 additions & 43 deletions docs/api.md
Original file line number Diff line number Diff line change
@@ -1,62 +1,35 @@
## 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._

## 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

Expand Down
13 changes: 12 additions & 1 deletion docs/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.

0 comments on commit 51afa53

Please sign in to comment.