Skip to content

Commit

Permalink
Merge remote-tracking branch 'mgax/docs-decorated-funcs'
Browse files Browse the repository at this point in the history
Conflicts:
	docs/api/core/operations.rst
	fabric/context_managers.py
  • Loading branch information
bitprophet committed Oct 29, 2012
2 parents a5f3e77 + 5661b09 commit 5f36cfd
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 24 deletions.
13 changes: 2 additions & 11 deletions docs/api/core/context_managers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,5 @@ Context Managers
================

.. automodule:: fabric.context_managers

.. autofunction:: cd(path)
.. autofunction:: hide(*groups)
.. autofunction:: lcd(path)
.. autofunction:: path
.. autofunction:: prefix
.. autofunction:: settings
.. autofunction:: shell_env(**kwargs)
.. autofunction:: show(*groups)
.. autofunction:: quiet
.. autofunction:: warn_only
:members: cd, hide, lcd, path, prefix, settings, shell_env, show,
quiet, warn_only
10 changes: 1 addition & 9 deletions docs/api/core/operations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,4 @@ Operations
==========

.. automodule:: fabric.operations
:members: local, prompt, require

.. autofunction:: get(remote_path, local_path=None)
.. autofunction:: open_shell(command=None)
.. autofunction:: put(local_path, remote_path, use_sudo=False, mirror_local_mode=False, mode=None)
.. autofunction:: reboot(wait=120)
.. autofunction:: run(command, shell=True, pty=True, combine_stderr=True, quiet=False, warn_only=False, stdout=None, stderr=None)
.. autofunction:: sudo(command, shell=True, pty=True, combine_stderr=True, user=None, quiet=False, warn_only=False, stdout=None, stderr=None, group=None)
.. autofunction:: local(command, capture=False)
:members: get, open_shell, put, reboot, run, sudo, local
15 changes: 15 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,3 +278,18 @@ def release_role(name, rawtext, text, lineno, inliner, options={}, content=[]):

# If false, no module index is generated.
#latex_use_modindex = True


# Restore decorated functions so that autodoc inspects the rigt arguments
def unwrap_decorated_functions():
from fabric import operations
for name in ['get', 'open_shell', 'put', 'reboot', 'run', 'sudo']:
func = getattr(operations, name)
setattr(operations, name, func.undecorated)

from fabric import context_managers
for name in ['show', 'hide']:
func = getattr(context_managers, name)
setattr(context_managers, name, func.undecorated)

unwrap_decorated_functions()
14 changes: 10 additions & 4 deletions fabric/context_managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,13 @@ def _set_output(groups, which):
output.update(previous)


@contextmanager
def documented_contextmanager(func):
wrapper = contextmanager(func)
wrapper.undecorated = func
return wrapper


@documented_contextmanager
def show(*groups):
"""
Context manager for setting the given output ``groups`` to True.
Expand All @@ -85,7 +91,7 @@ def my_task():
return _set_output(groups, True)


@contextmanager
@documented_contextmanager
def hide(*groups):
"""
Context manager for setting the given output ``groups`` to False.
Expand All @@ -105,7 +111,7 @@ def my_task():
return _set_output(groups, False)


@contextmanager
@documented_contextmanager
def _setenv(variables):
"""
Context manager temporarily overriding ``env`` with given key/value pairs.
Expand Down Expand Up @@ -411,7 +417,7 @@ def prefix(command):
return _setenv(lambda: {'command_prefixes': state.env.command_prefixes + [command]})


@contextmanager
@documented_contextmanager
def char_buffered(pipe):
"""
Force local terminal ``pipe`` be character, not line, buffered.
Expand Down
1 change: 1 addition & 0 deletions fabric/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,7 @@ def host_prompting_wrapper(*args, **kwargs):
" host string for connection: ")
env.update(to_dict(host_string))
return func(*args, **kwargs)
host_prompting_wrapper.undecorated = func
return host_prompting_wrapper


Expand Down

0 comments on commit 5f36cfd

Please sign in to comment.