Skip to content

Commit 871ffab

Browse files
committed
Docs and tests
- 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]>
1 parent 69f1ef0 commit 871ffab

4 files changed

Lines changed: 28 additions & 7 deletions

File tree

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,9 @@ _Note that flags are separated from the Fire command by an isolated `--` arg._
9090

9191
## License
9292

93-
Licensed under the [Apache 2.0](https://github.com/google/python-fire/blob/master/LICENSE) License.
94-
93+
Licensed under the
94+
[Apache 2.0](https://github.com/google/python-fire/blob/master/LICENSE) License.
95+
9596
## Disclaimer
9697

9798
This is not an official Google product.

docs/index.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ Please see [The Python Fire Guide](guide.md).
8888

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

91+
## License
92+
93+
Licensed under the
94+
[Apache 2.0](https://github.com/google/python-fire/blob/master/LICENSE) License.
9195

9296
## Disclaimer
9397

fire/completion.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,25 @@ def _FishScript(name, commands, default_options=None):
155155

156156

157157
def _IncludeMember(name, verbose):
158+
"""Returns whether a member should be included in auto-completion or help.
159+
160+
Determines whether a member of an object with the specified name should be
161+
included in auto-completion or help text(both usage and detailed help).
162+
163+
If the member starts with '__', it will always be excluded. If the member
164+
starts with only one '_', it will be included for all non-string types. If
165+
verbose is True, the members, including the private members, are always
166+
included.
167+
168+
Args:
169+
name: The name of the member.
170+
verbose: Whether to include private members.
171+
Returns
172+
A boolean value indicating whether the member should be included.
173+
174+
"""
175+
if isinstance(name, six.string_types) and name[:2] == '__':
176+
return False
158177
if verbose:
159178
return True
160179
if isinstance(name, six.string_types):

fire/helputils_test.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,16 +148,13 @@ def testUsageOutput(self):
148148
usage_output,
149149
textwrap.dedent(expected_output).lstrip('\n'))
150150

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

0 commit comments

Comments
 (0)