`fab -d` display detailed task info including signature #922

Closed
wants to merge 5 commits into
from

Projects

None yet

2 participants

@kevinjqiu
Contributor

Currently, running fab -d <task_name> shows only the docstring. Sometimes, if the task takes arguments, merely listing what's in the docstring isn't enough. You can always read the function definition in the fabfile, but if the fabfile exports tasks from another module, you will have to trace to that module to find the definition.

This PR spares you of all that trouble by making the signature, as well as any information of default arguments available to you through fab -d <task_name>. This works on old style tasks, decorated tasks and class-based tasks.

@bitprophet
Member

Thanks, this looks awesome! Only thing left undone was a changelog entry but I can add that easily enough.

When testing it by hand I noticed an oddball issue with indentation that I am trying to track down. This is mostly a note to myself for later today when I return from AFK. In master, fab -d indents the docstring uniformly:

» fab -d test                                                             
Displaying detailed information for task 'test':                          

    Run all unit tests and doctests.                                      

    Specify string argument ``args`` for additional args to ``nosetests``.                                                                   

In this ticket's branch, the 2nd line (+ subsequent lines - tested that temporarily) of the docstring is indented an extra indent, which is incorrect:

» fab -d test                                                                 
Displaying detailed information for task 'test':                              

    Run all unit tests and doctests.                                          

        Specify string argument ``args`` for additional args to ``nosetests``.

    Arguments: args=None                                                                                                                                    
Kevin Qiu Bring the indentation of the added detail to the same level of docstring
so that the docstring and the method signature are uniformly indented.
d99b66b
@kevinjqiu
Contributor

@bitprophet Fixed on the branch. Previously, the method signature (the added bits) and the docstring don't have the same indentation level (the docstring was manually indented), so when the output was produced, the second line of the docstring is indented twice. Now I call textwrap.dedent on task.__doc__ first to bring the indentation level of the docstring back to 0 first before the signature info is added on so they will be indented uniformly by fabric.util.indent. Hope it looks ok:

[show-detailed-task-signature +] $ fab -d test
Displaying detailed information for task 'test':

    Run all unit tests and doctests.

    Specify string argument ``args`` for additional args to ``nosetests``.

    Arguments: args=None
@bitprophet
Member

Cool, thanks. I added a test for the issue as well, and a changelog entry, and am currently running tests + pushing.

@bitprophet bitprophet added a commit that referenced this pull request Jul 7, 2013
@bitprophet bitprophet Docstring re #922 cc67753
@bitprophet
Member

Hrm, as usual Github is disagreeing with me (and I didn't rebase; might've been the cherry-pick of the last commit) - it is in fact fully merged to master. Closing manually.

@bitprophet bitprophet closed this Jul 7, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment