Skip to content

Commit

Permalink
Docs and tests
Browse files Browse the repository at this point in the history
- License in README
- _IncludeMember docstring
- testUsageOutputVerbose

PiperOrigin-RevId: 225603056
Change-Id: Iceed29fa261026f3f41e6e29ddeb76147e2051fe
Reviewed-on: https://team-review.git.corp.google.com/c/378384
Reviewed-by: David Bieber <[email protected]>
  • Loading branch information
dbieber committed Dec 14, 2018
1 parent 69f1ef0 commit 871ffab
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 7 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,9 @@ _Note that flags are separated from the Fire command by an isolated `--` arg._

## License

Licensed under the [Apache 2.0](https://github.com/google/python-fire/blob/master/LICENSE) License.

Licensed under the
[Apache 2.0](https://github.com/google/python-fire/blob/master/LICENSE) License.

## Disclaimer

This is not an official Google product.
4 changes: 4 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ Please see [The Python Fire Guide](guide.md).

_Note that flags are separated from the Fire command by an isolated `--` arg._

## License

Licensed under the
[Apache 2.0](https://github.com/google/python-fire/blob/master/LICENSE) License.

## Disclaimer

Expand Down
19 changes: 19 additions & 0 deletions fire/completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,25 @@ def _FishScript(name, commands, default_options=None):


def _IncludeMember(name, verbose):
"""Returns whether a member should be included in auto-completion or help.
Determines whether a member of an object with the specified name should be
included in auto-completion or help text(both usage and detailed help).
If the member starts with '__', it will always be excluded. If the member
starts with only one '_', it will be included for all non-string types. If
verbose is True, the members, including the private members, are always
included.
Args:
name: The name of the member.
verbose: Whether to include private members.
Returns
A boolean value indicating whether the member should be included.
"""
if isinstance(name, six.string_types) and name[:2] == '__':
return False
if verbose:
return True
if isinstance(name, six.string_types):
Expand Down
7 changes: 2 additions & 5 deletions fire/helputils_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,16 +148,13 @@ def testUsageOutput(self):
usage_output,
textwrap.dedent(expected_output).lstrip('\n'))

@testutils.skip('The functionality is not implemented yet')
def testUsageOutputVerbose(self):
component = tc.NoDefaults()
t = trace.FireTrace(component, name='NoDefaults')
usage_output = helputils.UsageText(component, trace=t, verbose=True)
expected_output = '''
Usage: NoDefaults <groups|commands|values>
available groups: __delattr__ | __dict__ | __doc__ | __getattribute__ | __hash__ | __init__ | __repr__ | __setattr__ | __str__ | __weakref__
available commands: __class__ | __format__ | __new__ | __reduce__ | __reduce_ex__ | __sizeof__ | __subclasshook__ | double | triple
available values: __module__
Usage: NoDefaults <commands>
available commands: double | triple
For detailed information on this command, run:
NoDefaults --help
Expand Down

0 comments on commit 871ffab

Please sign in to comment.